diff --git a/Audio/Output/OutputAVFoundation.h b/Audio/Output/OutputAVFoundation.h index bbf9c64d4..3728b36a5 100644 --- a/Audio/Output/OutputAVFoundation.h +++ b/Audio/Output/OutputAVFoundation.h @@ -113,6 +113,8 @@ using std::atomic_long; BOOL enableFSurround; FSurroundFilter *fsurround; + BOOL resetStreamFormat; + float *samplePtr; float tempBuffer[512 * 32]; float inputBuffer[4096 * 32]; // 4096 samples times maximum supported channel count diff --git a/Audio/Output/OutputAVFoundation.m b/Audio/Output/OutputAVFoundation.m index be61cbf64..5e4150c1b 100644 --- a/Audio/Output/OutputAVFoundation.m +++ b/Audio/Output/OutputAVFoundation.m @@ -304,12 +304,10 @@ current_device_listener(AudioObjectID inObjectID, UInt32 inNumberAddresses, cons eqPreamp = pow(10.0, preamp / 20.0); } else if([keyPath isEqualToString:@"values.enableHrtf"]) { enableHrtf = [[[NSUserDefaultsController sharedUserDefaultsController] defaults] boolForKey:@"enableHrtf"]; - if(streamFormatStarted) - [self updateStreamFormat]; + resetStreamFormat = YES; } else if([keyPath isEqualToString:@"values.enableFSurround"]) { enableFSurround = [[[NSUserDefaultsController sharedUserDefaultsController] defaults] boolForKey:@"enableFSurround"]; - if(streamFormatStarted) - [self updateStreamFormat]; + resetStreamFormat = YES; } } @@ -606,6 +604,7 @@ current_device_listener(AudioObjectID inObjectID, UInt32 inNumberAddresses, cons - (void)updateStreamFormat { /* Set the channel layout for the audio queue */ streamFormatChanged = YES; + resetStreamFormat = NO; uint32_t channels = realStreamFormat.mChannelsPerFrame; uint32_t channelConfig = realStreamChannelConfig; @@ -746,6 +745,10 @@ current_device_listener(AudioObjectID inObjectID, UInt32 inNumberAddresses, cons status = CMBlockBufferCreateEmpty(kCFAllocatorDefault, 0, 0, &blockListBuffer); if(status != noErr || !blockListBuffer) return 0; + if(resetStreamFormat) { + [self updateStreamFormat]; + } + int inputRendered = 0; int bytesRendered = 0; do { @@ -898,7 +901,9 @@ current_device_listener(AudioObjectID inObjectID, UInt32 inNumberAddresses, cons commandStop = NO; audioFormatDescription = NULL; - + + resetStreamFormat = NO; + running = NO; stopping = NO; stopped = NO;