diff options
Diffstat (limited to 'android/WALT/app/src/main/jni/sync_clock_jni.c')
-rw-r--r-- | android/WALT/app/src/main/jni/sync_clock_jni.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/android/WALT/app/src/main/jni/sync_clock_jni.c b/android/WALT/app/src/main/jni/sync_clock_jni.c new file mode 100644 index 0000000..15adfd5 --- /dev/null +++ b/android/WALT/app/src/main/jni/sync_clock_jni.c @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "sync_clock.h" + +#include <android/log.h> +#include <jni.h> + + +#define APPNAME "ClockSyncJNI" + +// This is global so that we don't have to pass it aroundbetween Java and here. +// TODO: come up with some more elegant solution. +struct clock_connection clk; + +jlong +Java_org_chromium_latency_walt_WaltUsbConnection_syncClock__III( + JNIEnv* env, + jobject thiz, + jint fd, + jint endpoint_out, + jint endpoint_in +){ + clk.fd = (int)fd; + clk.endpoint_in = (int)endpoint_in; + clk.endpoint_out = (int)endpoint_out; + clk.t_base = 0; + sync_clocks(&clk); + // __android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "Returned from sync_clocks\n"); + + int64_t t_base = clk.t_base; + return (jlong) t_base; +} + +void +Java_org_chromium_latency_walt_WaltUsbConnection_updateBounds() { + update_bounds(&clk); +} + +jint +Java_org_chromium_latency_walt_WaltUsbConnection_getMinE() { + return clk.minE; +} + + +jint +Java_org_chromium_latency_walt_WaltUsbConnection_getMaxE() { + return clk.maxE; +} |