Subject: Bug#845090: /usr/bin/alsamixer: alsamixer -c0 starts pulseaudio

From: Juha Jäykkä <[email-masked]>
Date: Sun, 20 Nov 2016 10:12:32 +0000

Package: alsa-utils
Version: 1.0.28-1
Severity: normal
File: /usr/bin/alsamixer

Dear Maintainer,

Running "alsamixer -c0" in order to adjust the ALSA mixer levels causes
pulseaudio daemon to start. This is not just wrong and unexpected, but
also causes unwanted side-effects in other programs, like mixer levels
changing and other programs suddenly defaulting to using pa.

Cheers,
Juha

-- System Information:
Debian Release: 8.5
  APT prefers stable
  APT policy: (995, 'stable'), (500, 'stable-updates'), (500, 'testing')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.16.0-4-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=fi_FI.UTF-8 (charmap=UTF-8) (ignored: LC_ALL set to en_GB.UTF-8)
Shell: /bin/sh linked to /bin/bash
Init: sysvinit (via /sbin/init)

Versions of packages alsa-utils depends on:
ii  dialog          1.2-20140911-1
ii  kmod            18-3
ii  libasound2      1.0.28-1
ii  libc6           2.19-18+deb8u6
ii  libncursesw5    5.9+20140913-1+b1
ii  libsamplerate0  0.1.8-8
ii  libtinfo5       5.9+20140913-1+b1
ii  lsb-base        4.1+Debian13+nmu1
ii  whiptail        0.52.17-1+b1

alsa-utils recommends no packages.

alsa-utils suggests no packages.

-- Configuration Files:
/etc/init.d/alsa-utils changed [not included]

-- no debconf information

---

From: Elimar Riesebieter <[email-masked]>
Date: Sun, 20 Nov 2016 14:36:33 +0100

> changing and other programs suddenly defaulting to using pa.

alsamixer doesn't fire up any puls daemon. Please check whether
puls is running before starting alsamixer. 

BTW: do you have more then one soundcard installed? If not just run
alsamixer without any option.

Elimar
-- 
  Obviously the human brain works like a computer.
  Since there are no stupid computers humans can't be stupid.
  There are just a few running with Windows or even CE ;-)

---

From: Juha Jäykkä <[email-masked]>
Date: Sun, 20 Nov 2016 18:15:54 +0000

> puls is running before starting alsamixer.

It should not, but it certainly does:

juhaj@meissa 18:07:16 ~> ps -flyu juhaj|grep pulseau
S juhaj     9740  9724  0  99  19  2204  3488 -      18:07 pts/4    00:00:00 
grep pulseau
Today is 20.11.2016, I am running on tty 4 and currently controlling 0 jobs
juhaj@meissa 18:07:31 ~> alsamixer -c0
/usr/bin/pulseaudio: line 3: /var/log/mpd/mpd.runs.pulseaudio.at: Permission 
denied
W: [pulseaudio.real] main.c: /proc/self/exe does not point to /usr/bin/
pulseaudio, cannot self execute. Are you playing games?
Today is 20.11.2016, I am running on tty 4 and currently controlling 0 jobs
juhaj@meissa 18:07:39 ~> ps -flyu juhaj|grep pulseau
S juhaj     9746     1  7  69 -11 10840 166267 -     18:07 ?        00:00:00 /
usr/bin/pulseaudio.real --start --log-target=syslog
S juhaj     9752  9746  0  80   0  5336 30992 -      18:07 ?        00:00:00 /
usr/lib/pulseaudio/pulse/gconf-helper
S juhaj     9756  9724  0  99  19  2160  3488 -      18:07 pts/4    00:00:00 
grep pulseau
Today is 20.11.2016, I am running on tty 4 and currently controlling 0 jobs
juhaj@meissa 18:07:40 ~> 

I do not think this behaviour is correct. The user juhaj is pristine, and 
default.pa comes from the deb, except I've added

load-module module-alsa-sink device=dmix:CARD=AudioPCI,DEV=1

just before 

