OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/midi/midi_input_port_android.h" | 5 #include "media/midi/midi_input_port_android.h" |
6 | 6 |
7 #include "base/android/jni_array.h" | 7 #include "base/android/jni_array.h" |
8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
9 #include "jni/MidiInputPortAndroid_jni.h" | 9 #include "jni/MidiInputPortAndroid_jni.h" |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 JNIEnv* env = base::android::AttachCurrentThread(); | 30 JNIEnv* env = base::android::AttachCurrentThread(); |
31 Java_MidiInputPortAndroid_close(env, raw_port_.obj()); | 31 Java_MidiInputPortAndroid_close(env, raw_port_.obj()); |
32 } | 32 } |
33 | 33 |
34 void MidiInputPortAndroid::OnData(JNIEnv* env, | 34 void MidiInputPortAndroid::OnData(JNIEnv* env, |
35 const JavaParamRef<jobject>& caller, | 35 const JavaParamRef<jobject>& caller, |
36 const JavaParamRef<jbyteArray>& data, | 36 const JavaParamRef<jbyteArray>& data, |
37 jint offset, | 37 jint offset, |
38 jint size, | 38 jint size, |
39 jlong timestamp) { | 39 jlong timestamp) { |
40 std::vector<uint8> bytes; | 40 std::vector<uint8_t> bytes; |
41 base::android::JavaByteArrayToByteVector(env, data, &bytes); | 41 base::android::JavaByteArrayToByteVector(env, data, &bytes); |
42 | 42 |
43 if (size == 0) { | 43 if (size == 0) { |
44 return; | 44 return; |
45 } | 45 } |
46 | 46 |
47 // TimeTick's internal value is in microseconds, |timestamp| is in | 47 // TimeTick's internal value is in microseconds, |timestamp| is in |
48 // nanoseconds. Both are monotonic. | 48 // nanoseconds. Both are monotonic. |
49 base::TimeTicks timestamp_to_pass = base::TimeTicks::FromInternalValue( | 49 base::TimeTicks timestamp_to_pass = base::TimeTicks::FromInternalValue( |
50 timestamp / base::TimeTicks::kNanosecondsPerMicrosecond); | 50 timestamp / base::TimeTicks::kNanosecondsPerMicrosecond); |
51 delegate_->OnReceivedData(this, &bytes[offset], size, timestamp_to_pass); | 51 delegate_->OnReceivedData(this, &bytes[offset], size, timestamp_to_pass); |
52 } | 52 } |
53 | 53 |
54 bool MidiInputPortAndroid::Register(JNIEnv* env) { | 54 bool MidiInputPortAndroid::Register(JNIEnv* env) { |
55 return RegisterNativesImpl(env); | 55 return RegisterNativesImpl(env); |
56 } | 56 } |
57 | 57 |
58 } // namespace midi | 58 } // namespace midi |
59 } // namespace media | 59 } // namespace media |
OLD | NEW |