gstreamer alsa mixer renders gnome volume controls useless

Bug #252237 reported by xtknight
26
This bug affects 2 people
Affects Status Importance Assigned to Milestone
gst-plugins-base
Fix Released
Undecided
Unassigned
gst-plugins-base0.10 (Ubuntu)
Fix Released
Low
Unassigned
Declined for Intrepid by Martin Pitt

Bug Description

SRU Info

1. This bug is persistent and annoying because users cannot control the volume without it randomly going to zero. They may be unable to use their keyboard volume controls and/or the display for the volume popup that appears through gnome-settings-daemon may appear incorrect.

2. It hasn't been addressed upstream yet, but was reported a while ago.

3. Patch is available below.

4. Not everyone can reproduce it; that's why it's tricky. The bug is sneaky. For a lot of us, simply using the keyboard volume controls will reveal a blank volume popup and not the actual volume. Or, adjusting the volume slider in the mixer will uncover the problem in a very short time.

TEST CASE:
-open gnome-volume-control
-Adjust master or PCM mixers with the left/right channels locked. Watch the sliders desynchronize as you move at a slow speed or really fast speed.
-OR-
-use keyboard volume controls and observe that the volume popup reports incorrect or no volume-

5. I could not see possible regressions. This patch reverts a commit which seemed to make controlling volume an asynchronous operation or something of the matter, but introduced issues on many systems. It used to work fine for everyone (to my knowledge) before the commit. So really, a regression is being reversed. I wasn't able to pinpoint exactly why that commit was added in to the gstreamer code.

---------------------------------------------------------------------------------------------------------

Primary example (only GNOME affected, focus of this bug, prelim. patch for it below)
1. Open gnome-volume-control
2. option a. Use keyboard to control volume. It is immediately messed up and the progress bar on the volume control disappears. You can see with alsamixer that one channel is randomly muted now and then.
2. option b. Rapidly adjust PCM volume with the channels locked. The channels will eventually loosen up or one will go to 0.

GNOME without pulseaudio and without software mixing still has the problem. The problem seems DIRECTLY related to GNOME, but it's also possible this bug is similar to the one below. The first problem is MUCH worse and ruins daily, practical use of the OS. The second is an observation and not intended to be the focal point of this bug report. I didn't see random muting with the second bug (that I can remember) but I saw a ton with the first.

--------------------------

Secondary example (all desktops):
1. Open gnome-alsamixer
2. Open gnome-volume-control
3. Open alsamixer

Adjust PCM volume with text-mode alsamixer. The two channels get out of sync very quickly.

sudo sh -c "echo 0 > /sys/devices/system/cpu/cpu1/online"

This command actually fixes the GNOME volume control on one of my dual-core systems (Intrepid/emu10k1). It is consistently reproducible and directly related to that command. On the other system (Hardy custom 2.6.26/cmipci), the command seems to have no effect and the problem remains.

Something is wrong with the locking or mutexing of the volume controls in an underlying component of Ubuntu. For some people, that means even rudimentary volume control with the keyboard is problematic.

Affected drivers:
- cmipci
- emu10k1
- possibly every audio driver

The second example happens on systems even with the 2nd cpu disabled, just a little less. With the first example it doesn't seem to matter.

Intrepid as of 7/24/2008 is affected.

I was not able to demonstrate any inconsistencies with the text-mode alsamixer when GNOME or KDE was not open, but that does not mean the race is not somewhere in the kernel either. Moving the volume controls with keys is a lot less stressful on the drivers than using a smooth slider or running apps that monitor the volume in real-time.

I have tried every fix I have seen, and none have fixed the problem.

Possibly related bugs:
- Bug 126333

From my debugging, a zero is first being written to a volume channel for some reason. I am not sure why or the source of it. Mixers then read this zero and the mistake carries on from there.

I will attach some library call logs from my debugging, but I can not say that they are reliable. "workinglogs" is from adjusting it slowly up and then slowly down in the text-mode alsamixer program with no desktop environment loaded, only a TTY.

"brokenlogs" shows what happens when I use my keyboard to do the same thing. The volume is jumping down periodically or going to zero.

_snd_mixer_selem_set_volume s->str[0].vol[1] = 18
elem_write_volume s->str[0].vol[0] = 0
elem_write_volume s->str[0].vol[1] = 18