.ifexists module-udev-detect.so
load-module module-udev-detect
.else
### Use the static hardware detection module (for systems that lack udev 
support)
load-module module-detect
.endif

> alsamixer without any option.

Your guess is correct. A total of three soundcards, although only two are 
relevant here: the third one is a webcam which only has a microphone, no 
speakers.

Now that you mention it, while alsamixer -c1 and alsamixer -c2 also start 
pulseaudio, only alsamixer -c0 causes any volumes to change.

Which makes me wonder perhaps 

load-module module-alsa-sink device=dmix:CARD=AudioPCI,DEV=1

has something to do with the changing of the mute setting. Having said that, I 
don't really mind if pulseaudio gets started as long as it does not screw up 
the mixer settings in the process: I can always configure other software to 
use alsa explicitly if I need to.

So I still think the problem is that pulseaudio gets started in the first 
place.

Cheers,
Juha

---

From: Elimar Riesebieter <[email-masked]>
Date: Thu, 24 Nov 2016 08:36:29 +0100

Control: tags -1 unreproducible

> Today is 20.11.2016, I am running on tty 4 and currently controlling 0 jobs

What do you want to tell me here? It seems your pulseaudio
installation is a bit buggy. I can't reproduce.

> default.pa comes from the deb, except I've added

default.pa comes from pulseaudio or xrdp package. There is no
instruction to start pulse in any alsa package.

> So I still think the problem is that pulseaudio gets started in the first 

It seems that pulse is fired up by mpd?

Elimar
-- 
  355/113: Not the famous irrational number pi,
           but an incredible simulation!
	                -unknown

---

From: Juha Jäykkä <[email-masked]>
Date: Sat, 26 Nov 2016 19:09:17 +0000

> installation is a bit buggy. I can't reproduce.

Apart from the bit about /usr/bin/pulseaudio being a script which simply 
records that pulseaudio has been started and then execs /usr/bin/
pulseaudio.real, pulseaudio and alsamixer are pristine jessie. The 
asound.conf, which does not refer to pulseaudio at all, is modified; 
default.pa is also modified, but it should not even be read in this case.

I'm sorry I forgot to remove that debugging script at /usr/bin/pulseaudio but 
the result is the same with that removed.

> instruction to start pulse in any alsa package.

You are quite correct. The culprit is /usr/share/alsa/alsa.conf.d/pulse.conf 
placed there by the package pulseaudio. If you install pulseaudio and that 
file then exists, can you then reproduce? (Please see my very last paragraph, 
too!)

Is this now a bug in pulseaudio? And what severity? I'd say this breaks 
unrelated software!

> It seems that pulse is fired up by mpd?

I think pulseaudio gets started by libasound.so.2 when it parses alsa.conf.d 
because pulseaudio has placed the above file there.

Interestingly enough, said file starts with a comment:

# PulseAudio alsa plugin configuration file to set the pulseaudio plugin as
# default output for applications using alsa when pulseaudio is running.

I would agree that this is probably the most commonly desired behaviour *when* 
pulseaudio is running. However, I would not expect this to start a fresh 
pulseaudio daemon when one is *not* running yet!

One further bit of information which I just realised might be relevant: there 
is a pulseaudio server running on the machine, but it belongs to another user. 
Could it be pulseaudio/alsa just naively think "pulseaudio running, let's use 
it" without considering whether they actually *can* use it or not? And when it 
cannot be used, a new daemon is fired up? Just guessing.

Cheers,
Juha

---

From: Elimar Riesebieter <[email-masked]>
Date: Sun, 18 Dec 2016 13:35:39 +0100

* Juha Jäykkä <[email-masked]> [2016-11-26 19:09 +0000]:

[...]
> because pulseaudio has placed the above file there.

If pulsaudion is installed it runs as a per user session by default.
To prevent starting pulse just

$ echo "autospawn=no" >> $HOME/.pulse/client.conf.

You can now kill the pulseaudio process with out restarting it
again. See alsa /usr/share/doc/pulseaudio/README.Debian.

