mamburu: Fixed InputNode's thread not being stopped at all

CQTexperiment
Chris Moeller 2013-10-12 13:59:34 -07:00
parent 56848daad6
commit 1b818bcaa7
4 changed files with 14 additions and 10 deletions

View File

@ -57,7 +57,6 @@
output = [[OutputNode alloc] initWithController:self previous:nil]; output = [[OutputNode alloc] initWithController:self previous:nil];
[output setup]; [output setup];
[output setVolume: volume]; [output setVolume: volume];
@synchronized(chainQueue) { @synchronized(chainQueue) {
for (id anObject in chainQueue) for (id anObject in chainQueue)
{ {
@ -65,7 +64,6 @@
} }
[chainQueue removeAllObjects]; [chainQueue removeAllObjects];
endOfInputReached = NO; endOfInputReached = NO;
if (bufferChain) if (bufferChain)
{ {
[bufferChain setShouldContinue:NO]; [bufferChain setShouldContinue:NO];
@ -73,7 +71,7 @@
[bufferChain release]; [bufferChain release];
} }
} }
bufferChain = [[BufferChain alloc] initWithController:self]; bufferChain = [[BufferChain alloc] initWithController:self];
[self notifyStreamChanged:userInfo]; [self notifyStreamChanged:userInfo];
@ -97,7 +95,7 @@
bufferChain = [[BufferChain alloc] initWithController:self]; bufferChain = [[BufferChain alloc] initWithController:self];
} }
[bufferChain setUserInfo:userInfo]; [bufferChain setUserInfo:userInfo];
[self setShouldContinue:YES]; [self setShouldContinue:YES];

View File

@ -122,6 +122,10 @@
- (void)dealloc - (void)dealloc
{ {
[[inputNode exitAtTheEndOfTheStream] signal];
[[inputNode semaphore] signal];
[[inputNode exitAtTheEndOfTheStream] wait]; // wait for decoder to be closed (see InputNode's -(void)process )
[rgInfo release]; [rgInfo release];
[userInfo release]; [userInfo release];
[streamURL release]; [streamURL release];

View File

@ -31,6 +31,7 @@
Semaphore *exitAtTheEndOfTheStream; Semaphore *exitAtTheEndOfTheStream;
} }
@property(readonly) Semaphore *exitAtTheEndOfTheStream;
- (BOOL)openWithSource:(id<CogSource>)source; - (BOOL)openWithSource:(id<CogSource>)source;
- (BOOL)openWithDecoder:(id<CogDecoder>) d; - (BOOL)openWithDecoder:(id<CogDecoder>) d;

View File

@ -15,6 +15,8 @@
#import "Logging.h" #import "Logging.h"
@implementation InputNode @implementation InputNode
@synthesize exitAtTheEndOfTheStream;
- (id)initWithController:(id)c previous:(id)p { - (id)initWithController:(id)c previous:(id)p {
self = [super initWithController:c previous:p]; self = [super initWithController:c previous:p];
@ -174,6 +176,8 @@
free(inputBuffer); free(inputBuffer);
[exitAtTheEndOfTheStream signal]; [exitAtTheEndOfTheStream signal];
DLog("Input node thread stopping");
} }
- (void)seek:(long)frame - (void)seek:(long)frame
@ -203,16 +207,13 @@
- (void)dealloc - (void)dealloc
{ {
DLog(@"Input Node 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:@"properties"];
[decoder removeObserver:self forKeyPath:@"metadata"]; [decoder removeObserver:self forKeyPath:@"metadata"];
[decoder release]; [decoder release];
[super dealloc]; [exitAtTheEndOfTheStream release];
[super dealloc];
} }
- (NSDictionary *) properties - (NSDictionary *) properties