[Thinlinc-technical] tlclient on Linux: pulseaudio sink inputs not allowed to move to different sink?

Jens Maus j.maus at hzdr.de
Fri Jan 17 14:20:04 CET 2014


Hi,

I am replying to myself since we have found a workaround for the problem I was reported in here yesterday and it might be interested if someone is bumping into the same problem:

While moving the sink input generated by ThinLinc to another output sink seems not to be possible because it is flagged with DONT_MOVE, one can generate a NULL output sink and a loopback input sink an connect them. That means, you have to add the following lines to your /etc/pulse/default.pa file:

— cut here — 
load-module module-stream-restore restore_device=false
load-module module-null-sink sink_name="stream"
load-module module-loopback source="stream.monitor" latency_msec=1
set-default-sink 0
— cut here — 

If you setup your pulseaudio installation like that thinlinc will connect to sink 0 stream sink which can then freely be moved to any output sink of your system via the shell script listed in my first mail.

While this workaround seems to solve our problem and we can perfectly switch to any audio output destination during runtime, I am still curious to find out why the pulseaudio connection initiated by ThinLinc will end up having a DONT_MOVE flag while others (e.g. from xfreerdp) are freely movable per default. Perhaps ThinLinc could be changed to also allow moving the audio stream (not ending up with DONT_MOVE flag). This would then allow to also move audio output to another device at any time.

best regards,
jens

Am 16.01.2014 um 15:10 schrieb Jens Maus <j.maus at hzdr.de>:

> Hello ThinLincer,
> 
> at the moment we are playing around in optimizing our thin clients which are based on an adapted “thinstation” Linux version optimized for the intel NUC hardware (see https://github.com/hzdr/thinstation). We are currently trying to implement auto-switching of audio output devices depending on which audio output source is currently plugged in (headphones, external usb speaker, etc.). While switching of audio output sources seem to work fine when using e.g. “xfreerdp” and its integrated pulseaudio support, we are not able to move the pulse audio audio sink input streams generated by ThinLinc to another audio output using the following script:
> 
> — cut here —
> #!/bin/bash
> #
> # a shell script that sets a new pulseaudio sink as the default one. In addition,
> # it will move all existing streams to the new default sink using "move-sink-input"
> #
> 
> if [ -z "$1" ]; then
>    echo "Usage: $0 <sinkId/sinkName>" >&2
>    echo "Valid sinks:" >&2
>    pactl list short sinks >&2
>    exit 1
> fi
> 
> newSink="$1"
> pactl list short sink-inputs | while read stream; do
>    streamId=$(echo $stream | cut -d ' ' -f1)
>    echo "moving stream ${streamId} to ${newSink}"
>    pactl move-sink-input "${streamId}" "${newSink}"
> done
> 
> pactl set-default-sink "${newSink}”
> — cut here — 
> 
> The main point of that script is, that it moves sink input streams via “pactl move-sink-input” to another output sink (e.g. the headphones). As said, this seem to work fine for streams that are directly generated on the thin client (e.g. via ‘cat /dev/urandom | pacat’ or via xfreerdp connections), but streams generated via ThinLinc cannot be moved and are rejected with an “invalid argument” error message.
> 
> After some investigation, it seems that sink inputs generated via thinlinc are not movable as they carry the DONT_MOVE flag. You can see the output of list-sink-inputs here:
> 
> — cut here — 
> fwpnuc33:~$ pacmd list-sink-inputs
>>>> 1 sink input(s) available.
>    index: 0
> 	driver: <protocol-native.c>
> 	flags: DONT_MOVE 
> 	state: CORKED
> 	sink: 0 <alsa_output.pci-0000_00_03.0.hdmi-stereo-extra1>
> 	volume: 0: 100% 1: 100%
> 	        0: 0,00 dB 1: 0,00 dB
> 	        balance 0,00
> 	muted: no
> 	current latency: 159,00 ms
> 	requested latency: 24,99 ms
> 	sample spec: s16le 2ch 44100Hz
> 	channel map: front-left,front-right
> 	             Stereo
> 	resample method: (null)
> 	module: 9
> 	client: 0 <ThinLinc Client>
> 	properties:
> 		media.name = "Built-in Audio Digital Stereo (HDMI) for tsuser at fwpnuc33"
> 		media.role = "abstract"
> 		application.name = "ThinLinc Client"
> 		native-protocol.peer = "UNIX socket client"
> 		native-protocol.version = "28"
> 		application.icon_name = "thinlinc-client"
> 		application.process.id = "2534"
> 		application.process.user = "tsuser"
> 		application.process.host = "fwpnuc33"
> 		application.process.binary = "pulseaudio"
> 		application.language = "de_DE.UTF-8"
> 		window.x11.display = ":0.0"
> 		application.process.machine_id = "902a406796be73a15e8f43570000001a"
> 		module-stream-restore.id = "sink-input-by-media-role:abstract”
> — cut here —
> 
> As we are by no means pulseaudio experts we are wondering if there is a possibility to tune the ThinLinc’ own pulseaudio daemon to start so that the local pulseaudio daemon running on the thin client will be allowed to move a sink input. And if so, instructions to do so would be very helpful.
> 
> Furthermore, please note that I even tried to reproduce the same on a standard Ubuntu/Linux system. If you are running a ThinLinc session with some audio output there it is impossible to move the currently playing audio output to another local output device. Thus, even Ubuntu/Linux+ThinLinc seem to suffer from the same problem: You have to reconnect your ThinLinc session if you want to switch audio output devices e.g. to/from your headphones.
> 
> And suggestions?
> 
> best regards,
> jens
> -- 
> Dr. Jens Maus
> Helmholtz-Zentrum Dresden-Rossendorf
> Institute of Radiopharmaceutical Cancer Research
> Department of Positron Emission Tomography
> POB 51 01 19, 01314 Dresden, Germany
> http://www.hzdr.de/ | +49 351 260 2757
> 
> Board of Directors:
> Prof. Dr. Dr. h. c. Roland Sauerbrey,
> Prof. Dr. Dr. h. c. Peter Joehnk,
> VR 1693 beim Amtsgericht Dresden
> 
> (Please note a real name change effective since 5.9.2013.
> Former name: Jens Langner)
> 
> *** Content is authentic only with digital signature  ***
> 
> _______________________________________________
> Thinlinc-technical mailing list
> Thinlinc-technical at lists.cendio.se
> Manage your subscription:
> http://lists.cendio.se/mailman/listinfo/thinlinc-technical

-- 
Dr. Jens Maus
Helmholtz-Zentrum Dresden-Rossendorf
Institute of Radiopharmaceutical Cancer Research
Department of Positron Emission Tomography
POB 51 01 19, 01314 Dresden, Germany
http://www.hzdr.de/ | +49 351 260 2757

Board of Directors:
Prof. Dr. Dr. h. c. Roland Sauerbrey,
Prof. Dr. Dr. h. c. Peter Joehnk,
VR 1693 beim Amtsgericht Dresden

(Please note a real name change effective since 5.9.2013.
Former name: Jens Langner)

*** Content is authentic only with digital signature  ***

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4726 bytes
Desc: not available
URL: <http://lists.cendio.se/pipermail/thinlinc-technical/attachments/20140117/0cf1f7c2/attachment.p7s>


More information about the Thinlinc-technical mailing list