[vlc-commits] macosx: audio effects: Do not duplicate EQ settings when saving profile

David Fuhrmann git at videolan.org
Wed Dec 13 23:51:26 CET 2017


vlc/vlc-3.0 | branch: master | David Fuhrmann <dfuhrmann at videolan.org> | Wed Dec 13 22:44:11 2017 +0100| [d93f6bfaaef8b8b8e9fe5bf5bdb42385ebd56cf7] | committer: David Fuhrmann

macosx: audio effects: Do not duplicate EQ settings when saving profile

For now, disable the code which duplicated EQ settings. This code
currently always duplicates settings if something was touched, as the
comparison with index 0 (flat profile) will very likey fail.

This needs more improvements beyond the current code, before we can
activate auto-saving of EQ changes, mainly:
- Figure out a way how to deal with (likely unchangable) default profiles
- Correctly mark own created profiles
- Correctly save own created profiles once overall preset is changed, but
  not override standard profiles
- Save own EQ profiles at exit automatically if desired.
- If above problems are solved, AND the user selected a default EQ profile
  and changed it inbetween, the commented code can be reconsidered.

This commit basically changes behaviour back to vlc 2.2.x, where a new
EQ Profile needs to be explicitly saved if desired (using the dropdown
menu).

refs #19260

(cherry picked from commit d0fe23e61ac1f6a7ecf2886e396fc1dcf1408a9d)
Signed-off-by: David Fuhrmann <dfuhrmann at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=d93f6bfaaef8b8b8e9fe5bf5bdb42385ebd56cf7
---

 .../gui/macosx/VLCAudioEffectsWindowController.m   | 25 ++++++++++++++--------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/modules/gui/macosx/VLCAudioEffectsWindowController.m b/modules/gui/macosx/VLCAudioEffectsWindowController.m
index 50cbb2124b..1f630cc661 100644
--- a/modules/gui/macosx/VLCAudioEffectsWindowController.m
+++ b/modules/gui/macosx/VLCAudioEffectsWindowController.m
@@ -410,16 +410,21 @@
 
     playlist_t *p_playlist = pl_Get(getIntf());
     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+    if ([[self generateProfileString] compare:[VLCAudioEffectsWindowController defaultProfileString]] == NSOrderedSame)
+        return;
+
+    // FIXME: Current code does not allow auto save of equalizer profiles, those profiles currently need to be saved
+    // individually with the popup menu, before saving the overall profile.
+    // Below code for auto duplication is not enough to fix current behaviour and results in too many duplicated profiles
+    // For auto-saving of eq profiles, a different stragety needs to be found, involving save also once overall profile changes.
+/*
     NSString *newPresetString = [NSString stringWithCString:var_InheritString(p_playlist, "equalizer-bands") encoding:NSASCIIStringEncoding];
     float newPresetPreamp = var_InheritFloat(p_playlist, "equalizer-preamp");
 
+    // TODO: Comparing against profile 0 is mostly useless and looks wrong (profile 0 is flat usually)
     NSInteger defaultPresetIndex = [self getPresetIndexForProfile:0];
     NSString *defaultPresetString = [[defaults objectForKey:@"EQValues"] objectAtIndex:defaultPresetIndex];
     float defaultPresetPreamp = [[[defaults objectForKey:@"EQPreampValues"] objectAtIndex:defaultPresetIndex] floatValue];
-    if ([[self generateProfileString] compare:[VLCAudioEffectsWindowController defaultProfileString]] == NSOrderedSame &&
-        [newPresetString compare:defaultPresetString] == NSOrderedSame &&
-        newPresetPreamp == defaultPresetPreamp)
-        return;
 
     NSMutableArray *workArray;
     int num_custom;
@@ -427,7 +432,7 @@
     if ([newPresetString compare:defaultPresetString] != NSOrderedSame ||
         newPresetPreamp != defaultPresetPreamp)
     {
-        /* preset title */
+        // preset title
         NSArray<NSString *> *presetTitles = [defaults objectForKey:@"EQTitles"];
         NSString *newPresetTitle;
 
@@ -440,24 +445,26 @@
         [workArray addObject:newPresetTitle];
         [defaults setObject:[NSArray arrayWithArray:workArray] forKey:@"EQTitles"];
 
-        /* preset name */
+        // preset name
         NSString *decomposedStringWithCanonicalMapping = [newPresetTitle decomposedStringWithCanonicalMapping];
         workArray = [[NSMutableArray alloc] initWithArray:[defaults objectForKey:@"EQNames"]];
         [workArray addObject:decomposedStringWithCanonicalMapping];
         [defaults setObject:[NSArray arrayWithArray:workArray] forKey:@"EQNames"];
         var_SetString(p_playlist, "equalizer-preset", [decomposedStringWithCanonicalMapping UTF8String]);
 
-        /* preset bands */
+        // preset bands
         workArray = [[NSMutableArray alloc] initWithArray:[defaults objectForKey:@"EQValues"]];
         [workArray addObject:newPresetString];
         [defaults setObject:[NSArray arrayWithArray:workArray] forKey:@"EQValues"];
 
-        /* preset preamp */
+        // preset preamp
         workArray = [[NSMutableArray alloc] initWithArray:[defaults objectForKey:@"EQPreampValues"]];
         [workArray addObject:[NSString stringWithFormat:@"%.1f", [_equalizerPreampSlider floatValue]]];
         [defaults setObject:[NSArray arrayWithArray:workArray] forKey:@"EQPreampValues"];
     }
+*/
 
+    NSMutableArray *workArray;
     /* profile string */
     workArray = [[NSMutableArray alloc] initWithArray:[defaults objectForKey:@"AudioEffectProfiles"]];
     [workArray addObject:[self generateProfileString]];
@@ -467,7 +474,7 @@
     NSArray<NSString *> *profileNames = [defaults objectForKey:@"AudioEffectProfileNames"];
     NSString *newProfileName;
 
-    num_custom = 0;
+    int num_custom = 0;
     do
         newProfileName = [@"Custom" stringByAppendingString:[NSString stringWithFormat:@"%03i",num_custom++]];
     while ([profileNames containsObject:newProfileName]);



More information about the vlc-commits mailing list