diff --git a/Timeline/Disk_Stream.C b/Timeline/Disk_Stream.C index 45cbbe9..b721d7c 100644 --- a/Timeline/Disk_Stream.C +++ b/Timeline/Disk_Stream.C @@ -96,7 +96,13 @@ void Disk_Stream::shutdown ( void ) { _terminate = true; - pthread_join( _thread, NULL ); + + /* try to wake the thread so it'll see that it's time to die */ + block_processed(); + + if ( _thread ) + pthread_join( _thread, NULL ); + _terminate = false; } diff --git a/Timeline/Disk_Stream.H b/Timeline/Disk_Stream.H index 351bbb8..e1cc307 100644 --- a/Timeline/Disk_Stream.H +++ b/Timeline/Disk_Stream.H @@ -42,7 +42,7 @@ protected: pthread_t _thread; /* io thread */ - Track *_th; /* Track we belong to */ + Track *_th; /* Track we belong to */ nframes_t _nframes; /* buffer size */ diff --git a/Timeline/Mutex.H b/Timeline/Mutex.H index f98f9eb..39b14e5 100644 --- a/Timeline/Mutex.H +++ b/Timeline/Mutex.H @@ -21,6 +21,8 @@ #include +const pthread_mutex_t _mutex_initializer = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; + class Mutex { @@ -30,7 +32,8 @@ public: Mutex ( ) { - pthread_mutex_init( &_lock, NULL ); +// pthread_mutex_init( &_lock, NULL ); + _lock = _mutex_initializer; } virtual ~Mutex ( ) diff --git a/Timeline/Track.C b/Timeline/Track.C index 2130324..e4d7353 100644 --- a/Timeline/Track.C +++ b/Timeline/Track.C @@ -423,6 +423,17 @@ Track::configure_outputs ( int n ) { int on = output.size(); + if ( n == on ) + return true; + +// engine->lock(); + + Playback_DS *ds = playback_ds; + playback_ds = NULL; + + ds->shutdown(); + delete ds; + if ( n > on ) { for ( int i = on; i < n; ++i ) @@ -444,6 +455,10 @@ Track::configure_outputs ( int n ) } } + + playback_ds = new Playback_DS( this, engine->frame_rate(), engine->nframes(), output.size() ); + +// engine->unlock(); /* FIXME: bogus */ return true; } @@ -453,6 +468,17 @@ Track::configure_inputs ( int n ) { int on = input.size(); + if ( n == on ) + return true; + +// engine->lock(); + + Record_DS *ds = record_ds; + record_ds = NULL; + + ds->shutdown(); + delete ds; + if ( n > on ) { for ( int i = on; i < n; ++i ) @@ -474,6 +500,10 @@ Track::configure_inputs ( int n ) } } + record_ds = new Record_DS( this, engine->frame_rate(), engine->nframes(), input.size() ); + +// engine->unlock(); + /* FIXME: bogus */ return true; }