[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>
lastfm
Christopher Snowhill 2022-06-25 05:12:43 -07:00
parent cca447ca5e
commit a1a084aabb
3 changed files with 6 additions and 8 deletions

View File

@ -62,6 +62,7 @@
[self waitUntilCallbacksExit];
if(output) {
[output setShouldContinue:NO];
[output close];
}
if(!output) {
output = [[OutputNode alloc] initWithController:self previous:nil];
@ -136,6 +137,7 @@
}
if(output) {
[output setShouldContinue:NO];
[output close];
}
output = nil;
}

View File

@ -156,10 +156,6 @@
}
- (void)setShouldContinue:(BOOL)s {
if(output && !s) {
[output stop];
}
[super setShouldContinue:s];
// if (s == NO)

View File

@ -301,7 +301,9 @@ current_device_listener(AudioObjectID inObjectID, UInt32 inNumberAddresses, cons
}
- (BOOL)signalEndOfStream:(double)latency {
stopped = YES;
BOOL ret = [outputController selectNextBuffer];
stopped = ret;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(NSEC_PER_SEC * latency)), dispatch_get_main_queue(), ^{
[self->outputController endOfInputPlayed];
[self->outputController resetAmountPlayed];
@ -1009,9 +1011,7 @@ current_device_listener(AudioObjectID inObjectID, UInt32 inNumberAddresses, cons
- (void)doStop {
if(stopInvoked) {
while(!stopCompleted) {
usleep(5000);
}
stopFlush = NO;
return;
}
@synchronized(self) {
@ -1060,7 +1060,7 @@ current_device_listener(AudioObjectID inObjectID, UInt32 inNumberAddresses, cons
compareVal = CMTimeCompare(outputPts, currentPts);
[currentPtsLock unlock];
usleep(5000);
} while(compareVal > 0);
} while(stopFlush && compareVal > 0);
}
[self removeSynchronizerBlock];
[renderSynchronizer setRate:0];