Bug 102987 - The "pacmd set-default-sink" command doesn't work anymore (as of v11.x)
Summary: The "pacmd set-default-sink" command doesn't work anymore (as of v11.x)
Status: RESOLVED INVALID
Alias: None
Product: PulseAudio
Classification: Unclassified
Component: tools (show other bugs)
Version: unspecified
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: pulseaudio-bugs
QA Contact: pulseaudio-bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-09-25 22:56 UTC by Xavion
Modified: 2018-12-07 21:08 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments
Working in v10.0 (418 bytes, text/plain)
2017-09-25 22:56 UTC, Xavion
Details
Failing in v11.1 (418 bytes, text/plain)
2017-09-25 22:57 UTC, Xavion
Details
Sinks list (v11.1) (5.27 KB, text/plain)
2017-10-06 00:27 UTC, Xavion
Details
Verbose output for v10.0 (success) (359.27 KB, text/plain)
2017-10-12 23:55 UTC, Xavion
Details
Verbose output for v11.1 (failure) (370.67 KB, text/plain)
2017-10-12 23:55 UTC, Xavion
Details

Description Xavion 2017-09-25 22:56:22 UTC
Created attachment 134480 [details]
Working in v10.0

I have two sinks.  Switching between them via "pacmd set-default-sink" was working in v10.0.  Unfortunately, as of v11.x, nothing happens.  I have attached the relevant log files.
Comment 1 Xavion 2017-09-25 22:57:32 UTC
Created attachment 134481 [details]
Failing in v11.1
Comment 2 Nils Alex 2017-10-04 09:33:42 UTC
I have the same problem:

nils@linux ~ % pactl list sinks | grep "Name:"
	Name: alsa_output.pci-0000_00_03.0.hdmi-stereo
	Name: alsa_output.pci-0000_00_1b.0.analog-stereo
nils@linux ~ % pactl info | grep "Default Sink:"
Default Sink: alsa_output.pci-0000_00_1b.0.analog-stereo
nils@linux ~ % pactl set-default-sink alsa_output.pci-0000_00_03.0.hdmi-stereo
nils@linux ~ % pactl info | grep "Default Sink:"
Default Sink: alsa_output.pci-0000_00_1b.0.analog-stereo
nils@linux ~ %
Comment 3 Nils Alex 2017-10-04 09:34:35 UTC
nils@linux ~ % pacmd --version
pacmd 11.1
Compiled with libpulse 11.1.0
Linked with libpulse 11.1.0
Comment 4 Nils Alex 2017-10-04 09:35:11 UTC
Sorry, wrong command.

nils@linux ~ % pactl --version
pactl 11.1
Compiled with libpulse 11.1.0
Linked with libpulse 11.1.0
Comment 5 Nils Alex 2017-10-05 14:11:41 UTC
This seems to be not a bug but desired behaviour. After pa_core_set_configured_default_sink() has set up the new default sink, the function pa_core_update_default_sink() is called.

If your new sink is not linked (that is, not SUSPENDED, IDLE or RUNNING) or if it is linked but all outputs are unavailable, this function will set a "better" sink as default sink.

In my case, the new sink is an HDMI sink and I tried the command while not being connected to any HDMI device. pa_core_set_configured_default_sink() did what it should do, but afterwards pa_core_update_default_sink() set the default sink to my old one.

For my use case this behaviour is actually nice, but maybe one should be able to set sinks without available output as default if one really wants to? At least I can see why this could be useful.


Could you post your output from

pactl list sinks

?
Comment 6 Nils Alex 2017-10-05 14:16:57 UTC
This new logic has been introduced with
https://github.com/pulseaudio/pulseaudio/commit/6b348961304903483aa78d4ddc1fd036ef75a7cb#diff-896600d0676bd6ea79841affee62f5e0
and updated since, so this is why the behaviour was different before.
Comment 7 Xavion 2017-10-06 00:27:23 UTC
Created attachment 134697 [details]
Sinks list (v11.1)
Comment 8 Xavion 2017-10-06 00:29:37 UTC
Thanks for the explanation, but I *really don't* agree that this new behaviour is an improvement.

I have attached the output of "pactl list sinks".  As you can see, the first one is merely 'suspended'.  It connects to my TV via HDMI.  The second one connects to my PC speakers via analogue headphone jack.

This wasn't a problem for v10.0: it was happy to switch from sink #1 to #0 when the latter was 'suspended'.  Unfortunately, even when the TV is on and the relevant HDMI input is chosen, v11.x still thinks it's no good!

I'd have thought it'd be the other way around if anything.  Shouldn't a HDMI output be considered superior to an analogue headphone jack?

Regardless, there needs to be a way to override this new behaviour (e.g. via a "--force" switch).
Comment 9 Tanu Kaskinen 2017-10-12 16:20:26 UTC
The behaviour that Nils sees is indeed expected. But the behaviour on Xavion's machine is not. PulseAudio sees that HDMI is available and headphones are not. In this situation the HDMI sink should automatically become the default.

