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

Commit 9652f0a3 authored by Mikhail Naganov's avatar Mikhail Naganov Committed by Android (Google) Code Review
Browse files

Merge "MIDI: Use server-side socket in blocking mode for virtual devices"

parents 89bd519b 7ea3e54b
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -226,10 +226,12 @@ public final class MidiDeviceServer implements Closeable {
                ParcelFileDescriptor[] pair = ParcelFileDescriptor.createSocketPair(
                                                    OsConstants.SOCK_SEQPACKET);
                MidiInputPort inputPort = new MidiInputPort(pair[0], portNumber);
                // Configure the server-side socket in non-blocking mode to avoid stalling
                // the entire MIDI framework if client app code gets stuck inside 'onSend'
                // handler.
                // Undo the default blocking-mode of the server-side socket for
                // physical devices to avoid stalling the Java device handler if
                // client app code gets stuck inside 'onSend' handler.
                if (mDeviceInfo.getType() != MidiDeviceInfo.TYPE_VIRTUAL) {
                    IoUtils.setBlocking(pair[0].getFileDescriptor(), false);
                }
                MidiDispatcher dispatcher = mOutputPortDispatchers[portNumber];
                synchronized (dispatcher) {
                    dispatcher.getSender().connect(inputPort);