From 455dc11dc8104277332e5d91f3f33d97abcc6fd4 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Tue, 27 May 2008 19:36:17 -0500 Subject: [PATCH] Fix order of track destruction. --- Timeline/Annotation_Sequence.H | 4 ++-- Timeline/Audio_Sequence.C | 4 ++-- Timeline/Control_Sequence.C | 2 -- Timeline/Engine/Disk_Stream.C | 8 ++------ Timeline/Engine/Playback_DS.C | 2 -- Timeline/Sequence.C | 3 +++ Timeline/Track.C | 17 +++++++++++++++-- 7 files changed, 24 insertions(+), 16 deletions(-) diff --git a/Timeline/Annotation_Sequence.H b/Timeline/Annotation_Sequence.H index d1e8cbc..841c705 100644 --- a/Timeline/Annotation_Sequence.H +++ b/Timeline/Annotation_Sequence.H @@ -83,9 +83,9 @@ public: ~Annotation_Sequence ( ) { - track()->remove( this ); - log_destroy(); + + track()->remove( this ); } int handle ( int m ) diff --git a/Timeline/Audio_Sequence.C b/Timeline/Audio_Sequence.C index d590db4..61279e9 100644 --- a/Timeline/Audio_Sequence.C +++ b/Timeline/Audio_Sequence.C @@ -49,9 +49,9 @@ Audio_Sequence::Audio_Sequence ( Track *track ) : Sequence( track ) Audio_Sequence::~Audio_Sequence ( ) { - track()->remove( this ); - log_destroy(); + + track()->remove( this ); } diff --git a/Timeline/Control_Sequence.C b/Timeline/Control_Sequence.C index f54bccb..b454480 100644 --- a/Timeline/Control_Sequence.C +++ b/Timeline/Control_Sequence.C @@ -65,8 +65,6 @@ Control_Sequence::~Control_Sequence ( ) delete _output; _output = NULL; - - log_destroy(); } void diff --git a/Timeline/Engine/Disk_Stream.C b/Timeline/Engine/Disk_Stream.C index dd6a2eb..c0c3e90 100644 --- a/Timeline/Engine/Disk_Stream.C +++ b/Timeline/Engine/Disk_Stream.C @@ -76,6 +76,8 @@ Disk_Stream::~Disk_Stream ( ) shutdown(); + /* FIXME: we must wait on the thread to finish here!!! */ + _track = NULL; sem_destroy( &_blocks ); @@ -136,12 +138,6 @@ Disk_Stream::shutdown ( void ) if ( _thread ) pthread_detach( _thread ); - /* we must block until the thread returns, because it might - * still have data left to process in its buffers--and we - * don't want to delete any of the datastructures it's using - * until it finishes with them. */ -// pthread_join( _thread, NULL ); - _thread = 0; } diff --git a/Timeline/Engine/Playback_DS.C b/Timeline/Engine/Playback_DS.C index 49283c8..9ab8559 100644 --- a/Timeline/Engine/Playback_DS.C +++ b/Timeline/Engine/Playback_DS.C @@ -196,8 +196,6 @@ Playback_DS::disk_thread ( void ) #ifndef AVOID_UNNECESSARY_COPYING delete[] cbuf; #endif - - _terminate = false; } /* THREAD: RT */ diff --git a/Timeline/Sequence.C b/Timeline/Sequence.C index 1c4c0e6..1acdab5 100644 --- a/Timeline/Sequence.C +++ b/Timeline/Sequence.C @@ -63,6 +63,9 @@ Sequence::init ( void ) Sequence::~Sequence ( ) { + + DMESSAGE( "destroying sequence" ); + if ( _name ) free( _name ); diff --git a/Timeline/Track.C b/Timeline/Track.C index 0614306..bb8f52c 100644 --- a/Timeline/Track.C +++ b/Timeline/Track.C @@ -247,6 +247,8 @@ Track::Track ( const char *L, int channels ) : Track::~Track ( ) { + log_destroy(); + timeline->remove_track( this ); /* give up our ports */ @@ -260,8 +262,10 @@ Track::~Track ( ) delete control_out.back(); control_out.pop_back(); } - - log_destroy(); + _sequence = NULL; + takes = NULL; + control = NULL; + annotation = NULL; if ( _name ) free( _name ); @@ -355,6 +359,9 @@ Track::add ( Audio_Sequence * t ) void Track::remove ( Audio_Sequence *t ) { + if ( ! takes ) + return; + timeline->wrlock(); takes->remove( t ); @@ -369,6 +376,9 @@ Track::remove ( Audio_Sequence *t ) void Track::remove ( Annotation_Sequence *t ) { + if ( ! annotation ) + return; + annotation->remove( t ); resize(); @@ -377,6 +387,9 @@ Track::remove ( Annotation_Sequence *t ) void Track::remove ( Control_Sequence *t ) { + if ( ! control ) + return; + engine->lock(); control->remove( t );