The second write command giving alsa a zero makes no sense, and completely destroys the linearity of the adjustment. But I don't know where it's coming from. I don't know if it's adjusting the same track number even or if it is the cause of the problem, but it seems to correlate.

Each log file (mylogn) in the archives is tracking a different part of the sound control subsystem. mylog5 is the lowest level and mylog1/mylog2(gstreamer) are the highest. text-mode didn't use mylog1/mylog2, only 3-5 which are farther down the line in the sound system.

Both machines were dual-core Intel Core 2 running x86_64 architecture Ubuntu with 4GB of RAM. All tracing was done on the first system (cmipci).

Revision history for this message
xtknight (xt-knight) wrote :
description: updated
Revision history for this message
xtknight (xt-knight) wrote :
description: updated
description: updated
xtknight (xt-knight)
description: updated
description: updated
xtknight (xt-knight)
description: updated
description: updated
description: updated
Revision history for this message
xtknight (xt-knight) wrote : Re: [gnome] normal volume control useless, various race conditions

I tried four Ubuntu LiveCDs:

- 8.04.1 Live Ubuntu (32-bit)
- 8.04.1 Live Kubuntu (32-bit)
- 8.04.1 Live Ubuntu (64-bit)
- 8.04.1 Live Kubuntu (64-bit)

While all of them may have exhibited the second problem to some extent, the first, more serious problem for all practical purposes did not exist on the KDE CDs.

I installed kubuntu-desktop on my normal GNOME Ubuntu machine. When I go into KDE, the problem no longer happens. Killing the mixer applet and closing volume control programs on GNOME doesn't help the problem. (gnome-settings-daemon obviously is still running to handle keyboard volume controls, my best demonstration of the issue.)

Revision history for this message
xtknight (xt-knight) wrote :

I am reasonably sure this is a gstreamer problem (either that or somehow lower down the line into alsa, but it doesn't happen in KDE so there's something in gnome...)

Mixer applications that use snd_mixer_selem_set_playback_volume() (alsamixer, gnome-alsamixer) never seem to experience the problem on their own. Applications that use gst_mixer_set_volume() (gnome-settings-daemon, gnome-volume-control) experience it excessively.

Therefore ext/alsa/gstalsamixer.c is probably the file at fault in this source package.

If I ltrace gnome-settings-daemon and use my keyboard volume keys, the problem is almost completely fixed. This indicates some type of timing problem, because ltrace slows down applications by a little bit.

Revision history for this message
Sebastien Bacher (seb128) wrote :

thank you for your bug report, do you do power management changes to your configuration? do you get the issue if you don't use pulseaudio?

Changed in gst-plugins-base0.10:
importance: Undecided → Low
status: New → Incomplete
Revision history for this message
xtknight (xt-knight) wrote :
Download full text (3.5 KiB)

Sebastien,

I have a CPU that scales from 3.00 GHz to 2.00 GHz. This is the only power management I use. That is the "ondemand" governor for my CPU and it was enabled by default. I made no further changes to any power management settings in Ubuntu. I get the issue even when pulseaudio is removed from my system and confirmed not running through "ps ax".

This might be worse with SMP although I'm not exactly sure why.

I have limited down the problem to a few packages. When I install the Feisty packages listed here on my Hardy, the volume control functions properly (although the volume icon is missing, that is irrelevant). When I install the Gutsy ones, it breaks. Between Feisty and Gutsy is where the breakage happened.

From Feisty {
-rwxr-xr-x 1 andy andy 189352 2007-04-12 16:41 gnome-settings-daemon
-rw-r--r-- 1 andy andy 68400 2008-07-28 02:09 gstreamer0.10-alsa_0.10.12-0ubuntu1_amd64.deb
-rw-r--r-- 1 andy andy 480170 2008-07-28 02:09 gstreamer0.10-plugins-base_0.10.12-0ubuntu1_amd64.deb
-rw-r--r-- 1 andy andy 19876 2008-07-28 02:11 libgnomekbd1_2.18.1-0ubuntu1_amd64.deb
-rw-r--r-- 1 andy andy 20826 2008-07-28 02:11 libgnomekbd-common_2.18.1-0ubuntu1_all.deb
-rw-r--r-- 1 andy andy 687866 2008-07-28 02:09 libgstreamer0.10-0_0.10.12-0ubuntu2_amd64.deb
-rw-r--r-- 1 andy andy 181430 2008-07-28 02:09 libgstreamer-plugins-base0.10-0_0.10.12-0ubuntu1_amd64.deb
-rw-r--r-- 1 andy andy 80516 2008-07-28 02:09 libxklavier11_3.2-0ubuntu1_amd64.deb
}

