From f2feb3bcd7e8ae5d08748ea3fbdfa52520fd26aa Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Wed, 19 Jan 2022 01:23:59 -0800 Subject: [PATCH] Equalizer: Fix applying equalizer presets on automatic track change --- Application/PlaybackController.m | 3 ++- Audio/Output/OutputCoreAudio.m | 8 ++------ Window/AUPlayerView.h | 2 +- Window/AUPlayerView.m | 6 ++++-- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Application/PlaybackController.m b/Application/PlaybackController.m index f0b5f6f8f..5f61d2c68 100644 --- a/Application/PlaybackController.m +++ b/Application/PlaybackController.m @@ -760,7 +760,8 @@ NSDictionary * makeRGInfo(PlaylistEntry *pe) [playlistController setCurrentEntry:pe]; - equalizerApplyGenre([pe genre]); + if (_eq) + equalizerApplyGenre(_eq, [pe genre]); lastPosition = -10; diff --git a/Audio/Output/OutputCoreAudio.m b/Audio/Output/OutputCoreAudio.m index 188a2bf4a..3e5538b58 100644 --- a/Audio/Output/OutputCoreAudio.m +++ b/Audio/Output/OutputCoreAudio.m @@ -13,6 +13,8 @@ extern void scale_by_volume(float * buffer, size_t count, float volume); +static NSString *CogPlaybackDidBeginNotficiation = @"CogPlaybackDidBeginNotficiation"; + @implementation OutputCoreAudio static void fillBuffers(AudioBufferList *ioData, float * inbuffer, size_t count, size_t offset) @@ -158,7 +160,6 @@ static OSStatus renderCallback( void *inRefCon, AudioUnitRenderActionFlags *ioAc [[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@"values.outputDevice" options:0 context:NULL]; [[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@"values.GraphicEQenable" options:0 context:NULL]; - [[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@"values.GraphicEQpreset" options:0 context:NULL]; } return self; @@ -184,10 +185,6 @@ default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const [self setEqualizerEnabled:enabled]; } - else if ([keyPath isEqualToString:@"values.GraphicEQpreset"]) { - if (_eq) - [outputController refreshEqualizer:_eq]; - } } - (void)signalEndOfStream @@ -755,7 +752,6 @@ default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const [[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeyPath:@"values.outputDevice"]; [[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeyPath:@"values.GraphicEQenable"]; - [[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeyPath:@"values.GraphicEQpreset"]; } - (void)pause diff --git a/Window/AUPlayerView.h b/Window/AUPlayerView.h index 8c7c18936..0933cdd84 100644 --- a/Window/AUPlayerView.h +++ b/Window/AUPlayerView.h @@ -14,7 +14,7 @@ #import #import -void equalizerApplyGenre(NSString *genre); +void equalizerApplyGenre(AudioUnit au, NSString *genre); void equalizerLoadPreset(AudioUnit au); void equalizerApplyPreset(AudioUnit au, NSDictionary * preset); diff --git a/Window/AUPlayerView.m b/Window/AUPlayerView.m index 3da82981a..0717559df 100644 --- a/Window/AUPlayerView.m +++ b/Window/AUPlayerView.m @@ -233,7 +233,7 @@ static void loadPresets() CFRelease(appUrlRef); } -void equalizerApplyGenre(NSString *genre) { +void equalizerApplyGenre(AudioUnit au, NSString *genre) { equalizerGenre = genre; if ([[[NSUserDefaultsController sharedUserDefaultsController] defaults] boolForKey:@"GraphicEQtrackgenre"]) { loadPresets(); @@ -264,6 +264,8 @@ void equalizerApplyGenre(NSString *genre) { if (preset) { NSInteger index = [equalizer_presets_processed indexOfObject:preset]; [[[NSUserDefaultsController sharedUserDefaultsController] defaults] setInteger:index forKey:@"GraphicEQpreset"]; + + equalizerApplyPreset(au, preset); } } } @@ -683,7 +685,7 @@ void equalizerApplyPreset(AudioUnit au, NSDictionary * preset) { [[[NSUserDefaultsController sharedUserDefaultsController] defaults] setBool:enabled forKey:@"GraphicEQtrackgenre"]; - equalizerApplyGenre(equalizerGenre); + equalizerApplyGenre(au, equalizerGenre); [self changePreset:presetButton]; }