To make this as a default I have this in my shell login script
(i.e .zlogin)
echo " Shutdown pulseaudio"
     if [ -x /usr/bin/pulseaudio ]; then
        if [ "$(pulseaudio --check 2>/dev/null)" = 0 ]; then
           pulseaudio -k
        else
           echo " No pulsedaemon found"
        fi
     fi

Elimar
-- 
    .~.
    /V\   L   I   N   U   X
   /( )\ >Phear the Penguin<
   ^^-^^

---

From: Juha Jäykkä <[email-masked]>
Date: Sun, 18 Dec 2016 23:02:35 +0000

> > I think pulseaudio gets started by libasound.so.2 when it parses
> > alsa.conf.d because pulseaudio has placed the above file there.

I think you might have misunderstood the problem. Disabling pulseaudio's 
autospawn does not fix the bug, it merely hides it in many circumstances.

Furthermore, in my case, I actually want to keep autospawn – for those 
programs which actually wants to use pulseaudio. But at the same time, I want  
alsamixer -c0 (and a host of other programs) not to mute my mixer.

Cheers,
Juha

---

From: Elimar Riesebieter <[email-masked]>
Date: Mon, 19 Dec 2016 10:18:56 +0100

* Juha Jäykkä <[email-masked]> [2016-12-18 23:02 +0000]:

> > If pulsaudio is installed it runs as a per user session by default.
> 

I think the only chance to run alsamixer without starting pulse is
to pulseaudio -k and autospawn pulse.

Elimar

---

From: Juha Jäykkä <[email-masked]>
Date: Wed, 21 Dec 2016 21:21:56 +0000

> to pulseaudio -k and autospawn pulse.

Is this not a bug?

Cheers,
Juha

---

From: Elimar Riesebieter <[email-masked]>
Date: Thu, 22 Dec 2016 10:27:02 +0100

> > to pulseaudio -k and autospawn pulse.

Starting pulseaudio automagic is a feature implemented in pulseaudio;-)

Elimar
-- 
  Numeric stability is probably not all that
  important when you're guessing;-)

---

From: Juha Jäykkä <[email-masked]>
Date: Thu, 22 Dec 2016 20:30:56 +0000

> Starting pulseaudio automagic is a feature implemented in pulseaudio;-)

So in short, it's either all or nothing? I.e. if I want *some* programs, which 
are linked against libpulse0, *not* to mess my mixer settings up because 
libpulse0 automagically starts pulseudio even when the program is explicitly 
asked to use something else, my only option is to never allow pulseaudio to 
start, even if for some programs I would actually prefer that?

This brings back memories of security bugs in Windows programs in the 90s 
which were claimed to be features by MS… MS has learned since…

Cheers,
Juha

---

From: Elimar Riesebieter <[email-masked]>
Date: Thu, 22 Dec 2016 22:28:04 +0100

* Juha Jäykkä <[email-masked]> [2016-12-22 20:30 +0000]:

> are linked against libpulse0,

Hmm, are there applications which need pulseaudio to work? I do have
a system which works fine without pulse. You can use pulse to
provide sound in a network which can other sound servers like
jackausio as well...

Elimar

---

From: Juha Jäykkä <[email-masked]>
Date: Thu, 22 Dec 2016 21:30:36 +0000

> > So in short, it's either all or nothing? I.e. if I want *some* programs,
> > which are linked against libpulse0,

There are, but probably best not mentioned aloud lest Stallman smites us. :)

> provide sound in a network which can other sound servers like

Bluetooth audio without pulse..? (Not my usecase, but I think that's not 
doable, is it? My use case is the one where I get the Vengeanceful Avengers of 
Free Software smite me.)

Cheers,
Juha

---

From: Elimar Riesebieter <[email-masked]>
Date: Thu, 22 Dec 2016 22:59:05 +0100

* Juha Jäykkä <[email-masked]> [2016-12-22 21:30 +0000]:

> Bluetooth audio without pulse..?

It works with plain alsa ;-)

Elimar