diff gui/interface.c @ 33671:a460339acfdf

Fix volume and balance bug. Changing the volume changed the balance as well, because the calculation for the balance was wrong. Additionally, use macro FFMAX() and replace identical code by a call to existing code.
author ib
date Tue, 28 Jun 2011 17:52:30 +0000
parents 3b3e2d2f68c3
children e576232a39d5
line wrap: on
line diff
--- a/gui/interface.c	Tue Jun 28 17:36:19 2011 +0000
+++ b/gui/interface.c	Tue Jun 28 17:52:30 2011 +0000
@@ -689,10 +689,10 @@
             float l, r;
 
             mixer_getvolume(mixer, &l, &r);
-            guiInfo.Volume = (r > l ? r : l);
+            guiInfo.Volume = FFMAX(l, r);
 
-            if (r != l)
-                guiInfo.Balance = ((r - l) + 100) * 0.5f;
+            if (guiInfo.Volume)
+                guiInfo.Balance = ((r - l) / guiInfo.Volume + 1.0) * 50.0;
             else
                 guiInfo.Balance = 50.0f;
 
@@ -719,20 +719,7 @@
 
         // audio
 
-        if (mixer) {
-            float l, r;
-
-            mixer_getvolume(mixer, &l, &r);
-            guiInfo.Volume = (r > l ? r : l);
-
-            if (r != l)
-                guiInfo.Balance = ((r - l) + 100) * 0.5f;
-            else
-                guiInfo.Balance = 50.0f;
-
-            btnModify(evSetVolume, guiInfo.Volume);
-            btnModify(evSetBalance, guiInfo.Balance);
-        }
+        guiGetEvent(guiSetMixer, NULL);
 
         if (gtkEnableAudioEqualizer) {
             equalizer_t eq;