GNOME Bugzilla – Bug 518082
[alsamixer] playback volumes overwritten by capture volumes if track has both playback and capture caps
Last modified: 2008-07-03 11:46:11 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
Good catch.
Ouch, nice catch indeed.
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?
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.
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
Created attachment 109002 [details] [review] Patch to only set the alsa flags on the correct track
If you use Fedora rawhide, you might want to test those packages, with the patch included: http://koji.fedoraproject.org/koji/buildinfo?buildID=46563
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.
Confirming that the posted problem is fixed. The updated version that fixes this problem was just recently released on Mandriva cooker.