• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "sync_clock.h"
18 
19 #include <android/log.h>
20 #include <jni.h>
21 
22 
23 #define APPNAME "ClockSyncJNI"
24 
25 // This is global so that we don't have to pass it aroundbetween Java and here.
26 // TODO: come up with some more elegant solution.
27 struct clock_connection clk;
28 
29 jlong
Java_org_chromium_latency_walt_WaltUsbConnection_syncClock__III(JNIEnv * env,jobject thiz,jint fd,jint endpoint_out,jint endpoint_in)30 Java_org_chromium_latency_walt_WaltUsbConnection_syncClock__III(
31     __attribute__((unused)) JNIEnv* env,
32     __attribute__((unused)) jobject thiz,
33     jint fd,
34     jint endpoint_out,
35     jint endpoint_in
36 ){
37     clk.fd = (int)fd;
38     clk.endpoint_in = (int)endpoint_in;
39     clk.endpoint_out = (int)endpoint_out;
40     clk.t_base = 0;
41     sync_clocks(&clk);
42     // __android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "Returned from sync_clocks\n");
43 
44     int64_t t_base = clk.t_base;
45     return (jlong) t_base;
46 }
47 
48 void
Java_org_chromium_latency_walt_WaltUsbConnection_updateBounds()49 Java_org_chromium_latency_walt_WaltUsbConnection_updateBounds() {
50     update_bounds(&clk);
51 }
52 
53 jint
Java_org_chromium_latency_walt_WaltUsbConnection_getMinE()54 Java_org_chromium_latency_walt_WaltUsbConnection_getMinE() {
55     return clk.minE;
56 }
57 
58 
59 jint
Java_org_chromium_latency_walt_WaltUsbConnection_getMaxE()60 Java_org_chromium_latency_walt_WaltUsbConnection_getMaxE() {
61     return clk.maxE;
62 }
63