small round of compiler warning fixes
[ardour.git] / libs / ardour / midi_ring_buffer.cc
index 21f840af10a9481690332ea4b0bba69f28d7f9c9..555ac6fb96c6422975655688ee8f9eaf3092d9c0 100644 (file)
@@ -17,6 +17,7 @@
 */
 
 #include "pbd/compose.h"
+#include "pbd/enumwriter.h"
 #include "pbd/error.h"
 
 #include "ardour/debug.h"
@@ -54,10 +55,10 @@ 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)));
+               ev_time = *(reinterpret_cast<T*>((uintptr_t)peekbuf));
+               ev_size = *(reinterpret_cast<uint32_t*>((uintptr_t)(peekbuf + sizeof(T) + sizeof (Evoral::EventType))));
 
                if (ev_time >= end) {
                        DEBUG_TRACE (DEBUG::MidiDiskstreamIO, string_compose ("MRB event @ %1 past end @ %2\n", ev_time, end));
@@ -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;
@@ -160,13 +148,13 @@ MidiRingBuffer<T>::flush (framepos_t /*start*/, framepos_t end)
                */
                assert (success);
 
-               ev_time = *((T*) peekbuf);
+               ev_time = *(reinterpret_cast<T*>((uintptr_t)peekbuf));
                
                if (ev_time >= end) {
                        break;
                }
 
-               ev_size = *((uint32_t*)(peekbuf + sizeof(T) + sizeof (Evoral::EventType)));
+               ev_size = *(reinterpret_cast<uint32_t*>((uintptr_t)(peekbuf + sizeof(T) + sizeof (Evoral::EventType))));
                this->increment_read_ptr (prefix_size);
                this->increment_read_ptr (ev_size);
        }