Chromium Code Reviews| Index: media/midi/midi_output_port_android.cc |
| diff --git a/media/midi/midi_output_port_android.cc b/media/midi/midi_output_port_android.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e3eb03e1ae875e118d316d8236bb5786026090bb |
| --- /dev/null |
| +++ b/media/midi/midi_output_port_android.cc |
| @@ -0,0 +1,31 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "media/midi/midi_output_port_android.h" |
| + |
| +#include "base/android/jni_array.h" |
| +#include "jni/MidiOutputPortAndroid_jni.h" |
| + |
| +namespace media { |
| +namespace midi { |
| + |
| +MidiOutputPortAndroid::MidiOutputPortAndroid(JNIEnv* env, jobject raw) |
| + : raw_port_(env, raw) {} |
| +MidiOutputPortAndroid::~MidiOutputPortAndroid() {} |
| + |
| +void MidiOutputPortAndroid::Send(const std::vector<uint8>& data) { |
| + JNIEnv* env = base::android::AttachCurrentThread(); |
| + const uint8* head = data.size() ? &data[0] : nullptr; |
|
philburk
2015/08/19 01:40:15
If there is no data maybe skip the send call.
yhirano
2015/08/19 06:32:03
Done.
|
| + ScopedJavaLocalRef<jbyteArray> data_to_pass = |
| + base::android::ToJavaByteArray(env, head, data.size()); |
| + |
| + Java_MidiOutputPortAndroid_send(env, raw_port_.obj(), data_to_pass.obj()); |
| +} |
| + |
| +bool MidiOutputPortAndroid::Register(JNIEnv* env) { |
| + return RegisterNativesImpl(env); |
| +} |
| + |
| +} // namespace midi |
| +} // namespace media |