debug trace lost midi-messages
[ardour.git] / libs / ardour / midi_port.cc
index 55280eb9428e82aed7fc611a53d866991f0b0b82..1377938f2e7363a734ab28169fd3b32933db0aed 100644 (file)
 #include <cassert>
 #include <iostream>
 
+#include "pbd/compose.h"
+#include "pbd/debug.h"
+
 #include "ardour/midi_port.h"
 #include "ardour/data_type.h"
 #include "ardour/audioengine.h"
+#include "ardour/debug.h"
 
-using namespace ARDOUR;
 using namespace std;
+using namespace ARDOUR;
+using namespace PBD;
 
 #define port_engine AudioEngine::instance()->port_engine()
 
@@ -197,6 +202,21 @@ MidiPort::flush_buffers (pframes_t nframes)
 
                        // event times are in frames, relative to cycle start
 
+#ifndef NDEBUG
+       if (DEBUG::MidiIO & PBD::debug_bits) {
+               DEBUG_STR_DECL(a);
+               DEBUG_STR_APPEND(a, string_compose ("MidiPort %1 pop event    @ %2 sz %3 ", this, ev.time(), ev.size()));
+               for (size_t i=0; i < ev.size(); ++i) {
+                       DEBUG_STR_APPEND(a,hex);
+                       DEBUG_STR_APPEND(a,"0x");
+                       DEBUG_STR_APPEND(a,(int)(ev.buffer()[i]));
+                       DEBUG_STR_APPEND(a,' ');
+               }
+               DEBUG_STR_APPEND(a,'\n');
+               DEBUG_TRACE (DEBUG::MidiIO, DEBUG_STR(a).str());
+       }
+#endif
+
                        assert (ev.time() < (nframes + _global_port_buffer_offset + _port_buffer_offset));
 
                        if (ev.time() >= _global_port_buffer_offset + _port_buffer_offset) {
@@ -206,8 +226,12 @@ MidiPort::flush_buffers (pframes_t nframes)
                                }
                        } else {
                                cerr << "drop flushed event on the floor, time " << ev.time()
-                                    << " to early for " << _global_port_buffer_offset 
-                                    << " + " << _port_buffer_offset << endl;
+                                    << " too early for " << _global_port_buffer_offset
+                                    << " + " << _port_buffer_offset;
+                               for (size_t xx = 0; xx < ev.size(); ++xx) {
+                                       cerr << ' ' << hex << (int) ev.buffer()[xx];
+                               }
+                               cerr << dec << endl;
                        }
                }