Skip to content

Commit

Permalink
Equalizer: Instances of GraphicEQ AU are now relinquished to the main…
Browse files Browse the repository at this point in the history
… thread for destruction instead of being destroyed by the Core Audio Output shutdown
  • Loading branch information
kode54 committed Jan 25, 2022
1 parent d8b16e4 commit ec7009f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
20 changes: 8 additions & 12 deletions Application/PlaybackController.m
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ - (IBAction)volumeUp:(id)sender
[[NSUserDefaults standardUserDefaults] setDouble:[audioPlayer volume] forKey:@"volume"];
}

- (void)showStubEq
- (void)eqAlloc
{
// Show a stopped equalizer as a stub
OSStatus err;
Expand All @@ -602,15 +602,13 @@ - (void)showStubEq
return;

AudioUnitInitialize(_eq);

_eqStubbed = YES;
}

- (void)hideStubEq
- (void)eqDealloc
{
AudioUnitUninitialize(_eq);
AudioComponentInstanceDispose(_eq);
_eq = NULL;
_eq = nil;
_eqStubbed = NO;
}

Expand All @@ -625,7 +623,7 @@ - (IBAction)showEq:(id)sender
}
else
{
[self showStubEq];
[self eqAlloc];
_eqWasOpen = YES;
[self audioPlayer:nil displayEqualizer:_eq];
[_equi bringToFront];
Expand Down Expand Up @@ -655,10 +653,8 @@ - (void)audioPlayer:(AudioPlayer *)player displayEqualizer:(AudioUnit)eq

CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);

if (_eqStubbed)
{
[self hideStubEq];
}
// Caller relinquishes EQ to us
[self eqDealloc];
}

_eq = eq;
Expand Down Expand Up @@ -728,9 +724,9 @@ - (void)audioPlayer:(AudioPlayer *)player removeEqualizer:(AudioUnit)eq
{
_eqWasOpen = [_equi isOpen];
}

_equi = nil;
_eq = nil;
[self eqDealloc];

if (_eqWasOpen)
{
Expand Down
3 changes: 1 addition & 2 deletions Audio/Output/OutputCoreAudio.m
Original file line number Diff line number Diff line change
Expand Up @@ -767,9 +767,8 @@ - (void)stop
}
if (_eq)
{
// This takes the EQ and frees it after disposing of any present UIs
[outputController endEqualizer:_eq];
AudioUnitUninitialize(_eq);
AudioComponentInstanceDispose(_eq);
_eq = NULL;
}
#ifdef OUTPUT_LOG
Expand Down

0 comments on commit ec7009f

Please sign in to comment.