Equalizer: Instances of GraphicEQ AU are now relinquished to the main thread for destruction instead of being destroyed by the Core Audio Output shutdown

CQTexperiment
Christopher Snowhill 2022-01-24 19:49:43 -08:00
parent d8b16e44c7
commit ec7009f3fc
2 changed files with 9 additions and 14 deletions

View File

@ -576,7 +576,7 @@ NSDictionary * makeRGInfo(PlaylistEntry *pe)
[[NSUserDefaults standardUserDefaults] setDouble:[audioPlayer volume] forKey:@"volume"]; [[NSUserDefaults standardUserDefaults] setDouble:[audioPlayer volume] forKey:@"volume"];
} }
- (void)showStubEq - (void)eqAlloc
{ {
// Show a stopped equalizer as a stub // Show a stopped equalizer as a stub
OSStatus err; OSStatus err;
@ -602,15 +602,13 @@ NSDictionary * makeRGInfo(PlaylistEntry *pe)
return; return;
AudioUnitInitialize(_eq); AudioUnitInitialize(_eq);
_eqStubbed = YES;
} }
- (void)hideStubEq - (void)eqDealloc
{ {
AudioUnitUninitialize(_eq); AudioUnitUninitialize(_eq);
AudioComponentInstanceDispose(_eq); AudioComponentInstanceDispose(_eq);
_eq = NULL; _eq = nil;
_eqStubbed = NO; _eqStubbed = NO;
} }
@ -625,7 +623,7 @@ NSDictionary * makeRGInfo(PlaylistEntry *pe)
} }
else else
{ {
[self showStubEq]; [self eqAlloc];
_eqWasOpen = YES; _eqWasOpen = YES;
[self audioPlayer:nil displayEqualizer:_eq]; [self audioPlayer:nil displayEqualizer:_eq];
[_equi bringToFront]; [_equi bringToFront];
@ -655,10 +653,8 @@ NSDictionary * makeRGInfo(PlaylistEntry *pe)
CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication); CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
if (_eqStubbed) // Caller relinquishes EQ to us
{ [self eqDealloc];
[self hideStubEq];
}
} }
_eq = eq; _eq = eq;
@ -730,7 +726,7 @@ NSDictionary * makeRGInfo(PlaylistEntry *pe)
} }
_equi = nil; _equi = nil;
_eq = nil; [self eqDealloc];
if (_eqWasOpen) if (_eqWasOpen)
{ {

View File

@ -767,9 +767,8 @@ default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const
} }
if (_eq) if (_eq)
{ {
// This takes the EQ and frees it after disposing of any present UIs
[outputController endEqualizer:_eq]; [outputController endEqualizer:_eq];
AudioUnitUninitialize(_eq);
AudioComponentInstanceDispose(_eq);
_eq = NULL; _eq = NULL;
} }
#ifdef OUTPUT_LOG #ifdef OUTPUT_LOG