[pulseaudio-discuss] "Speaker saver" module to notify when sound is needed and when not
tanuk at iki.fi
Mon Nov 7 13:38:41 PST 2011
On Mon, 2011-11-07 at 10:23 +0000, Colin Guthrie wrote:
> 'Twas brillig, and Ben Bucksch at 07/11/11 02:55 did gyre and gimble:
> > On 07.11.2011 03:34, Ben Bucksch wrote:
> >> Is there a module that can run a (configurable) shell command when
> >> * sound output is needed, i.e. an application plays a sound, and
> >> it's not muted
> >> * no sound output is needed anymore, after a certain configurable
> >> timeout, e.g. no sound played in the last 120 minutes
> >> ? Effectively, this would work exactly like a screen saver, just for
> >> sound, not for the screen/input.
> > FYI: Ford_Perfect pointed me to
> > http://0pointer.de/blog/projects/device-reservation.html
> > http://git.0pointer.de/?p=reserve.git;a=blob_plain;f=reserve.txt
> > (if anybody has better solutions, please let me know)
> Ahh interesting. Yeah you could use this to know when PA is playing
> sound. All you'd need is a simple dbus integration and you could write
> your app accordingly completely separate of PA.
> The other option is to get your hands dirty, write a module in PA and
> use that.
I don't see why server-side solution would be better in this case. The
sink status (suspended / idle / running) is available to clients, and
there will be notifications when the state changes.
> I think other people may have posted similar modules in the past, but it
> won't be too difficult to do it either way - module-suspend-on-idle will
> have pretty much all the infrastructure you'd need.
> Of course some apps misbehave (e.g. flash) and keep their streams around
> even when they are not playing and thus may need some kind of special
> handling here that you probably won't get via dbus or idle status.
What's the problem with flash? Does it play silence even when no flash
animations/videos are running in the browser? Detecting that would
require monitoring the live stream data...
Ben, you seemed to think that having mplayer on pause running all the
time would have this same problem. I don't think that's the case -
mplayer should set the stream to "corked" state while paused. Corked
streams don't keep the sink in the "running" state, so just monitoring
the sink state should be enough.
(The device reservation solution might also work well, and if it does,
it's probably the easiest solution to implement, at least if you're
already familiar with D-Bus.)
More information about the pulseaudio-discuss