[Audio Output] Fix serious deadlock issue
There was a serious deadlock issue. Now it is fixed. Whew. Signed-off-by: Christopher Snowhill <kode54@gmail.com>swiftingly
parent
ab13b66755
commit
36c82a61e7
|
@ -62,6 +62,7 @@
|
||||||
[self waitUntilCallbacksExit];
|
[self waitUntilCallbacksExit];
|
||||||
if(output) {
|
if(output) {
|
||||||
[output setShouldContinue:NO];
|
[output setShouldContinue:NO];
|
||||||
|
[output close];
|
||||||
}
|
}
|
||||||
if(!output) {
|
if(!output) {
|
||||||
output = [[OutputNode alloc] initWithController:self previous:nil];
|
output = [[OutputNode alloc] initWithController:self previous:nil];
|
||||||
|
@ -136,6 +137,7 @@
|
||||||
}
|
}
|
||||||
if(output) {
|
if(output) {
|
||||||
[output setShouldContinue:NO];
|
[output setShouldContinue:NO];
|
||||||
|
[output close];
|
||||||
}
|
}
|
||||||
output = nil;
|
output = nil;
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,10 +156,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setShouldContinue:(BOOL)s {
|
- (void)setShouldContinue:(BOOL)s {
|
||||||
if(output && !s) {
|
|
||||||
[output stop];
|
|
||||||
}
|
|
||||||
|
|
||||||
[super setShouldContinue:s];
|
[super setShouldContinue:s];
|
||||||
|
|
||||||
// if (s == NO)
|
// if (s == NO)
|
||||||
|
|
|
@ -301,7 +301,9 @@ current_device_listener(AudioObjectID inObjectID, UInt32 inNumberAddresses, cons
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)signalEndOfStream:(double)latency {
|
- (BOOL)signalEndOfStream:(double)latency {
|
||||||
|
stopped = YES;
|
||||||
BOOL ret = [outputController selectNextBuffer];
|
BOOL ret = [outputController selectNextBuffer];
|
||||||
|
stopped = ret;
|
||||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(NSEC_PER_SEC * latency)), dispatch_get_main_queue(), ^{
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(NSEC_PER_SEC * latency)), dispatch_get_main_queue(), ^{
|
||||||
[self->outputController endOfInputPlayed];
|
[self->outputController endOfInputPlayed];
|
||||||
[self->outputController resetAmountPlayed];
|
[self->outputController resetAmountPlayed];
|
||||||
|
@ -1009,9 +1011,7 @@ current_device_listener(AudioObjectID inObjectID, UInt32 inNumberAddresses, cons
|
||||||
|
|
||||||
- (void)doStop {
|
- (void)doStop {
|
||||||
if(stopInvoked) {
|
if(stopInvoked) {
|
||||||
while(!stopCompleted) {
|
stopFlush = NO;
|
||||||
usleep(5000);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@synchronized(self) {
|
@synchronized(self) {
|
||||||
|
@ -1060,7 +1060,7 @@ current_device_listener(AudioObjectID inObjectID, UInt32 inNumberAddresses, cons
|
||||||
compareVal = CMTimeCompare(outputPts, currentPts);
|
compareVal = CMTimeCompare(outputPts, currentPts);
|
||||||
[currentPtsLock unlock];
|
[currentPtsLock unlock];
|
||||||
usleep(5000);
|
usleep(5000);
|
||||||
} while(compareVal > 0);
|
} while(stopFlush && compareVal > 0);
|
||||||
}
|
}
|
||||||
[self removeSynchronizerBlock];
|
[self removeSynchronizerBlock];
|
||||||
[renderSynchronizer setRate:0];
|
[renderSynchronizer setRate:0];
|
||||||
|
|
Loading…
Reference in New Issue