Audio Player: Only wait for unstopped input
Input thread now signals when it has stopped and is about to return, in case the input thread returns before the BufferChain dealloc function would be waiting for it to terminate. Somehow, even though the Semaphore is being signaled at this point, the BufferChain still ends up waiting the default of 2.5 seconds for the signal that apparently never comes, delaying file stoppage. This prevents the wait action entirely. Must have been some sort of race condition. Signed-off-by: Christopher Snowhill <kode54@gmail.com>xcode15
parent
6daa0de425
commit
72ee38ad14
|
@ -156,7 +156,8 @@
|
||||||
[inputNode setShouldContinue:NO];
|
[inputNode setShouldContinue:NO];
|
||||||
[[inputNode exitAtTheEndOfTheStream] signal];
|
[[inputNode exitAtTheEndOfTheStream] signal];
|
||||||
[[inputNode semaphore] 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");
|
DLog(@"Bufferchain dealloc");
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
Semaphore *exitAtTheEndOfTheStream;
|
Semaphore *exitAtTheEndOfTheStream;
|
||||||
}
|
}
|
||||||
@property(readonly) Semaphore *exitAtTheEndOfTheStream;
|
@property(readonly) Semaphore *exitAtTheEndOfTheStream;
|
||||||
|
@property(readonly) BOOL threadExited;
|
||||||
|
|
||||||
- (BOOL)openWithSource:(id<CogSource>)source;
|
- (BOOL)openWithSource:(id<CogSource>)source;
|
||||||
- (BOOL)openWithDecoder:(id<CogDecoder>)d;
|
- (BOOL)openWithDecoder:(id<CogDecoder>)d;
|
||||||
|
|
|
@ -21,12 +21,14 @@
|
||||||
|
|
||||||
static void *kInputNodeContext = &kInputNodeContext;
|
static void *kInputNodeContext = &kInputNodeContext;
|
||||||
|
|
||||||
|
@synthesize threadExited;
|
||||||
@synthesize exitAtTheEndOfTheStream;
|
@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];
|
||||||
if(self) {
|
if(self) {
|
||||||
exitAtTheEndOfTheStream = [[Semaphore alloc] init];
|
exitAtTheEndOfTheStream = [[Semaphore alloc] init];
|
||||||
|
threadExited = NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
@ -223,6 +225,7 @@ static void *kInputNodeContext = &kInputNodeContext;
|
||||||
[decoder close];
|
[decoder close];
|
||||||
|
|
||||||
[exitAtTheEndOfTheStream signal];
|
[exitAtTheEndOfTheStream signal];
|
||||||
|
threadExited = YES;
|
||||||
|
|
||||||
DLog("Input node thread stopping");
|
DLog("Input node thread stopping");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue