Bug#593952: hotplugging devices doesn't work completely if PA was started during earlier X-session

Alexander Kurtz kurtz.alex at googlemail.com
Sun Aug 22 15:17:38 UTC 2010


Package: pulseaudio
Version: 0.9.21-3
Severity: normal

Hi,

To work around #593746 [1] I changed /usr/bin/start-pulseaudio-x11 like
this

	$ egrep -v '(^#|^$)' /usr/bin/start-pulseaudio-x11
	set -e
	[ -z "$PULSE_SERVER" ]
	if [ "$XAUTHORITY" ]; then
		cp "$XAUTHORITY" "$HOME/.Xauthority"
		export XAUTHORITY="$HOME/.Xauthority"
	fi
	/usr/bin/pulseaudio --start "$@"
	if [ x"$DISPLAY" != x ] ; then
	    /usr/bin/pactl load-module module-x11-publish "display=$DISPLAY" > /dev/null
	    /usr/bin/pactl load-module module-x11-cork-request "display=$DISPLAY" > /dev/null
	    if [ x"$SESSION_MANAGER" != x ] ; then
		/usr/bin/pactl load-module module-x11-xsmp "display=$DISPLAY session_manager=$SESSION_MANAGER" > /dev/null
	    fi
	fi

and to work around #593881 [2] I executed this

	$ sudo adduser $USERNAME audio
	Adding user `alexander' to group `audio' ...
	Adding user alexander to group audio
	Done.

I verified that both workarounds do their job:

 * PA now stores it's properties to the X root window even if it was 
   started during an earlier X-session:
   
	$ ps -C pulseaudio -C x-session-manager -f
	UID        PID  PPID  C STIME TTY          TIME CMD
	1000     20966     1  0 16:19 ?        00:00:00 /usr/bin/pulseaudio --start
	1000     21109 21076  0 16:20 ?        00:00:00 x-session-manager
	$ xprop -root | grep -q ^PULSE_SERVER
	$ echo $?
	0

 * and I can use a hotplugged audio device instantly:
 
	$ aplay -l
	**** List of PLAYBACK Hardware Devices ****
	[ ... my internal sound card ... ]
	card 1: default [C-Media USB Headphone Set  ], device 0: USB Audio [USB Audio]
	  Subdevices: 1/1
	  Subdevice #0: subdevice #0

So theoretically I should now be able to just plug my USB sound card in,
fire up `gnome-volume-control' and switch the output to the new sound
card.

However this actually only works if I'm in the same X-session where PA
was started. During any later X-session PA will recognize the new card
correctly but fail to detect its sinks and sources:

	$ pacmd list-cards
	Welcome to PulseAudio! Use "help" for usage information.
	>>> 2 card(s) available.
	    index: 1
		[ ... my internal sound card ... ]
	    index: 3
		name: <alsa_card.usb-0d8c_C-Media_USB_Headphone_Set-00-default>
		driver: <module-alsa-card.c>
		owner module: 24
		properties:
			alsa.card = "1"
			alsa.card_name = "C-Media USB Headphone Set  "
			alsa.long_card_name = "C-Media USB Headphone Set   at usb-0000:00:0b.0-5, full speed"
			alsa.driver_name = "snd_usb_audio"
			device.bus_path = "pci-0000:00:0b.0-usb-0:5:1.0"
			sysfs.path = "/devices/pci0000:00/0000:00:0b.0/usb2/2-5/2-5:1.0/sound/card1"
			udev.id = "usb-0d8c_C-Media_USB_Headphone_Set-00-default"
			device.bus = "usb"
			device.vendor.id = "0d8c"
			device.vendor.name = "C-Media Electronics, Inc."
			device.product.id = "000c"
			device.product.name = "Audio Adapter"
			device.serial = "0d8c_C-Media_USB_Headphone_Set"
			device.form_factor = "headphone"
			device.string = "1"
			device.description = "Audio Adapter"
			module-udev-detect.discovered = "1"
			device.icon_name = "audio-headphones-usb"
		profiles:
			output:analog-stereo: Analog Stereo Output (priority 6000)
			output:analog-stereo+input:analog-mono: Analog Stereo Output + Analog Mono Input (priority 6001)
			output:iec958-stereo: Digital Stereo Duplex (IEC958) (priority 5500)
			output:iec958-stereo+input:analog-mono: Digital Stereo (IEC958) Output + Analog Mono Input (priority 5501)
			input:analog-mono: Analog Mono Input (priority 1)
			off: Aus (priority 0)
		active profile: <output:analog-stereo+input:analog-mono>
	>>> $

So I thought, maybe it's another environmental variable (like in
#593746[1]) which isn't correct anymore during the later X-session, so I
did this:

	$ pulseaudio --kill; sleep 1; env --ignore-environment DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY HOME=$HOME start-pulseaudio-x11
	$ tr '\0' '\n' < /proc/`pidof pulseaudio`/environ
	HOME=/home/alexander
	DISPLAY=:0.0
	XAUTHORITY=/home/alexander/.Xauthority
	PWD=/home/alexander
	LD_BIND_NOW=1

But surprisingly hotplugging worked. So it can't be some environmental
variable which has changed.

My next thought was that maybe the connection to some session service
like Dbus wasn't valid anymore during the new X-session. So I logged
out of GNOME and logged into a VT and restarted pulseaudio:

	$ pulseaudio --kill; sleep 1; pulseaudio --start
	$

But even after several logouts/logins to the VT, hotplugging still
worked, although PA was started during an earlier session and there were
no additional services running:

	$ ps -fu 1000
	UID        PID  PPID  C STIME TTY          TIME CMD
	1000     24030     1  0 16:51 ?        00:00:00 pulseaudio --start
	1000     24405 24384  0 16:52 tty2     00:00:00 -bash
	1000     24559 24405  0 16:52 tty2     00:00:00 ps -fu 1000

Since I'm really running out of ideas now, I'm filing this bug report.
Maybe someone out there is more clever than I am.

Please report if you can confirm that hotplugging doesn't work
completely (i.e. including sinks/sources) if PA was started during an
earlier X-session, or if this is some problem which only occurs under
rare circumstances.

If you need more information/additional tests, just ask!

Thanks for your work!

Alexander Kurtz

[1] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=593746
[2] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=593881


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part
URL: <http://lists.alioth.debian.org/pipermail/pkg-pulseaudio-devel/attachments/20100822/b05f4e39/attachment.pgp>


More information about the pkg-pulseaudio-devel mailing list