[Core Audio] Conditionally uninitialize equalizer
Only uninitialize the equalizer if sound output was successfully started and the equalizer AudioUnit was successfully ininitialized. Signed-off-by: Christopher Snowhill <kode54@gmail.com>swiftingly
parent
d390febe72
commit
10f0644407
|
@ -51,6 +51,7 @@ using std::atomic_long;
|
|||
BOOL restarted;
|
||||
|
||||
BOOL eqEnabled;
|
||||
BOOL eqInitialized;
|
||||
|
||||
BOOL streamFormatStarted;
|
||||
|
||||
|
|
|
@ -764,6 +764,8 @@ default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const
|
|||
if(_err)
|
||||
return NO;
|
||||
|
||||
eqInitialized = YES;
|
||||
|
||||
[self setEqualizerEnabled:[[[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"GraphicEQenable"] boolValue]];
|
||||
|
||||
[outputController beginEqualizer:_eq];
|
||||
|
@ -851,7 +853,10 @@ default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const
|
|||
}
|
||||
if(_eq) {
|
||||
[outputController endEqualizer:_eq];
|
||||
AudioUnitUninitialize(_eq);
|
||||
if(eqInitialized) {
|
||||
AudioUnitUninitialize(_eq);
|
||||
eqInitialized = NO;
|
||||
}
|
||||
AudioComponentInstanceDispose(_eq);
|
||||
_eq = NULL;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue