fix invalid mapping detection
[ardour.git] / libs / ardour / midi_ring_buffer.cc
index 658583322ee909efbea4644374cfb5744f050dd0..9258b2f7dc7861a66ceba62f920bfb55cbe46fd6 100644 (file)
@@ -83,7 +83,7 @@ MidiRingBuffer<T>::read(MidiBuffer& dst, framepos_t start, framepos_t end, frame
                this->increment_read_ptr (prefix_size);
 
                uint8_t status;
-               bool r = this->peek (&status, sizeof(uint8_t)); 
+               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.
@@ -103,7 +103,7 @@ MidiRingBuffer<T>::read(MidiBuffer& dst, framepos_t start, framepos_t end, frame
                bool success = read_contents (ev_size, write_loc);
 
 #ifndef NDEBUG
-               if (DEBUG::MidiDiskstreamIO && PBD::debug_bits) {
+               if (DEBUG_ENABLED (DEBUG::MidiDiskstreamIO)) {
                        DEBUG_STR_DECL(a);
                        DEBUG_STR_APPEND(a, string_compose ("wrote MidiEvent to Buffer (time=%1, start=%2 offset=%3)", ev_time, start, offset));
                        for (size_t i=0; i < ev_size; ++i) {
@@ -165,7 +165,19 @@ MidiRingBuffer<T>::skip_to(framepos_t start)
 
                ++count;
 
-               if (ev_size < 8) {
+               /* TODO investigate and think:
+                *
+                * Does it makes sense to keep track of notes
+                * that are skipped (because they're either too late
+                * (underrun) or never used (read-ahead, loop) ?
+                *
+                * skip_to() is called on the rinbuffer between
+                * disk and process. it seems wrong to track them
+                * (a potential synth never sees skipped notes, either)
+                * but there may be more to this.
+                */
+
+               if (ev_size >= 8) {
                        this->increment_read_ptr (ev_size);
                } else {
                        // we only track note on/off, 8 bytes are plenty.
@@ -200,7 +212,7 @@ MidiRingBuffer<T>::flush (framepos_t /*start*/, framepos_t end)
                assert (success);
 
                ev_time = *(reinterpret_cast<T*>((uintptr_t)peekbuf));
-               
+
                if (ev_time >= end) {
                        break;
                }