You are not logged in.

#1 2014-07-16 20:56:55

xorgx3
Member
From: Poland
Registered: 2011-11-29
Posts: 197

Check if audio output is running

Hi,
I want to check if audio output is running for the lightson script(here is a link https://bbs.archlinux.org/viewtopic.php … 9#p1418969 with solution which I want to use).

I am using pulseaudio.

fuser /dev/snd/timer

This command gives me nothing if audio is working or not.

I know, pulseaudio have a GUI where I can find not only if audio is running, but even what app is using it. By i want to know them only for use it to script.

Offline

#2 2014-07-16 23:16:48

emeres
Member
Registered: 2013-10-08
Posts: 1,570

Re: Check if audio output is running

fuser -v /dev/snd/*

Offline

#3 2014-07-17 08:05:02

xorgx3
Member
From: Poland
Registered: 2011-11-29
Posts: 197

Re: Check if audio output is running

This command return always(even if output isn't running) :

$ fuser -v /dev/snd/*
                     USER        PID ACCESS COMMAND
/dev/snd/controlC0:  rlk120     3806 F.... pulseaudio
/dev/snd/controlC1:  rlk120     3806 F.... pulseaudio
/dev/snd/pcmC0D0p:   rlk120     3806 F...m pulseaudio

Offline

#4 2014-07-17 08:27:23

ooo
Member
Registered: 2013-04-10
Posts: 1,638

Re: Check if audio output is running

that command shows if alsa card is being used. If you're using pulseaudio, alsa card will most likely be used by it.

try 'man pacmd' and 'man pactl' for figuring out if pulseaudio is being used.
at least 'pactl list' can show whether sinks are idle or running.

pacmd is also an interactive shell you can use to find out which applications are unsing pa:

pacmd
Welcome to PulseAudio 5.0! Use "help" for usage information.
>>> list-sink-inputs
0 sink input(s) available.
>>>

neither commands are really that great for scripting, but I hope this help

Last edited by ooo (2014-07-17 08:27:51)

Offline

#5 2014-07-17 09:15:29

emeres
Member
Registered: 2013-10-08
Posts: 1,570

Re: Check if audio output is running

The playback devices are of interest. If pcmC0D0p shows up in fuser output, it means the first playback sound card first device is occupied by pulseaudio.
I probably misunderstood your intent here. Should you only be interested if the pulseaudio is processing and outputting audio samples, I would try to grab one of the master meters [data] that pulseaudio uses.
Maybe a better approach would be getting an alsa file pipe before pulseaudio, then monitoring that pipe if there are any samples. But it corresponds to audio input from alsa to pulseaudio.
You could also try to cat the playback device, in your case /dev/snd/pcmC0D0p. If the exit code is 1, then there is no output and cat exits immediately. Should cat [try to] read the device, then there is audio output, after audio stops it also exits with code 1. Thing is, it may also sustain cat while the outputted samples are zero, so it may be insufficient for your case.
So what ooo suggests might your best bet right now, or try to look for pulseaudio spectrum analyzers or similar and tap the signal there.

Last edited by emeres (2014-07-17 10:20:11)

Offline

#6 2014-07-17 16:39:14

xorgx3
Member
From: Poland
Registered: 2011-11-29
Posts: 197

Re: Check if audio output is running

Hmm, I need more time to configure it in proper way. Until this time I leave this topic as not solved yet.

Offline

Board footer

Powered by FluxBB