main fix: when transport stops, clear per-region per-playlist note trackers even if there is no capture data to process; side effects: remove unused MidiBuffer::merge() and add DEBUG::MidiTrackers as well as more and better MIDI debug tracing facilities

git-svn-id: svn://localhost/ardour2/branches/3.0@11057 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2011-12-22 20:14:47 +00:00
parent 2449a787c5
commit ed2beaffee
11 changed files with 61 additions and 60 deletions

View file

@ -130,8 +130,6 @@ bool
MidiBuffer::push_back(const Evoral::MIDIEvent<TimeType>& ev)
{
const size_t stamp_size = sizeof(TimeType);
/*cerr << "MidiBuffer: pushing event @ " << ev.time()
<< " size = " << ev.size() << endl;*/
if (_size + stamp_size + ev.size() >= _capacity) {
cerr << "MidiBuffer::push_back failed (buffer is full)" << endl;
@ -204,6 +202,7 @@ bool
MidiBuffer::push_back(const jack_midi_event_t& ev)
{
const size_t stamp_size = sizeof(TimeType);
if (_size + stamp_size + ev.size >= _capacity) {
cerr << "MidiBuffer::push_back failed (buffer is full)" << endl;
return false;
@ -214,6 +213,21 @@ MidiBuffer::push_back(const jack_midi_event_t& ev)
return false;
}
#ifndef NDEBUG
if (DEBUG::MidiIO & PBD::debug_bits) {
DEBUG_STR_DECL(a);
DEBUG_STR_APPEND(a, string_compose ("midibuffer %1 push jack 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
uint8_t* const write_loc = _data + _size;
*((TimeType*)write_loc) = ev.time;
memcpy(write_loc + stamp_size, ev.buffer, ev.size);
@ -387,9 +401,9 @@ MidiBuffer::second_simultaneous_midi_byte_is_first (uint8_t a, uint8_t b)
/** Merge \a other into this buffer. Realtime safe. */
bool
MidiBuffer::merge_in_place(const MidiBuffer &other)
MidiBuffer::merge_in_place (const MidiBuffer &other)
{
if (other.size() || size()) {
if (other.size() && size()) {
DEBUG_TRACE (DEBUG::MidiIO, string_compose ("merge in place, sizes %1/%2\n", size(), other.size()));
}
@ -549,49 +563,3 @@ MidiBuffer::merge_in_place(const MidiBuffer &other)
return true;
}
/** Clear, and merge \a a and \a b into this buffer.
*
* \return true if complete merge was successful
*/
bool
MidiBuffer::merge(const MidiBuffer& a, const MidiBuffer& b)
{
_size = 0;
if (this == &a) {
return merge_in_place(b);
} else if (this == &b) {
return merge_in_place(a);
}
const_iterator ai = a.begin();
const_iterator bi = b.begin();
resize(a.size() + b.size());
while (ai != a.end() && bi != b.end()) {
if ((*ai).time() < (*bi).time()) {
memcpy(_data + _size, (*ai).buffer(), (*ai).size());
_size += (*ai).size();
++ai;
} else {
memcpy(_data + _size, (*bi).buffer(), (*bi).size());
_size += (*bi).size();
++bi;
}
}
while (ai != a.end()) {
memcpy(_data + _size, (*ai).buffer(), (*ai).size());
_size += (*ai).size();
++ai;
}
while (bi != b.end()) {
memcpy(_data + _size, (*bi).buffer(), (*bi).size());
_size += (*bi).size();
++bi;
}
return true;
}