From 60059f40054db40a77754670cdae2e9517df3568 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Sun, 15 Feb 2015 15:47:55 -0800 Subject: [PATCH] Timeline: Fix assertion triggered by failure to join a diskthread which self-terminated due to punch-out. --- nonlib/Thread.C | 6 +++++- timeline/src/Engine/Disk_Stream.C | 9 +++++++-- timeline/src/Engine/Playback_DS.C | 2 -- timeline/src/Engine/Record_DS.C | 15 +-------------- 4 files changed, 13 insertions(+), 19 deletions(-) diff --git a/nonlib/Thread.C b/nonlib/Thread.C index de30601..6f2227b 100644 --- a/nonlib/Thread.C +++ b/nonlib/Thread.C @@ -88,7 +88,11 @@ Thread::run_thread ( void *arg ) ((Thread*)td.t)->_running = true; - return td.entry_point( td.arg ); + void * r = td.entry_point( td.arg ); + + ((Thread*)td.t)->_running = false; + + return r; } diff --git a/timeline/src/Engine/Disk_Stream.C b/timeline/src/Engine/Disk_Stream.C index 6843178..7268e67 100644 --- a/timeline/src/Engine/Disk_Stream.C +++ b/timeline/src/Engine/Disk_Stream.C @@ -137,9 +137,14 @@ Disk_Stream::shutdown ( void ) block_processed(); usleep( 10 * 1000 ); } - - _thread.join(); } + + /* thread may have terminated on it's own (due to punch out..), in + * any case join to clean up */ + _thread.join(); + + DMESSAGE( "diskthread joined." ); + } Track * diff --git a/timeline/src/Engine/Playback_DS.C b/timeline/src/Engine/Playback_DS.C index 93b1b0f..e5cf15d 100644 --- a/timeline/src/Engine/Playback_DS.C +++ b/timeline/src/Engine/Playback_DS.C @@ -181,8 +181,6 @@ done: // flush(); _terminate = false; - - _thread.exit(); } /** take a single block from the ringbuffers and send it out the diff --git a/timeline/src/Engine/Record_DS.C b/timeline/src/Engine/Record_DS.C index c8735c5..e24b0a3 100644 --- a/timeline/src/Engine/Record_DS.C +++ b/timeline/src/Engine/Record_DS.C @@ -247,8 +247,6 @@ again: _recording = false; DMESSAGE( "capture thread gone" ); - - _thread.exit(); } @@ -283,20 +281,9 @@ Record_DS::stop ( nframes_t frame ) { THREAD_ASSERT( UI ); - if ( ! _recording ) - { - WARNING( "programming error: attempt to stop recording when no recording is being made" ); - return; - } - _stop_frame = frame; - - // _recording = false; - -// detach(); - - DMESSAGE( "recording finished" ); + DMESSAGE( "recording stop scheduled" ); }