[Audio Output] Properly handle end of playlist
Handle audio on the end of the playlist, flushing playback until all output stops. Signed-off-by: Christopher Snowhill <kode54@gmail.com>lastfm
parent
858f446597
commit
0cc084b58b
|
@ -317,6 +317,7 @@ current_device_listener(AudioObjectID inObjectID, UInt32 inNumberAddresses, cons
|
||||||
- (BOOL)processEndOfStream {
|
- (BOOL)processEndOfStream {
|
||||||
if([outputController endOfStream] == YES && [self signalEndOfStream:secondsLatency]) {
|
if([outputController endOfStream] == YES && [self signalEndOfStream:secondsLatency]) {
|
||||||
stopping = YES;
|
stopping = YES;
|
||||||
|
stopFlush = YES;
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
return NO;
|
return NO;
|
||||||
|
@ -326,6 +327,7 @@ current_device_listener(AudioObjectID inObjectID, UInt32 inNumberAddresses, cons
|
||||||
running = YES;
|
running = YES;
|
||||||
started = NO;
|
started = NO;
|
||||||
secondsLatency = 1.0;
|
secondsLatency = 1.0;
|
||||||
|
stopFlush = NO;
|
||||||
|
|
||||||
while(!stopping) {
|
while(!stopping) {
|
||||||
if([outputController shouldReset]) {
|
if([outputController shouldReset]) {
|
||||||
|
@ -358,8 +360,8 @@ current_device_listener(AudioObjectID inObjectID, UInt32 inNumberAddresses, cons
|
||||||
|
|
||||||
[audioRenderer enqueueSampleBuffer:bufferRef];
|
[audioRenderer enqueueSampleBuffer:bufferRef];
|
||||||
} else {
|
} else {
|
||||||
|
stopFlush = YES;
|
||||||
break;
|
break;
|
||||||
// r8b will absorb some samples first
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,7 +377,9 @@ current_device_listener(AudioObjectID inObjectID, UInt32 inNumberAddresses, cons
|
||||||
}
|
}
|
||||||
|
|
||||||
stopped = YES;
|
stopped = YES;
|
||||||
[self stop];
|
if(!stopInvoked) {
|
||||||
|
[self stop];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (OSStatus)setOutputDeviceByID:(AudioDeviceID)deviceID {
|
- (OSStatus)setOutputDeviceByID:(AudioDeviceID)deviceID {
|
||||||
|
@ -1033,7 +1037,17 @@ current_device_listener(AudioObjectID inObjectID, UInt32 inNumberAddresses, cons
|
||||||
}
|
}
|
||||||
if(renderSynchronizer || audioRenderer) {
|
if(renderSynchronizer || audioRenderer) {
|
||||||
if(renderSynchronizer) {
|
if(renderSynchronizer) {
|
||||||
|
if(stopFlush) {
|
||||||
|
int compareVal = 0;
|
||||||
|
do {
|
||||||
|
[currentPtsLock lock];
|
||||||
|
compareVal = CMTimeCompare(outputPts, currentPts);
|
||||||
|
[currentPtsLock unlock];
|
||||||
|
usleep(5000);
|
||||||
|
} while(compareVal > 0);
|
||||||
|
}
|
||||||
[self removeSynchronizerBlock];
|
[self removeSynchronizerBlock];
|
||||||
|
[renderSynchronizer setRate:0];
|
||||||
}
|
}
|
||||||
if(audioRenderer) {
|
if(audioRenderer) {
|
||||||
[audioRenderer stopRequestingMediaData];
|
[audioRenderer stopRequestingMediaData];
|
||||||
|
|
Loading…
Reference in New Issue