Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5b14d989 authored by Mike Lockwood's avatar Mike Lockwood Committed by Android (Google) Code Review
Browse files

Merge "MidiManager API tweaks:"

parents f4f9a301 90b9a6a4
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -254,12 +254,12 @@ public final class MidiDeviceServer implements Closeable {
        return new MidiReceiver() {

            @Override
            public void onPost(byte[] msg, int offset, int count, long timestamp) throws IOException {
            public void post(byte[] msg, int offset, int count, long timestamp) throws IOException {
                ArrayList<MidiInputPort> receivers = mOutputPortReceivers[portNumberF];
                synchronized (receivers) {
                    for (int i = 0; i < receivers.size(); i++) {
                        // FIXME catch errors and remove dead ones
                        receivers.get(i).onPost(msg, offset, count, timestamp);
                        receivers.get(i).post(msg, offset, count, timestamp);
                    }
                }
            }
+1 −1
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ public class MidiInputPort extends MidiPort implements MidiReceiver {
     * @param timestamp future time to post the message (based on
     *                  {@link java.lang.System#nanoTime}
     */
    public void onPost(byte[] msg, int offset, int count, long timestamp) throws IOException {
    public void post(byte[] msg, int offset, int count, long timestamp) throws IOException {
        assert(offset >= 0 && count >= 0 && offset + count <= msg.length);

        synchronized (mBuffer) {
+6 −4
Original line number Diff line number Diff line
@@ -66,22 +66,24 @@ public class MidiManager {
    }

    /**
     * Callback interface used for clients to receive MIDI device added and removed notifications
     * Callback class used for clients to receive MIDI device added and removed notifications
     */
    public interface DeviceCallback {
    public static class DeviceCallback {
        /**
         * Called to notify when a new MIDI device has been added
         *
         * @param device a {@link MidiDeviceInfo} for the newly added device
         */
        void onDeviceAdded(MidiDeviceInfo device);
        void onDeviceAdded(MidiDeviceInfo device) {
        }

        /**
         * Called to notify when a MIDI device has been removed
         *
         * @param device a {@link MidiDeviceInfo} for the removed device
         */
        void onDeviceRemoved(MidiDeviceInfo device);
        void onDeviceRemoved(MidiDeviceInfo device) {
        }
    }

    /**
+1 −1
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ public class MidiOutputPort extends MidiPort implements MidiSender {
                        for (int i = 0; i < mReceivers.size(); i++) {
                            MidiReceiver receiver = mReceivers.get(i);
                            try {
                                receiver.onPost(buffer, offset, size, timestamp);
                                receiver.post(buffer, offset, size, timestamp);
                            } catch (IOException e) {
                                Log.e(TAG, "post failed");
                                deadReceivers.add(receiver);
+2 −2
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ public interface MidiReceiver {
     * The msg bytes should be copied by the receiver rather than retaining a reference
     * to this parameter.
     * Also, modifying the contents of the msg array parameter may result in other receivers
     * in the same application receiving incorrect values in their onPost() method.
     * in the same application receiving incorrect values in their post() method.
     *
     * @param msg a byte array containing the MIDI data
     * @param offset the offset of the first byte of the data in the byte array
@@ -40,5 +40,5 @@ public interface MidiReceiver {
     * @param timestamp the timestamp of the message (based on {@link java.lang.System#nanoTime}
     * @throws IOException
     */
    public void onPost(byte[] msg, int offset, int count, long timestamp) throws IOException;
    public void post(byte[] msg, int offset, int count, long timestamp) throws IOException;
}
Loading