From 8d7cd6cc9373190c80ce06436667a058c10c316f Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Sun, 26 Dec 2021 02:01:53 -0800 Subject: [PATCH] Multi Input plugin: Correctly forward register and remove observer callbacks to the actual decoder in use --- Audio/CogPluginMulti.m | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Audio/CogPluginMulti.m b/Audio/CogPluginMulti.m index f4ad98cb5..d5a22d88c 100644 --- a/Audio/CogPluginMulti.m +++ b/Audio/CogPluginMulti.m @@ -126,18 +126,23 @@ NSArray * sortClassesByPriority(NSArray * theClasses) } else { [cachedObservers addObject:[NSDictionary dictionaryWithObjectsAndKeys:observer, @"observer", keyPath, @"keyPath", @(options), @"options", nil]]; } + if (theDecoder) { + [theDecoder addObserver:observer forKeyPath:keyPath options:options context:context]; + } } /* And this is currently called after the decoder is closed */ - (void)removeObserver:(NSObject *)observer forKeyPath:(NSString *)keyPath { - for (NSDictionary *obsItem in cachedObservers) - { + for (NSDictionary *obsItem in cachedObservers) { if ([obsItem objectForKey:@"observer"] == observer && [keyPath isEqualToString:[obsItem objectForKey:@"keyPath"]]) { [cachedObservers removeObject:obsItem]; break; } } + if (theDecoder) { + [theDecoder removeObserver:observer forKeyPath:keyPath]; + } } @end