[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 restarted;
|
||||||
|
|
||||||
BOOL eqEnabled;
|
BOOL eqEnabled;
|
||||||
|
BOOL eqInitialized;
|
||||||
|
|
||||||
BOOL streamFormatStarted;
|
BOOL streamFormatStarted;
|
||||||
|
|
||||||
|
|
|
@ -764,6 +764,8 @@ default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const
|
||||||
if(_err)
|
if(_err)
|
||||||
return NO;
|
return NO;
|
||||||
|
|
||||||
|
eqInitialized = YES;
|
||||||
|
|
||||||
[self setEqualizerEnabled:[[[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"GraphicEQenable"] boolValue]];
|
[self setEqualizerEnabled:[[[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"GraphicEQenable"] boolValue]];
|
||||||
|
|
||||||
[outputController beginEqualizer:_eq];
|
[outputController beginEqualizer:_eq];
|
||||||
|
@ -851,7 +853,10 @@ default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const
|
||||||
}
|
}
|
||||||
if(_eq) {
|
if(_eq) {
|
||||||
[outputController endEqualizer:_eq];
|
[outputController endEqualizer:_eq];
|
||||||
AudioUnitUninitialize(_eq);
|
if(eqInitialized) {
|
||||||
|
AudioUnitUninitialize(_eq);
|
||||||
|
eqInitialized = NO;
|
||||||
|
}
|
||||||
AudioComponentInstanceDispose(_eq);
|
AudioComponentInstanceDispose(_eq);
|
||||||
_eq = NULL;
|
_eq = NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue