Fix race causing MIDI tracer to stop working when master record state is changed.

git-svn-id: svn://localhost/ardour2/branches/3.0@7320 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington 2010-06-28 23:07:05 +00:00
parent 21e10145d8
commit a3cb425ca9
2 changed files with 11 additions and 5 deletions

View File

@ -25,7 +25,7 @@ MidiTracer::MidiTracer (const std::string& name, Parser& p)
, autoscroll (true)
, show_hex (true)
, collect (true)
, update_queued (false)
, _update_queued (0)
, fifo (1024)
, buffer_pool ("miditracer", buffer_size, 1024) // 1024 256 byte buffers
, autoscroll_button (_("Auto-Scroll"))
@ -255,9 +255,9 @@ MidiTracer::tracer (Parser&, byte* msg, size_t len)
fifo.write (&buf, 1);
if (!update_queued) {
if (g_atomic_int_get (&_update_queued) == 0) {
gui_context()->call_slot (invalidator (*this), boost::bind (&MidiTracer::update, this));
update_queued = true;
g_atomic_int_inc (&_update_queued);
}
}
@ -265,7 +265,7 @@ void
MidiTracer::update ()
{
bool updated = false;
update_queued = false;
g_atomic_int_dec_and_test (&_update_queued);
RefPtr<TextBuffer> buf (text.get_buffer());

View File

@ -36,7 +36,13 @@ class MidiTracer : public ArdourDialog
bool autoscroll;
bool show_hex;
bool collect;
volatile bool update_queued;
/** Incremented when an update is requested, decremented when one is handled; hence
* equal to 0 when an update is not queued. May temporarily be negative if a
* update is handled before it was noted that it had just been queued.
*/
volatile gint _update_queued;
RingBuffer<char *> fifo;
Pool buffer_pool;
static const size_t buffer_size = 256;