Core Audio output: Hopefully stop buffer looping on device stop
parent
6011982a63
commit
502e52d699
|
@ -176,4 +176,5 @@
|
|||
{
|
||||
[output sustainHDCD];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
BOOL stopped;
|
||||
BOOL started;
|
||||
BOOL paused;
|
||||
BOOL stopNext;
|
||||
|
||||
BOOL eqEnabled;
|
||||
|
||||
|
|
|
@ -160,6 +160,7 @@ static OSStatus renderCallback( void *inRefCon, AudioUnitRenderActionFlags *ioAc
|
|||
listenerapplied = NO;
|
||||
running = NO;
|
||||
started = NO;
|
||||
stopNext = NO;
|
||||
|
||||
atomic_init(&bytesRendered, 0);
|
||||
atomic_init(&bytesHdcdSustained, 0);
|
||||
|
@ -210,6 +211,7 @@ default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const
|
|||
{
|
||||
running = YES;
|
||||
started = NO;
|
||||
stopNext = NO;
|
||||
size_t eventCount = 0;
|
||||
atomic_store(&bytesRendered, 0);
|
||||
NSMutableArray *delayedEvents = [[NSMutableArray alloc] init];
|
||||
|
@ -277,6 +279,10 @@ default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const
|
|||
else
|
||||
bytesBuffered -= CHUNK_SIZE;
|
||||
}
|
||||
else {
|
||||
stopNext = YES;
|
||||
break;
|
||||
}
|
||||
[delayedEvents addObject:[NSNumber numberWithLong:bytesBuffered]];
|
||||
delayedEventsPopped = NO;
|
||||
if (!started) {
|
||||
|
@ -554,6 +560,7 @@ default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const
|
|||
stopping = NO;
|
||||
stopped = NO;
|
||||
paused = NO;
|
||||
stopNext = NO;
|
||||
outputDeviceID = -1;
|
||||
|
||||
AudioComponentDescription desc;
|
||||
|
@ -722,6 +729,14 @@ default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const
|
|||
|
||||
- (void)stop
|
||||
{
|
||||
if (stopNext && started && !paused) {
|
||||
while (![[outputController buffer] isEmpty])
|
||||
usleep(500);
|
||||
}
|
||||
if (stopNext) {
|
||||
stopNext = NO;
|
||||
[self signalEndOfStream];
|
||||
}
|
||||
stopInvoked = YES;
|
||||
stopping = YES;
|
||||
paused = NO;
|
||||
|
|
Loading…
Reference in New Issue