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 518082 - [alsamixer] playback volumes overwritten by capture volumes if track has both playback and capture caps
[alsamixer] playback volumes overwritten by capture volumes if track has both...
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
0.10.17
Other Linux
: Normal normal
: 0.10.20
Assigned To: Tim-Philipp Müller
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2008-02-22 14:57 UTC by Kjel Oslund
Modified: 2008-07-03 11:46 UTC
See Also:
GNOME target: ---
GNOME version: 2.21/2.22


Attachments
Patch to only set the alsa flags on the correct track (2.73 KB, patch)
2008-04-10 16:14 UTC, James Westby
committed Details | Review

Description Kjel Oslund 2008-02-22 14:57:05 UTC
The gst alsamixer implementation supports alsa element tracks that have both playback and capture capabilities by creating two separate tracks for the element. See gst-plugins-base/ext/alsa/gstalsamixer.c function gst_alsa_mixer_ensure_track_list(). When the track is created in gstalsamixertrack.c gst_alsa_mixer_track_new() it is passed a flag field which indicates whether the track is _INPUT or _OUTPUT and the function initializes a separate field alsa_flags in function gst_alsa_mixer_track_update_alsa_capabilities using alsa functions snd_mixer_selem_has_playback_volume and snd_mixer_selem_has_capture_volume. As a consequence a dual capability track will have both GST_ALSA_MIXER_TRACK_PVOLUME and GST_ALSA_MIXER_TRACK_CVOLUME flags set on *both* the _INPUT and _OUTPUT tracks created for the alsa element.

This leads to a bug when gst_alsa_mixer_track_update() is called to update a tracks volumes. This function checks only the alsa_flags (via alsa_track_has_cap). If a track has both _PVOLUME AND _CVOLUME set, the function will first retrieve the playback volumes and store them in GstMixerTrack->volumes, then it will retrieve the capture volumes and overwrite the playback volumes in the structure, since GstMixerTrack supports only one set of volumes.

This bug showed up in a recent version of gnome-applets/applet_mixer2 on Mandriva Cooker, which includes a patch not yet accepted in the gnome-applets trunck, but which has been implement in Redhat and Ubuntu distributions and which implements mixer notifications. When used with an Audigy2 card, which alsa shows as having a dual capability Master element, changes to the Master volume result in notifications in which the Master playback volume is always set to zero when in fact it is non-zero.

This bug was located and verified by tracing with gdb and inspection of the code.

Output from amixer:
$ amixer -c 0 info
Card hw:0 'Audigy2'/'Audigy 2 [SB0240] (rev.4, serial:0x10071102) at 0xa000, irq 20'
  Mixer name	: 'SigmaTel STAC9721,23'
  Components	: 'AC97a:83847609'
  Controls      : 213
  Simple ctrls  : 48

$ amixer -c 0 | head
Simple mixer control 'Master',0
  Capabilities: pvolume pvolume-joined cvolume cswitch cswitch-joined
  Playback channels: Mono
  Capture channels: Front Left - Front Right
  Limits: Playback 0 - 100 Capture 0 - 31
  Mono: Playback 9 [9%] [-36.40dB]
  Front Left: Capture 0 [0%] [-46.50dB] [on]
  Front Right: Capture 0 [0%] [-46.50dB] [on]
Simple mixer control 'Tone',0
  Capabilities: pswitch
Comment 1 Bastien Nocera 2008-02-22 15:16:42 UTC
Good catch.
Comment 2 Tim-Philipp Müller 2008-02-22 17:31:18 UTC
Ouch, nice catch indeed.
Comment 3 Tim-Philipp Müller 2008-02-27 21:02:22 UTC
So I've fixed this locally (I think), but it's still all a bit messed up - some of the channels always jump back to 0 when I change a slider control (maybe related to bug #478498 though?)

Do you have a patch that fixes this for you, or were you just posting the result of your investigation?
Comment 4 Kjel Oslund 2008-02-28 01:30:57 UTC
Sorry, no patch. I just posted the results of my investigation. I don't know gstreamer well enough at this point to attempt a patch.
Comment 5 James Westby 2008-04-10 16:13:48 UTC
Hi,

Tim-Philipp passed his patch to me on IRC, so I'm attaching
it here in the hope that someone can test it.

Thanks,

James
Comment 6 James Westby 2008-04-10 16:14:55 UTC
Created attachment 109002 [details] [review]
Patch to only set the alsa flags on the correct track
Comment 7 Bastien Nocera 2008-04-18 13:53:34 UTC
If you use Fedora rawhide, you might want to test those packages, with the patch included:
http://koji.fedoraproject.org/koji/buildinfo?buildID=46563
Comment 8 Tim-Philipp Müller 2008-05-27 16:14:04 UTC
I've committed this now:

 2008-05-27  Tim-Philipp Müller  <tim.muller at collabora co uk>

        * ext/alsa/gstalsamixertrack.c:
          (gst_alsa_mixer_track_update_alsa_capabilities):
          Make sure playback volumes aren't accidentally overwritten by
          capture volumes if an alsa mixer track has both playback and
          capture capabilities: we create two GstMixerTracks in that
          case, so make sure we query only the alsa capabilities that
          refer to the type of GstMixerTrack we created from the dual
          capability alsa element. Should fix issues with Audigy2 sound
          cards (#518082).

Hope this fixes at least some of the issues with Audigy2 cards.
Comment 9 Kjel Oslund 2008-07-03 11:46:11 UTC
Confirming that the posted problem is fixed. The updated version that fixes this problem was just recently released on Mandriva cooker.