- problem comes in here -

Gutsy {
-rwxr-xr-x 1 andy andy 209704 2007-10-08 06:48 gnome-settings-daemon
-rw-r--r-- 1 andy andy 71246 2008-07-28 02:07 gstreamer0.10-alsa_0.10.14-1ubuntu3_amd64.deb
-rw-r--r-- 1 andy andy 528782 2008-07-28 02:12 gstreamer0.10-plugins-base_0.10.14-1ubuntu3_amd64.deb
-rw-r--r-- 1 andy andy 738756 2008-07-28 02:08 libgstreamer0.10-0_0.10.14-1ubuntu3_amd64.deb
-rw-r--r-- 1 andy andy 231534 2008-07-28 02:08 libgstreamer-plugins-base0.10-0_0.10.14-1ubuntu3_amd64.deb
}

Furthermore,

I modified the Gutsy control-center-2.18.1/gnome-settings-daemon/actions/acme-volume-gstreamer.c and control-center-2.18.1/gnome-settings-daemon/gnome-settings-multimedia-keys.c files to match Feisty's control center package.

Then I modified the gutsy source package gst-plugins-base0.10-0.10.14's ext/alsa directory to the Feisty gst-plugins-base0.10-0.10.12 ext/alsa. After compiling and loading the new Gutsy debs onto my Hardy, the volume control functions properly.

sudo dpkg -i gstreamer0.10-alsa_0.10.14-1ubuntu3_amd64.deb

sudo dpkg -i gstreamer0.10-plugins-base_0.10.14-1ubuntu3_amd64.deb

sudo dpkg -i libgstreamer-plugins-base0.10-0_0.10.14-1ubuntu3_amd64.deb

So I loaded in my patches. I copied the gnome-settings-daemon out of the new deb, placed in Hardy's /usr/bin. Killed the process and restarted it. Then using the keyboard, the volume keys work properly as I can see by running alsamixer in the background. No jumping to zero or mess ups. gnome-volume-control also acts much more reliably with the patched Gutsy libs.

Certainly I will be working on a patch to Hardy and Intrepid for this but there was a lot of code that was changed (few hundred lines?) So it may take some fur...

Read more...

Changed in gst-plugins-base0.10:
status: Incomplete → New
status: New → Incomplete
Revision history for this message
Sebastien Bacher (seb128) wrote :

thank you for your work on that, you might want to open the bug on bugzilla.gnome.org maybe upstream has some clue about the issue

xtknight (xt-knight)
Changed in gst-plugins-base0.10:
status: Incomplete → New
Revision history for this message
xtknight (xt-knight) wrote :

Sent upstream, but here's a patch that works for Hardy. I don't think it breaks any other apps. It's on my PPA as well.

xtknight (xt-knight)
description: updated
Changed in gst-plugins-base:
status: Unknown → New
Changed in gst-plugins-base0.10:
status: New → Triaged
Revision history for this message
Fernando Miguel (fernandomiguel) wrote :

is this bug related with the way that even after you stop pressing the audio keyboard shortcuts, the sound still continues to increase/decrease?

Revision history for this message
xtknight (xt-knight) wrote :

BUGabundo: it's possible that it's related. I did not experience that problem in my testing of it. If you have that problem you could see if my debs fix it for you. They are on my PPA.

Revision history for this message
Fernando Miguel (fernandomiguel) wrote :
Revision history for this message
Fernando Miguel (fernandomiguel) wrote :

never mind i've found the correct link
https://edge.launchpad.net/~xt-knight/+archive

i'll test it in a bit and report back.

Revision history for this message
Fernando Miguel (fernandomiguel) wrote :

your versions are for hardy, and the package are lower version then the ones that I have on my system ( i have intrepid).

Should i downgrade?

Revision history for this message
xtknight (xt-knight) wrote :

BUGabundo: it's probably alright to downgrade. You can still see if it fixes the bug.

I would make a package for Intrepid but I can't get it to work in my VM at the moment and I'd also like to see what the gstreamer team says before doing much else.

Revision history for this message
Mark Falcey (mfalcey) wrote :

I am not sure if this is the same bug, but it is very similar. I am using Hadry 8.04.1 and ALSA 1.0.15

