merge-in-place debugging (to be removed later)
authorPaul Davis <paul@linuxaudiosystems.com>
Wed, 21 Dec 2011 17:30:08 +0000 (17:30 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Wed, 21 Dec 2011 17:30:08 +0000 (17:30 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@11050 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/midi_buffer.cc

index 403f0a86ac44b81c6ed9d05d3f5044093756a52d..6e07a1bedd9fbca4fdf06b7d572438d86b3051ae 100644 (file)
@@ -407,6 +407,16 @@ MidiBuffer::merge_in_place(const MidiBuffer &other)
                return false;
        }
 
+       cerr << "MERGING\nUS: ";
+       for (MidiBuffer::iterator i = begin(); i != end(); ++i) {
+               cerr << *i << " ; ";
+       }
+       cerr << "\nTHEM: ";
+       for (MidiBuffer::const_iterator i = other.begin(); i != other.end(); ++i) {
+               cerr << *i << " ; ";
+       }
+       cerr << endl;
+
 #ifndef NDEBUG
 #ifdef  TEST_MIDI_MERGE
        size_t   test_orig_us_size   = _size;
@@ -445,14 +455,21 @@ MidiBuffer::merge_in_place(const MidiBuffer &other)
                src = -1;
                sz = 0;
 
+               cerr << "Start merge skip with them = " << *them << endl;
+
                while (them != other.end() && (*them).time() < (*us).time()) {
                        if (src == -1) {
                                src = them.offset;
                        }
                        sz += sizeof (TimeType) + (*them).size();
+                       cerr << " move through other event " << *them << endl;
                        ++them;
                }
 
+               cerr << "merge skip done, sz = " << sz << " us @ end ? " << (us == end())
+                    << " them @ end ? " << (them == other.end()) 
+                    << endl;
+
                if (sz) {
                        assert(src >= 0);
                        /* move existing */
@@ -471,12 +488,15 @@ MidiBuffer::merge_in_place(const MidiBuffer &other)
                        */
 
                        while (us != end() && (*us).time() < (*them).time()) {
+                               cerr << "skip by our own event " << (*us) << endl;
                                ++us;
                        }
                }
 
                if (us == end()) { 
 
+                       cerr << " append rest of other to us\n";
+
                        /* just append the rest of other */
 
                        memcpy (_data + us.offset, other._data + them.offset, other._size - them.offset);