diff --git a/Audio/Chain/BufferChain.m b/Audio/Chain/BufferChain.m index a4e1fae38..1ff7a08c8 100644 --- a/Audio/Chain/BufferChain.m +++ b/Audio/Chain/BufferChain.m @@ -156,7 +156,8 @@ [inputNode setShouldContinue:NO]; [[inputNode exitAtTheEndOfTheStream] signal]; [[inputNode semaphore] signal]; - [[inputNode exitAtTheEndOfTheStream] wait]; // wait for decoder to be closed (see InputNode's -(void)process ) + if(![inputNode threadExited]) + [[inputNode exitAtTheEndOfTheStream] wait]; // wait for decoder to be closed (see InputNode's -(void)process ) DLog(@"Bufferchain dealloc"); } diff --git a/Audio/Chain/InputNode.h b/Audio/Chain/InputNode.h index 5a33ae47c..02c7a69c9 100644 --- a/Audio/Chain/InputNode.h +++ b/Audio/Chain/InputNode.h @@ -34,6 +34,7 @@ Semaphore *exitAtTheEndOfTheStream; } @property(readonly) Semaphore *exitAtTheEndOfTheStream; +@property(readonly) BOOL threadExited; - (BOOL)openWithSource:(id)source; - (BOOL)openWithDecoder:(id)d; diff --git a/Audio/Chain/InputNode.m b/Audio/Chain/InputNode.m index a071fa34a..98fa02c5d 100644 --- a/Audio/Chain/InputNode.m +++ b/Audio/Chain/InputNode.m @@ -21,12 +21,14 @@ static void *kInputNodeContext = &kInputNodeContext; +@synthesize threadExited; @synthesize exitAtTheEndOfTheStream; - (id)initWithController:(id)c previous:(id)p { self = [super initWithController:c previous:p]; if(self) { exitAtTheEndOfTheStream = [[Semaphore alloc] init]; + threadExited = NO; } return self; @@ -223,6 +225,7 @@ static void *kInputNodeContext = &kInputNodeContext; [decoder close]; [exitAtTheEndOfTheStream signal]; + threadExited = YES; DLog("Input node thread stopping"); }