I am experiencing this problem also but only with my usb headest. If I select the headset in System/Preferences/Sound I can control the volume with the multimedia keys but the left always drops to zero when I change the volume, Right channel reacts normally. This also happens when I have them selected in the panel Volume Control and try to adjust the volume with the mouse.

This does not happen in the Pulse Audio Volume Control. When the sliders are out of lock from the above using the PA Volume Control locks the sliders back together and allows them to be adjusted in a normal fashion.

This also does not happen with my C-Media 8768 PCI card or AC'97 on board sound or with any of the pulseaudio virtual devices.

Is seems to be a strictly ALSA USB problem from here.

Revision history for this message
Davidiam (hectorjerezano) wrote :

I have the same problem before upgrading to intrepid y solved using xtknight PPA repository , but now in intrepid went back with the same problem . Is it that developers from gstreamer did not apply the patch cause I try debian stable en experimental alsa did have the same issue.

xtknight do you have PPA for intrepid?

Revision history for this message
xtknight (xt-knight) wrote :

Davidiam: Yes, the problem persists in Intrepid.

The developers didn't look at my bug yet as far as I can tell. Not much I can do about that.

I'll try to get a PPA for Intrepid soon. My patches are not "fixes", they are "reverts" to unbreak what was broken.

Revision history for this message
xtknight (xt-knight) wrote :

Here's a patch that fixes it for intrepid. Same patch as for Hardy.

Revision history for this message
Davidiam (hectorjerezano) wrote :

Thanks! Working now as it should be!

xtknight (xt-knight)
description: updated
xtknight (xt-knight)
description: updated
Revision history for this message
Martin Pitt (pitti) wrote :

I can reproduce it as well with some fiddling, but it happens very rarely. This does not look like a serious bug which warrants an SRU in my opinion, and the patch is far from trivial, thus it does not match the SRU criteria.

Also, please get this fixed in Jaunty first. Thanks a lot for your work on this!

Revision history for this message
Martin Pitt (pitti) wrote :

(It is easy to recover from the desynchronized mixer applet by just locking them again and sliding them back up)

Revision history for this message
xtknight (xt-knight) wrote :

Martin Pitt: thank you for looking at it. At this point I don't see a point of making this fix for Jaunty too when it hasn't gotten into Hardy or Intrepid. So, I will wait until the gstreamer people devise the "proper" solution to fix their code and backport to Jaunty whatever patch ensues from their decision.

Revision history for this message
Sebastien Bacher (seb128) wrote :

does the change still applies to jaunty?

Revision history for this message
Fernando Miguel (fernandomiguel) wrote :

i dont see how this could affect current behavior on jaunty, since the new PA controls lacks all the usual alsamixer levers.

Revision history for this message
Sebastien Bacher (seb128) wrote :

unsubscribing the sponsor team if there is nothing to sponsor there

Revision history for this message
xtknight (xt-knight) wrote :

Still experience this blunder in Jaunty simply by using keyboard controls. Audio mutes itself randomly.

They already fixed it in this commit:
http://bugzilla.gnome.org/show_bug.cgi?id=478512

commit fc23037a9aaf0beca99f9494948b2fb1169a03db
Author: Antoine Tremblay <email address hidden>
Date: Tue Feb 10 11:00:12 2009 +0100

    alsamixer: Fix race condition that made alsamixer not working properly

It really wouldn't be too bad to get this into Jaunty would it? Let's smash this bug at last...

Revision history for this message
xtknight (xt-knight) wrote :
Revision history for this message
Sebastien Bacher (seb128) wrote :

thank you for your work there, the package is on sync with debian though and should stay this way, I pinged the debian maintainer for this package and he will backport the change, unsubscribing the sponsors

Revision history for this message
Sebastien Bacher (seb128) wrote :

gst-plugins-base0.10 (0.10.22-3) unstable; urgency=low

  * debian/patches/01_alsamixer-race-condition.patch:
    + Fix race condition in alsamixer which made the volume controls
      useless in many situations (Closes: #514685).
      Patch from upstream GIT.

Changed in gst-plugins-base0.10:
status: Triaged → Fix Released
Revision history for this message
xtknight (xt-knight) wrote :

This is no longer an issue. It was fixed in gstreamer upstream.

Changed in gst-plugins-base:
importance: Unknown → Undecided
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.