Fix order of disk stream thread destruction.
This commit is contained in:
parent
54f0fd2fd9
commit
dc7d769cf7
|
@ -201,7 +201,7 @@ Audio_Region::write ( nframes_t nframes )
|
|||
++W;
|
||||
Fl::lock();
|
||||
sequence()->damage( FL_DAMAGE_ALL, x() + w() - W, y(), W, h() );
|
||||
Fl::awake();
|
||||
// Fl::awake();
|
||||
Fl::unlock();
|
||||
}
|
||||
}
|
||||
|
@ -215,6 +215,8 @@ Audio_Region::write ( nframes_t nframes )
|
|||
bool
|
||||
Audio_Region::finalize ( nframes_t frame )
|
||||
{
|
||||
DMESSAGE( "finalizing capture region" );
|
||||
|
||||
_range.length = frame - _range.start;
|
||||
|
||||
log_end();
|
||||
|
|
|
@ -76,9 +76,7 @@ Disk_Stream::~Disk_Stream ( )
|
|||
|
||||
shutdown();
|
||||
|
||||
/* FIXME: we must wait on the thread to finish here!!! */
|
||||
|
||||
_track = NULL;
|
||||
_track = NULL;
|
||||
|
||||
sem_destroy( &_blocks );
|
||||
|
||||
|
@ -126,6 +124,17 @@ Disk_Stream::base_flush ( bool is_output )
|
|||
|
||||
}
|
||||
|
||||
/** signal thread to terminate, then detach it */
|
||||
void
|
||||
Disk_Stream::detach ( void )
|
||||
{
|
||||
_terminate = true;
|
||||
|
||||
block_processed();
|
||||
|
||||
pthread_detach( _thread );
|
||||
}
|
||||
|
||||
/** stop the IO thread. */
|
||||
void
|
||||
Disk_Stream::shutdown ( void )
|
||||
|
@ -136,9 +145,7 @@ Disk_Stream::shutdown ( void )
|
|||
block_processed();
|
||||
|
||||
if ( _thread )
|
||||
pthread_detach( _thread );
|
||||
|
||||
_thread = 0;
|
||||
pthread_join( _thread, NULL );
|
||||
}
|
||||
|
||||
Track *
|
||||
|
@ -157,6 +164,8 @@ Disk_Stream::sequence ( void ) const
|
|||
void
|
||||
Disk_Stream::run ( void )
|
||||
{
|
||||
ASSERT( ! _thread, "Thread is already running" );
|
||||
|
||||
if ( pthread_create( &_thread, NULL, &Disk_Stream::disk_thread, this ) != 0 )
|
||||
FATAL( "Could not create IO thread!" );
|
||||
}
|
||||
|
|
|
@ -81,10 +81,7 @@ protected:
|
|||
{
|
||||
while ( ! sem_wait( &_blocks ) && errno == EINTR );
|
||||
|
||||
if ( _terminate )
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
return ! _terminate;
|
||||
}
|
||||
|
||||
virtual void disk_thread ( void ) = 0;
|
||||
|
@ -92,6 +89,10 @@ protected:
|
|||
void base_flush ( bool is_output );
|
||||
virtual void flush ( void ) = 0;
|
||||
|
||||
void run ( void );
|
||||
void shutdown ( void );
|
||||
void detach ( void );
|
||||
|
||||
public:
|
||||
|
||||
/* must be set before any Disk_Streams are created */
|
||||
|
@ -109,9 +110,6 @@ public:
|
|||
/* void seek ( nframes_t frame ); */
|
||||
/* bool seek_pending ( void ); */
|
||||
|
||||
void run ( void );
|
||||
void shutdown ( void );
|
||||
|
||||
virtual nframes_t process ( nframes_t nframes ) = 0;
|
||||
|
||||
int buffer_percent ( void );
|
||||
|
|
|
@ -196,6 +196,9 @@ Playback_DS::disk_thread ( void )
|
|||
#ifndef AVOID_UNNECESSARY_COPYING
|
||||
delete[] cbuf;
|
||||
#endif
|
||||
|
||||
_terminate = false;
|
||||
_thread = 0;
|
||||
}
|
||||
|
||||
/* THREAD: RT */
|
||||
|
|
|
@ -191,13 +191,17 @@ Record_DS::disk_thread ( void )
|
|||
delete[] cbuf;
|
||||
#endif
|
||||
|
||||
DMESSAGE( "finalzing capture" );
|
||||
|
||||
/* now finalize the recording */
|
||||
track()->finalize( _capture, _stop_frame );
|
||||
|
||||
delete _capture;
|
||||
_capture = NULL;
|
||||
|
||||
_thread = 0;
|
||||
_terminate = false;
|
||||
DMESSAGE( "capture thread gone" );
|
||||
}
|
||||
|
||||
|
||||
|
@ -241,7 +245,7 @@ Record_DS::stop ( nframes_t frame )
|
|||
|
||||
_stop_frame = frame;
|
||||
|
||||
shutdown();
|
||||
detach();
|
||||
|
||||
DMESSAGE( "recording finished" );
|
||||
}
|
||||
|
|
|
@ -68,7 +68,6 @@ Track::configure_outputs ( int n )
|
|||
Playback_DS *ds = playback_ds;
|
||||
playback_ds = NULL;
|
||||
|
||||
ds->shutdown();
|
||||
delete ds;
|
||||
}
|
||||
|
||||
|
@ -116,7 +115,6 @@ Track::configure_inputs ( int n )
|
|||
Record_DS *ds = record_ds;
|
||||
record_ds = NULL;
|
||||
|
||||
ds->shutdown();
|
||||
delete ds;
|
||||
}
|
||||
|
||||
|
@ -250,6 +248,7 @@ void
|
|||
Track::finalize ( Capture *c, nframes_t frame )
|
||||
{
|
||||
c->region->finalize( frame );
|
||||
DMESSAGE( "finalizing audio file" );
|
||||
c->audio_file->finalize();
|
||||
|
||||
delete c->audio_file;
|
||||
|
|
Loading…
Reference in New Issue