Can you attach (use the "Add an attachment" link, don't paste to the comment box) the verbose log of the pulseaudio server? Instructions for getting the log:

1. Disable automatic starting of PulseAudio. If your distro uses
systemd's socket activation to start PulseAudio, run

    systemctl --user --now mask pulseaudio.service pulseaudio.socket

If your distro doesn't do that, put "autospawn = no" to
~/.config/pulse/client.conf.

2. Stop pulseaudio with "killall pulseaudio" (the previous systemctl
command might have stopped it already, though).

3. Start pulseaudio in a terminal with verbose logging:

    pulseaudio -vv

4. Run "pactl set-default-sink alsa_output.pci-0000_00_03.0.hdmi-stereo-extra1"

5. Stop pulseaudio with ctrl-c.

6. To return things back to normal, run

    systemctl --user unmask pulseaudio.service pulseaudio.socket

if you masked the service before. And remove the "autospawn = no" line
from client.conf if you added it there.
Comment 10 Tanu Kaskinen 2017-10-12 16:23:44 UTC
I'll mark this as a release blocker bug, since this is pretty serious regression.
Comment 11 Xavion 2017-10-12 23:55:00 UTC
Created attachment 134823 [details]
Verbose output for v10.0 (success)
Comment 12 Xavion 2017-10-12 23:55:51 UTC
Created attachment 134824 [details]
Verbose output for v11.1 (failure)
Comment 13 Xavion 2017-10-12 23:57:46 UTC
It looks like I got this around the wrong way slightly: v11.x insists on the HDMI sink (#0) always being the default.

Therefore, I have modified your test case slightly: for step 4, I issued "pactl set-default-sink alsa_output.pci-0000_00_1b.0.analog-stereo" instead.

Also, I added an extra step before and after it ("pacmd list-sinks | grep "* index: ") to check on the status.

I have attached the verbose log files from both v10.0 and v11.1.  Let me know if any further testing is required.
Comment 14 Tanu Kaskinen 2017-10-15 14:14:32 UTC
(In reply to Xavion from comment #13)
> It looks like I got this around the wrong way slightly: v11.x insists on the
> HDMI sink (#0) always being the default.

Ok, this doesn't look like a PulseAudio bug then. I'm removing the release blocker status, and may close the bug later. Since alsa reports that headphones are unplugged, PulseAudio is working as designed when it doesn't set headphones as the default device.

If you don't have headphones plugged in, why do you want pulseaudio to play audio to headphones?

If you actually do have headphones plugged in, then this is a bug in the kernel driver or the hardware is defective. In this case you can work around the problem by removing this part from /usr/share/pulseaudio/alsa-mixer/paths/analog-output-headphones.conf:

[Jack Front Headphone]
required-any = any

That change will be overwritten when PulseAudio is upgraded, however.
Comment 15 Xavion 2017-10-15 22:06:56 UTC
Nah, it definitely is a bug in PulseAudio v11.x.

You say the "Headphones" port is unplugged, but what about the "Line Out" one?  It's permanently connected to my desktop speakers!

To me, both sinks are equally important.  It just depends on whether I'm sitting at my desk or in my recliner (using the TV as the monitor).

I need to be able to switch between them at will, regardless of whether PulseAudio thinks it's a good idea.

For this reason, please either fix the bug (to check the "Line Out" port status) or implement a "--force" (override) switch.
Comment 16 Tanu Kaskinen 2017-10-20 19:32:20 UTC
(In reply to Xavion from comment #15)
> You say the "Headphones" port is unplugged, but what about the "Line Out"
> one?  It's permanently connected to my desktop speakers!

Ok, so you don't want to use headphones. Why are headphones selected then instead of line out? Did PulseAudio select the headphones automatically (it should not do that) or did you manually select that port?

Do things start to work as expected if you switch the port to line out? You can do that with pavucontrol or with this command:

pactl set-sink-port alsa_output.pci-0000_00_1b.0.analog-stereo analog-output-lineout
Comment 17 Xavion 2017-10-20 23:18:43 UTC
Yes, setting the port to "Line Out" manually first does fix the problem.  I can then switch the default sink back and forth between #0 and #1 as usual.

Unfortunately, PulseAudio v11.x doesn't remember the port setting between sessions.  When I kill and relaunch it, "Headphones" is once again selected.

For some reason, though, even when this is the case, the sound still comes out of the desktop speakers (meaning that "Line Out" is active after all).
Comment 18 Xavion 2017-10-20 23:58:49 UTC
It's okay, I've discovered a configuration issue with my "/etc/pulse/default.pa" file.  I had added the following line years ago (for my previous motherboard): "set-sink-port 1 analog-output-headphones"

This wasn't a problem with PulseAudio v10.3 and lower: it only became apparent with the new "smart-sink-selection" code present in v11.x.  Anyway, I'm very sorry to have wasted everyone's time on this!
Comment 19 Xavion 2017-10-21 00:14:04 UTC
Sorry, "v10.3" should obviously have been "v10.0".  On my Arch Linux system, the latest v10 package was "v10.0-3".  That's where I got the '3' from; I'm not going totally crazy. :-)

Anyway, this extra comment provides me with an opportunity to mark the bug as 'invalid'.  Thanks again for all of the time everyone spent on it.
Comment 20 Ghry 2018-12-07 21:08:53 UTC
I have pulseaudio-10.0-2 and its set-default-sink doesn't work :( I tried the "$pactl set-sink-port" which outputs "Failure: Missing implementation" :(

$pactl set-sink-port 1 analog-output-headphones
Failure: Missing implementation

Really need some workaround solution...


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.