From 338e66c7593f1eaa61256dca40cabc24b09288b0 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Thu, 29 Mar 2012 22:08:45 -0700 Subject: [PATCH] Cleanup locking for OSC playback. --- timeline/src/OSC_Thread.C | 4 ---- timeline/src/Timeline.C | 20 ++++++++++++-------- timeline/src/Track.C | 8 ++++---- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/timeline/src/OSC_Thread.C b/timeline/src/OSC_Thread.C index f252810..be6e074 100644 --- a/timeline/src/OSC_Thread.C +++ b/timeline/src/OSC_Thread.C @@ -51,11 +51,7 @@ OSC_Thread::process ( void ) { usleep( 100 * 1000 ); - lock(); - timeline->process_osc(); - - unlock(); } } diff --git a/timeline/src/Timeline.C b/timeline/src/Timeline.C index 8a8bf79..1a4f7d7 100644 --- a/timeline/src/Timeline.C +++ b/timeline/src/Timeline.C @@ -1479,16 +1479,16 @@ Timeline::add_track ( Track *track ) { DMESSAGE( "added new track to the timeline" ); - engine->lock(); + wrlock(); - osc_thread->lock(); + engine->lock(); tracks->add( track ); - osc_thread->unlock(); - engine->unlock(); + unlock(); + /* FIXME: why is this necessary? doesn't the above add do DAMAGE_CHILD? */ redraw(); @@ -1500,17 +1500,17 @@ Timeline::remove_track ( Track *track ) { DMESSAGE( "removed track from the timeline" ); - engine->lock(); + wrlock(); - osc_thread->lock(); + engine->lock(); /* FIXME: what to do about track contents? */ tracks->remove( track ); - osc_thread->unlock(); - engine->unlock(); + unlock(); + /* FIXME: why is this necessary? doesn't the above add do DAMAGE_CHILD? */ redraw(); } @@ -1708,6 +1708,8 @@ Timeline::process_osc ( void ) { THREAD_ASSERT( OSC ); + rdlock(); + /* reconnect OSC signals */ for ( int i = tracks->children(); i-- ; ) { @@ -1719,5 +1721,7 @@ Timeline::process_osc ( void ) c->process_osc(); } } + + unlock(); } diff --git a/timeline/src/Track.C b/timeline/src/Track.C index a53e9b8..1a42171 100644 --- a/timeline/src/Track.C +++ b/timeline/src/Track.C @@ -582,16 +582,16 @@ Track::remove ( Control_Sequence *t ) if ( ! control ) return; - engine->lock(); + timeline->wrlock(); - timeline->osc_thread->lock(); + engine->lock(); control->remove( t ); - timeline->osc_thread->unlock(); - engine->unlock(); + timeline->unlock(); + resize(); }