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

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

Issue 2418493002: //media/midi: use top level namespace midi rather than media.midi (Closed)
Patch Set: TAG name change s/media_midi/midi/ Created 4 years, 2 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/MidiInputPortAndroid.java
diff --git a/media/midi/java/src/org/chromium/media/midi/MidiInputPortAndroid.java b/media/midi/java/src/org/chromium/media/midi/MidiInputPortAndroid.java
deleted file mode 100644
index 60d9abb8f65f68b5410eeedb22a736d9b7bead23..0000000000000000000000000000000000000000
--- a/media/midi/java/src/org/chromium/media/midi/MidiInputPortAndroid.java
+++ /dev/null
@@ -1,97 +0,0 @@
-// 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.annotation.TargetApi;
-import android.media.midi.MidiDevice;
-import android.media.midi.MidiOutputPort;
-import android.media.midi.MidiReceiver;
-import android.os.Build;
-
-import org.chromium.base.annotations.CalledByNative;
-import org.chromium.base.annotations.JNINamespace;
-
-import java.io.IOException;
-
-// Note "InputPort" is named in the Web MIDI manner. It corresponds to MidiOutputPort class in the
-// Android API.
-/**
- * A MidiInputPortAndroid provides data to the associated media::midi::MidiInputPortAndroid object.
- */
-@JNINamespace("media::midi")
-@TargetApi(Build.VERSION_CODES.M)
-class MidiInputPortAndroid {
- /**
- * The underlying port.
- */
- private MidiOutputPort mPort;
- /**
- * A pointer to a media::midi::MidiInputPortAndroid object.
- */
- private long mNativeReceiverPointer;
- /**
- * The device this port belongs to.
- */
- private final MidiDevice mDevice;
- /**
- * The index of the port in the associated device.
- */
- private final int mIndex;
-
- /**
- * constructor
- * @param device the device this port belongs to.
- * @param index the index of the port in the associated device.
- */
- MidiInputPortAndroid(MidiDevice device, int index) {
- mDevice = device;
- mIndex = index;
- }
-
- /**
- * Registers this object to the underlying port so as to the C++ function will be called with
- * the given C++ object when data arrives.
- * @param nativeReceiverPointer a pointer to a media::midi::MidiInputPortAndroid object.
- * @return true if this operation succeeds or the port is already open.
- */
- @CalledByNative
- boolean open(long nativeReceiverPointer) {
- if (mPort != null) {
- return true;
- }
- mPort = mDevice.openOutputPort(mIndex);
- if (mPort == null) {
- return false;
- }
- mNativeReceiverPointer = nativeReceiverPointer;
- mPort.connect(new MidiReceiver() {
- @Override
- public void onSend(byte[] bs, int offset, int count, long timestamp) {
- nativeOnData(mNativeReceiverPointer, bs, offset, count, timestamp);
- }
- });
- return true;
- }
-
- /**
- * Closes the port.
- */
- @CalledByNative
- void close() {
- if (mPort == null) {
- return;
- }
- try {
- mPort.close();
- } catch (IOException e) {
- // We can do nothing here. Just ignore the error.
- }
- mNativeReceiverPointer = 0;
- mPort = null;
- }
-
- private static native void nativeOnData(
- long nativeMidiInputPortAndroid, byte[] bs, int offset, int count, long timestamp);
-}

Powered by Google App Engine
This is Rietveld 408576698