rationalize (a bit) engine start/stop/restart so that it is possible to start up...
[ardour.git] / libs / ardour / midi_ring_buffer.cc
index 21f840af10a9481690332ea4b0bba69f28d7f9c9..e4ae3f3ffe5e9b210f0df544d34b0c6f1e8a66d9 100644 (file)
@@ -17,6 +17,7 @@
 */
 
 #include "pbd/compose.h"
+#include "pbd/enumwriter.h"
 #include "pbd/error.h"
 
 #include "ardour/debug.h"
@@ -54,7 +55,7 @@ MidiRingBuffer<T>::read(MidiBuffer& dst, framepos_t start, framepos_t end, frame
                /* this cannot fail, because we've already verified that there
                   is prefix_space to read
                */
-               assert (this->peek (peekbuf, prefix_size));
+               this->peek (peekbuf, prefix_size);
 
                ev_time = *((T*) peekbuf);
                ev_size = *((uint32_t*)(peekbuf + sizeof(T) + sizeof (Evoral::EventType)));
@@ -78,18 +79,8 @@ MidiRingBuffer<T>::read(MidiBuffer& dst, framepos_t start, framepos_t end, frame
                this->increment_read_ptr (prefix_size);
 
                uint8_t status;
-               assert (this->peek (&status, sizeof(uint8_t))); // If this failed, buffer is corrupt, all hope is lost
-
-               // Ignore event if it doesn't match channel filter
-               if (is_channel_event(status) && get_channel_mode() == FilterChannels) {
-                       const uint8_t channel = status & 0x0F;
-                       if (!(get_channel_mask() & (1L << channel))) {
-                               DEBUG_TRACE (DEBUG::MidiDiskstreamIO, string_compose ("MRB skipping event (%3 bytes) due to channel mask (mask = %1 chn = %2)\n",
-                                                                                     get_channel_mask(), (int) channel, ev_size));
-                               this->increment_read_ptr (ev_size); // Advance read pointer to next event
-                               continue;
-                       }
-               }
+               bool r = this->peek (&status, sizeof(uint8_t)); 
+               assert (r); // If this failed, buffer is corrupt, all hope is lost
 
                /* lets see if we are going to be able to write this event into dst.
                 */
@@ -129,10 +120,7 @@ MidiRingBuffer<T>::read(MidiBuffer& dst, framepos_t start, framepos_t end, frame
                        } else if (is_note_off(write_loc[0])) {
                                _tracker.remove (write_loc[1], write_loc[0] & 0xf);
                        }
-                       
-                       if (is_channel_event(status) && get_channel_mode() == ForceChannel) {
-                               write_loc[0] = (write_loc[0] & 0xF0) | (get_channel_mask() & 0x0F);
-                       }
+
                        ++count;
                } else {
                        cerr << "WARNING: error reading event contents from MIDI ring" << endl;