From 232d23915a39e2c95ad3995e73c25945fdb81e94 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Thu, 22 May 2008 18:12:51 -0500 Subject: [PATCH] Mipmap peak building actually happens in the UI thread, not the IO thread. Therefore, it is always necessary to fork when mipmapping peaks after capture. --- Timeline/Engine/Audio_Region.C | 1 - Timeline/Engine/Disk_Stream.C | 1 + Timeline/Engine/Peaks.C | 8 +++----- Timeline/Engine/Record_DS.C | 12 ++---------- 4 files changed, 6 insertions(+), 16 deletions(-) diff --git a/Timeline/Engine/Audio_Region.C b/Timeline/Engine/Audio_Region.C index 614c7ad..94a19b0 100644 --- a/Timeline/Engine/Audio_Region.C +++ b/Timeline/Engine/Audio_Region.C @@ -209,7 +209,6 @@ Audio_Region::write ( nframes_t nframes ) return nframes; } -/* THREAD: IO */ /** finalize region capture. Assumes that this *is* a captured region and that no other regions refer to the same source */ bool diff --git a/Timeline/Engine/Disk_Stream.C b/Timeline/Engine/Disk_Stream.C index 64d10c3..0d7e8ef 100644 --- a/Timeline/Engine/Disk_Stream.C +++ b/Timeline/Engine/Disk_Stream.C @@ -135,6 +135,7 @@ Disk_Stream::shutdown ( void ) pthread_join( _thread, NULL ); _thread = 0; + _terminate = false; } diff --git a/Timeline/Engine/Peaks.C b/Timeline/Engine/Peaks.C index f1c679b..2720b0f 100644 --- a/Timeline/Engine/Peaks.C +++ b/Timeline/Engine/Peaks.C @@ -530,7 +530,6 @@ Peaks::prepare_for_writing ( void ) _peak_writer = new Peaks::Streamer( _clip->name(), _clip->channels(), cache_minimum ); } -/* THREAD: IO */ void Peaks::finish_writing ( void ) { @@ -539,10 +538,9 @@ Peaks::finish_writing ( void ) delete _peak_writer; _peak_writer = NULL; - /* now fill in the rest of the cache */ - make_peaks_mipmap(); -/* if ( ! fork() ) */ -/* exit( make_peaks_mipmap() ); */ +/* now fill in the rest of the cache */ + if ( ! fork() ) + exit( make_peaks_mipmap() ); } diff --git a/Timeline/Engine/Record_DS.C b/Timeline/Engine/Record_DS.C index 57b83a1..8814e7d 100644 --- a/Timeline/Engine/Record_DS.C +++ b/Timeline/Engine/Record_DS.C @@ -145,12 +145,11 @@ Record_DS::disk_thread ( void ) const nframes_t nframes = _nframes; const size_t block_size = _nframes * sizeof( sample_t ); - #ifdef AVOID_UNNECESSARY_COPYING sample_t *cbuf = new sample_t[ nframes ]; #endif - while ( blocks_ready-- > 0 || ! sem_trywait( &_blocks ) && errno != EAGAIN ) + while ( blocks_ready-- > 0 || ( ! sem_trywait( &_blocks ) && errno != EAGAIN ) ) { for ( int i = channels(); i--; ) @@ -182,8 +181,6 @@ Record_DS::disk_thread ( void ) #ifndef AVOID_UNNECESSARY_COPYING delete[] cbuf; #endif - - _thread = NULL; } @@ -217,21 +214,16 @@ Record_DS::stop ( nframes_t frame ) { if ( ! _recording ) { - printf( "programming error: attempt to stop recording when no recording is being made\n" ); + WARNING( "programming error: attempt to stop recording when no recording is being made\n" ); return; } _recording = false; - /* FIXME: we may still have data in the buffers waiting to be - * written to disk... We should flush it out before stopping... */ - _stop_frame = frame; shutdown(); - /* FIXME: flush buffers here? */ - track()->stop( frame ); DMESSAGE( "recording finished" );