[Audio Output] Make toggling DSPs safe
The DSPs should not be deinitialized from another thread, possibly while they are currently processing. Signed-off-by: Christopher Snowhill <kode54@gmail.com>main
parent
dd58a540a8
commit
d417d245f4
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
@ -899,6 +902,8 @@ current_device_listener(AudioObjectID inObjectID, UInt32 inNumberAddresses, cons
|
|||
|
||||
audioFormatDescription = NULL;
|
||||
|
||||
resetStreamFormat = NO;
|
||||
|
||||
running = NO;
|
||||
stopping = NO;
|
||||
stopped = NO;
|
||||
|
|
Loading…
Reference in New Issue