After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 486840 - [alsamixer] use _all variants when setting the mixer
[alsamixer] use _all variants when setting the mixer
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
git master
Other Linux
: Normal normal
: 0.10.16
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2007-10-15 14:23 UTC by Bastien Nocera
Modified: 2008-01-07 14:02 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gst-alsa-mixer-use-all.patch (2.55 KB, patch)
2007-10-15 14:23 UTC, Bastien Nocera
committed Details | Review

Description Bastien Nocera 2007-10-15 14:23:19 UTC
See: https://bugzilla.redhat.com/show_bug.cgi?id=305501

alsa-lib sometimes gives us different answer to _get() when _set()'ing the volumes quickly.

1. Launch gnome-volume-control
2. Check that the master track's channels are locked
3. Change the volume quickly, the 2 channels will become unlocked (the 2 tracks
end up with different volumes)

I debugged this in gst-plugins-base's gstalsamixer.c:
A quick succession of snd_mixer_selem_set_playback_volume and
snd_mixer_selem_get_playback_volume will result in 2 slightly different results.

I add those lines in gst_alsa_mixer_get_volume():
      if (track->num_channels == 2 && volumes[0] != volumes[1])
             printf ("volumes[0]: %d volumes[1]: %d\n",
                    volumes[0], volumes[1]);
And saw this after dragging the sliders for a while:
volumes[0]: 31 volumes[1]: 21
etc.

The attached patch makes the set() use the _all() variants if all the tracks are set to have the same volume.
Comment 1 Bastien Nocera 2007-10-15 14:23:46 UTC
Created attachment 97240 [details] [review]
gst-alsa-mixer-use-all.patch
Comment 2 Tim-Philipp Müller 2007-10-16 09:19:22 UTC
Do you know _why_ this happens?  Your patch looks like a hack to work around a problem in alsa to me, but maybe I'm just not getting the real issue.
Comment 3 Bastien Nocera 2007-10-16 09:26:35 UTC
(In reply to comment #2)
> Do you know _why_ this happens?

No, I don't, which is why I've left the original bug against alsa-lib opened.

> Your patch looks like a hack to work around a
> problem in alsa to me, but maybe I'm just not getting the real issue.

It is a work-around. It's not that much of a hack though, as we should use the _all variants when possible.
Comment 4 Tim-Philipp Müller 2008-01-07 14:02:21 UTC
Oh well:

 2008-01-07  Tim-Philipp Müller  <tim at centricular dot net>

        Patch by: Bastien Nocera <hadess at hadess net>

        * ext/alsa/gstalsamixer.c: (gst_alsa_mixer_get_volume),
          (check_if_volumes_are_the_same), (gst_alsa_mixer_set_volume):
          Use snd_mixer_selem_set_{playback|capture}_volume_all() if
          the volume is the same for all channels. This works around
          some problem in alsa that leaves us with inconsistent state
          for some reason (#486840).

(I took the liberty to make the function return a boolean when it actually returns booleans :))