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

Unified Diff: media/midi/java/src/org/chromium/media/midi/MidiOutputPortAndroid.java

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 side-by-side diff with in-line comments
Download patch
Index: media/midi/java/src/org/chromium/media/midi/MidiOutputPortAndroid.java
diff --git a/media/midi/java/src/org/chromium/media/midi/MidiOutputPortAndroid.java b/media/midi/java/src/org/chromium/media/midi/MidiOutputPortAndroid.java
new file mode 100644
index 0000000000000000000000000000000000000000..827fe0b5e1645bdf1581e8ae760e23f63f6c80a5
--- /dev/null
+++ b/media/midi/java/src/org/chromium/media/midi/MidiOutputPortAndroid.java
@@ -0,0 +1,56 @@
+// 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.
+
+package org.chromium.media.midi;
+
+import android.media.midi.MidiInputPort;
+
+import org.chromium.base.annotations.CalledByNative;
+import org.chromium.base.annotations.JNINamespace;
+
+import java.io.IOException;
+
+/**
+ * A class implementing media::midi::MidiOutputPortAndroid functionality.
+ */
+// Note "OutputPort" is named in the WebMIDI manner. It corresponds to MidiInputPort class in the
+// Android API.
+@JNINamespace("media::midi")
+class MidiOutputPortAndroid {
+ /**
+ * The underlying port.
+ */
+ private MidiInputPort mPort;
+
+ /**
+ * constructor
+ * @port port
+ */
+ MidiOutputPortAndroid(MidiInputPort port) {
+ mPort = port;
+ }
+
+ /**
+ * Sends the data to the underlying output port.
+ */
+ @CalledByNative
+ void send(byte[] bs) {
+ try {
+ mPort.send(bs, 0, bs.length);
+ } catch (IOException e) {
+ // We can do nothing here. Just ignore the error.
+ }
+ }
+
+ /**
+ * Closes the port.
+ */
+ void close() {
+ try {
+ mPort.close();
+ } catch (IOException e) {
+ // We can do nothing here. Just ignore the error.
+ }
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698