some backends can handle incorrectly ordered midi events.
authorRobin Gareus <robin@gareus.org>
Mon, 9 Mar 2015 04:41:36 +0000 (05:41 +0100)
committerRobin Gareus <robin@gareus.org>
Mon, 9 Mar 2015 04:41:36 +0000 (05:41 +0100)
(that can happen if multiple sources send to the same
ouput port, in particular async midi events)

libs/backends/alsa/alsa_audiobackend.cc
libs/backends/coreaudio/coreaudio_backend.cc
libs/backends/dummy/dummy_audiobackend.cc

index a18d58ee586552ed87a4dbd6dd0efb9238015aeb..8befb9219cadbe91ca4319d31ece8699e2dc21c7 100644 (file)
@@ -1256,9 +1256,11 @@ AlsaAudioBackend::midi_event_put (
        assert (buffer && port_buffer);
        AlsaMidiBuffer& dst = * static_cast<AlsaMidiBuffer*>(port_buffer);
        if (dst.size () && (pframes_t)dst.back ()->timestamp () > timestamp) {
+#ifndef NDEBUG
+               // nevermind, ::get_buffer() sorts events
                fprintf (stderr, "AlsaMidiBuffer: it's too late for this event. %d > %d\n",
                                (pframes_t)dst.back ()->timestamp (), timestamp);
-               return -1;
+#endif
        }
        dst.push_back (boost::shared_ptr<AlsaMidiEvent>(new AlsaMidiEvent (timestamp, buffer, size)));
        return 0;
index 8946aea0a74b2c50c1a796d106e73bccf138fd01..50477b6d08ebbae2438ba6c94e4fa0a428a81da0 100644 (file)
@@ -1227,9 +1227,11 @@ CoreAudioBackend::midi_event_put (
        if (!buffer || !port_buffer) return -1;
        CoreMidiBuffer& dst = * static_cast<CoreMidiBuffer*>(port_buffer);
        if (dst.size () && (pframes_t)dst.back ()->timestamp () > timestamp) {
-               fprintf (stderr, "CoreMidiBuffer: it's too late for this event. %d > %d\n",
+#ifndef NDEBUG
+               // nevermind, ::get_buffer() sorts events
+               fprintf (stderr, "CoreMidiBuffer: unordered event: %d > %d\n",
                                (pframes_t)dst.back ()->timestamp (), timestamp);
-               return -1;
+#endif
        }
        dst.push_back (boost::shared_ptr<CoreMidiEvent>(new CoreMidiEvent (timestamp, buffer, size)));
        return 0;
index 462f1b9dc3f04fc9d4570da2daf0def9797265f0..cf49c7d5e835aa748c4aedbcb94bce2abc75113a 100644 (file)
@@ -981,8 +981,8 @@ DummyAudioBackend::midi_event_put (
        assert (buffer && port_buffer);
        DummyMidiBuffer& dst = * static_cast<DummyMidiBuffer*>(port_buffer);
        if (dst.size () && (pframes_t)dst.back ()->timestamp () > timestamp) {
+               // nevermind, ::get_buffer() sorts events, but always print warning
                fprintf (stderr, "DummyMidiBuffer: it's too late for this event.\n");
-               return -1;
        }
        dst.push_back (boost::shared_ptr<DummyMidiEvent>(new DummyMidiEvent (timestamp, buffer, size)));
        return 0;