I have a media center (Asrock Nvidia ION330) server with Ubuntu 16.04. It runs Kodi and is connected to my TV through an HDMI cable. The PC has more audio outputs, like stereo jack and iec958 connectors that I have connected to an Hi-Fi Amplifier.
I want to add a new functionality to my media center, a2dp bluetooth receiver. Actually is very simple, just pairing the device with bluetoothctl and you are done, but I don't want the music plays through HDMI, because I don't want to hear the music in the TV.
With pavucontrol is very simple to change the profile of my sound card and output the music through stereo jack or iec958, but I want to do this in headless mode. I don't want to take the keyboard, launch pavucontrol and change the profile every time I want to hear music.
I have a daemon script that detects when my phone is paired and tries to change the profile of the sound card with pactl but, for some unknown reason, my soundcard ignores the command.
The command I am trying is: "pactl set-card-profile 0 output:iec958-stereo" I am running with the same user that runs kodi, and the command doesn't fire any error. Even more, if I look at sound card active profile after running the command, I can see that the profile has changed, but the music keeps playing through hdmi.
I don't know why pavucontrol works all the time but pactl doesn't
EDIT: I have found a workaround, but doesn't fix the original problem. I have Music Player Daemon running in the same server, it has its own instance of pulseaudio running, with a different sound card profile. MPD plays through SPDIF while Kodi plays through HDMI. All I have done is to add mpd user to lp group in order to mpd user can see bluetooth resources. Now, when I pair my phone, mpd's pulseaudio session can see the bluetooth source and it plays through SPDIF too. Something rare is that kodi's pulseaudio session doesn't see bluetooth source anymore, but it doesn't bother me.
pactl list sinks
to see the details of the available sinks, andpactl info
should tell you the current default sink. – Tom Yan Aug 10 '17 at 12:36module-stream-restore
, or at least load it with its parameterrestore_device
set to false. You may either need to restart the programs or move the streams of them manually move the streams. Pavucontrol move active streams for you when you change default sink with it, while pactl/pacmd does not. – Tom Yan Aug 10 '17 at 12:42pactl list sink-inputs
should tell you the sink each active stream is using. – Tom Yan Aug 10 '17 at 12:44