[pulseaudio-discuss] Killing Parec?

Colin Guthrie gmane at colin.guthr.ie
Wed Jul 14 00:48:34 PDT 2010


'Twas brillig, and Murtaza Munaim at 14/07/10 07:52 did gyre and gimble:
> Hey guys. I had a inquiry into parec, the pulse audio recording tool.
> 
> So in my current setup, I have a sink setup by the following:
> pactl load-module module-null-sink sink_name=$port
> 
> Now, I have firefox feeding into this sink, and I have parec fetching
> data from this sink and piping it to a script I have running that does
> some data manipulation. Now, when firefox dies, it stops feeding data
> into the sink, and thus parec has no more use. I want parec to die when
> the sink is of no more use. Is this parec's default behavior? Do I need
> to add something? Is there some configuration so that when a sink
> becomes indefinitely empty/unusable, the parec process will die aswell?

As far as I'm aware, there is no way to do this. I can think of a few
different ways to make it happen, but they will basically involve
putting the parec process into the background in your script and then
looping and checking pactl or pacmd list to see how many inputs the sink
has and when it drops to 0, it kills the parec process.

#!/bin/bash

trap 'kill $(jobs -p)' EXIT

(parec blah | blah)&

while (/bin/true); do
	num_clients=`pacmd list-sinks | grep "name: <$port>" -A 30 | grep "used
by" | awk '{ print $3 }'`
	if [ "$num_clients" = "0" ]; then
		exit;
	fi
done



Or something like that... the above is totally untested!


-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]




More information about the pulseaudio-discuss mailing list