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