Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(381)

Side by Side Diff: media/midi/midi_input_port_android.cc

Issue 1177973003: [Web MIDI] Use Android MIDI API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "media/midi/midi_input_port_android.h"
6
7 #include "base/android/jni_array.h"
8 #include "jni/MidiInputPortAndroid_jni.h"
9
10 namespace media {
11 namespace midi {
12
13 MidiInputPortAndroid::MidiInputPortAndroid(JNIEnv* env,
14 jobject raw,
15 Delegate* delegate)
16 : delegate_(delegate) {
17 Java_MidiInputPortAndroid_connect(env, raw, reinterpret_cast<jlong>(this));
18 }
19
20 MidiInputPortAndroid::~MidiInputPortAndroid() {}
21
22 void MidiInputPortAndroid::OnData(JNIEnv* env,
23 jobject caller,
24 jbyteArray data,
25 jint offset,
26 jint size,
27 jlong timestamp) {
28 std::vector<uint8> bytes;
29 base::android::JavaByteArrayToByteVector(env, data, &bytes);
30
31 // We don't use |timestamp| because MidiManager wants base::TimeTicks.
philburk 2015/08/19 01:40:15 Ignoring timestamp can cause rendering errors. Som
yhirano 2015/08/19 06:32:03 Done.
32 const uint8* head = bytes.size() ? &bytes[offset] : nullptr;
33 delegate_->OnReceivedData(this, head, size, base::TimeTicks::Now());
34 }
35
36 bool MidiInputPortAndroid::Register(JNIEnv* env) {
37 return RegisterNativesImpl(env);
38 }
39
40 } // namespace midi
41 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698