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

Unified Diff: media/midi/midi_output_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, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/midi/midi_output_port_android.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..f82ad51d63bdc140f9c29744e55037d3315872c3
--- /dev/null
+++ b/media/midi/midi_output_port_android.cc
@@ -0,0 +1,46 @@
+// 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() {
+ Close();
+}
+
+bool MidiOutputPortAndroid::Open() {
+ JNIEnv* env = base::android::AttachCurrentThread();
+ return Java_MidiOutputPortAndroid_open(env, raw_port_.obj());
+}
+
+void MidiOutputPortAndroid::Close() {
+ JNIEnv* env = base::android::AttachCurrentThread();
+ Java_MidiOutputPortAndroid_close(env, raw_port_.obj());
+}
+
+void MidiOutputPortAndroid::Send(const std::vector<uint8>& data) {
+ if (data.size() == 0) {
+ return;
+ }
+
+ JNIEnv* env = base::android::AttachCurrentThread();
+ ScopedJavaLocalRef<jbyteArray> data_to_pass =
+ base::android::ToJavaByteArray(env, &data[0], 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
« no previous file with comments | « media/midi/midi_output_port_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698