From 1b818bcaa750b0e6703960a4b54d121fc3748b14 Mon Sep 17 00:00:00 2001 From: Chris Moeller Date: Sat, 12 Oct 2013 13:59:34 -0700 Subject: [PATCH] mamburu: Fixed InputNode's thread not being stopped at all --- Audio/AudioPlayer.m | 6 ++---- Audio/Chain/BufferChain.m | 4 ++++ Audio/Chain/InputNode.h | 1 + Audio/Chain/InputNode.m | 13 +++++++------ 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Audio/AudioPlayer.m b/Audio/AudioPlayer.m index 433936c8b..2db18f7ae 100644 --- a/Audio/AudioPlayer.m +++ b/Audio/AudioPlayer.m @@ -57,7 +57,6 @@ output = [[OutputNode alloc] initWithController:self previous:nil]; [output setup]; [output setVolume: volume]; - @synchronized(chainQueue) { for (id anObject in chainQueue) { @@ -65,7 +64,6 @@ } [chainQueue removeAllObjects]; endOfInputReached = NO; - if (bufferChain) { [bufferChain setShouldContinue:NO]; @@ -73,7 +71,7 @@ [bufferChain release]; } } - + bufferChain = [[BufferChain alloc] initWithController:self]; [self notifyStreamChanged:userInfo]; @@ -97,7 +95,7 @@ bufferChain = [[BufferChain alloc] initWithController:self]; } - + [bufferChain setUserInfo:userInfo]; [self setShouldContinue:YES]; diff --git a/Audio/Chain/BufferChain.m b/Audio/Chain/BufferChain.m index 0f2b3e002..2c55011ad 100644 --- a/Audio/Chain/BufferChain.m +++ b/Audio/Chain/BufferChain.m @@ -122,6 +122,10 @@ - (void)dealloc { + [[inputNode exitAtTheEndOfTheStream] signal]; + [[inputNode semaphore] signal]; + [[inputNode exitAtTheEndOfTheStream] wait]; // wait for decoder to be closed (see InputNode's -(void)process ) + [rgInfo release]; [userInfo release]; [streamURL release]; diff --git a/Audio/Chain/InputNode.h b/Audio/Chain/InputNode.h index c0b440faa..d54d7fe42 100644 --- a/Audio/Chain/InputNode.h +++ b/Audio/Chain/InputNode.h @@ -31,6 +31,7 @@ Semaphore *exitAtTheEndOfTheStream; } +@property(readonly) Semaphore *exitAtTheEndOfTheStream; - (BOOL)openWithSource:(id)source; - (BOOL)openWithDecoder:(id) d; diff --git a/Audio/Chain/InputNode.m b/Audio/Chain/InputNode.m index 08d1362e4..f6eeba767 100644 --- a/Audio/Chain/InputNode.m +++ b/Audio/Chain/InputNode.m @@ -15,6 +15,8 @@ #import "Logging.h" @implementation InputNode +@synthesize exitAtTheEndOfTheStream; + - (id)initWithController:(id)c previous:(id)p { self = [super initWithController:c previous:p]; @@ -174,6 +176,8 @@ free(inputBuffer); [exitAtTheEndOfTheStream signal]; + + DLog("Input node thread stopping"); } - (void)seek:(long)frame @@ -203,16 +207,13 @@ - (void)dealloc { DLog(@"Input Node dealloc"); - [exitAtTheEndOfTheStream signal]; - [exitAtTheEndOfTheStream wait]; // wait for decoder to be closed (see -(void)process ) - [exitAtTheEndOfTheStream release]; - [decoder removeObserver:self forKeyPath:@"properties"]; [decoder removeObserver:self forKeyPath:@"metadata"]; [decoder release]; - - [super dealloc]; + + [exitAtTheEndOfTheStream release]; + [super dealloc]; } - (NSDictionary *) properties