diff options
author | Mike Lockwood <lockwood@google.com> | 2015-03-07 23:50:36 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-03-07 23:50:37 +0000 |
commit | d73ff8727ddd88a0f983acc55cbe8d8d3a223993 (patch) | |
tree | a98abbdc5f16e4e68505335b9cc226478910ac5d /services | |
parent | 6c4c58d6d96a9118b1eea33c85e9494202d3e2e4 (diff) | |
parent | 4a3d7ed45d98ad2fe900221755845b87f26b554a (diff) | |
download | frameworks_base-d73ff8727ddd88a0f983acc55cbe8d8d3a223993.zip frameworks_base-d73ff8727ddd88a0f983acc55cbe8d8d3a223993.tar.gz frameworks_base-d73ff8727ddd88a0f983acc55cbe8d8d3a223993.tar.bz2 |
Merge changes Ib5cc22db,I93e0c449,I65cd4cfd,I1cef3bd4,I628c0468
* changes:
MIDI Manager: Add explicit close mechanism for input and output ports
MidiDeviceService: Add getDeviceInfo() accessor method
Add MidiDevice.close() method so we can clean up our ServiceConnection
Make MidiSender and MidiReceiver abstract classes, rename MidiReceiver.post() to receive()
Eliminate MidiPort base class for MidiInputPort and MidiOutputPort
Diffstat (limited to 'services')
-rw-r--r-- | services/usb/java/com/android/server/usb/UsbMidiDevice.java | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/services/usb/java/com/android/server/usb/UsbMidiDevice.java b/services/usb/java/com/android/server/usb/UsbMidiDevice.java index a6e9677..51d61bb 100644 --- a/services/usb/java/com/android/server/usb/UsbMidiDevice.java +++ b/services/usb/java/com/android/server/usb/UsbMidiDevice.java @@ -21,7 +21,6 @@ import android.media.midi.MidiDeviceInfo; import android.media.midi.MidiDeviceServer; import android.media.midi.MidiDispatcher; import android.media.midi.MidiManager; -import android.media.midi.MidiPort; import android.media.midi.MidiReceiver; import android.media.midi.MidiSender; import android.os.Bundle; @@ -46,6 +45,8 @@ public final class UsbMidiDevice implements Closeable { private final MidiReceiver[] mInputPortReceivers; + private static final int BUFFER_SIZE = 512; + // for polling multiple FileDescriptors for MIDI events private final StructPollfd[] mPollFDs; // streams for reading from ALSA driver @@ -102,7 +103,7 @@ public final class UsbMidiDevice implements Closeable { final int portF = port; mInputPortReceivers[port] = new MidiReceiver() { @Override - public void post(byte[] data, int offset, int count, long timestamp) + public void receive(byte[] data, int offset, int count, long timestamp) throws IOException { // FIXME - timestamps are ignored, future posting not supported yet. mOutputStreams[portF].write(data, offset, count); @@ -130,7 +131,7 @@ public final class UsbMidiDevice implements Closeable { new Thread() { @Override public void run() { - byte[] buffer = new byte[MidiPort.MAX_PACKET_DATA_SIZE]; + byte[] buffer = new byte[BUFFER_SIZE]; try { boolean done = false; while (!done) { @@ -143,7 +144,7 @@ public final class UsbMidiDevice implements Closeable { int count = mInputStreams[index].read(buffer); long timestamp = System.nanoTime(); - outputReceivers[index].post(buffer, 0, count, timestamp); + outputReceivers[index].receive(buffer, 0, count, timestamp); } else if ((pfd.revents & (OsConstants.POLLERR | OsConstants.POLLHUP)) != 0) { done = true; |