[MPlayer-dev-eng] Is there a bug with balance?

Hans-Dieter Kosch hdkosch at kabelbw.de
Sat Mar 22 03:47:51 CET 2014


Ingo Brückl wrote:

> When I change balance with '(' or ')', I get a console information on the
> new balance, but there isn't any change in the left/right channel of my PC
> speakers.
> 
> Is this a bug?

I can reproduce this behaviour (using ALSA).

> I was wondering why the GUI sets volume after a balance change, but now I'm
> realizing that it seems necessary.
> 
> Oughtn't MPlayer adjust the left/right volume when the balance changes, or am
> I missing something?

There's more unclear interaction between balance and volume. When running the 
GUI, balance is reset to 50% upon each new stream. Root cause is that 
mixer_getbalance() in mixer.c fails at first time and returns a default value of 
0, interpreted as 50%. I could work around it with patch below:


Index: gui/interface.c
===================================================================
--- gui/interface.c      (revision 37038)
+++ gui/interface.c      (working copy)
@@ -742,16 +742,22 @@

          if (mixer) {
              float l, r, b;
+            int balance_corrected = False;
              static float last_balance = 50.0f;

              mixer_getvolume(mixer, &l, &r);
              guiInfo.Volume = FFMAX(l, r);

              mixer_getbalance(mixer, &b);
+            if (b == 0.0f && l != r) {
+                b = (r - l) / guiInfo.Volume; // (NB: div by 0 can't occur here)
+                balance_corrected = True;
+            }
              guiInfo.Balance = (b + 1.0) * 50.0; // transform -1..1 to 0..100

              if (guiInfo.Balance != last_balance) {
-                uiEvent(ivSetVolume, guiInfo.Volume);
+                if (!balance_corrected)
+                    uiEvent(ivSetVolume, guiInfo.Volume);
                  last_balance = guiInfo.Balance;
              }
          }


Balance and volume seem unsynchronised to me on driver level; my ALSA Mixer has 
no balance, it's handled by volume L/R.

Hans-Dieter


More information about the MPlayer-dev-eng mailing list