LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   how to know who use the sound device (https://www.linuxquestions.org/questions/linux-software-2/how-to-know-who-use-the-sound-device-235441/)

alexrait1 09-26-2004 01:01 PM

how to know who use the sound device
 
Hello,
I develop a small application that has to know in a specific time, whether someone writes to the /dev/dsp or in other words, emits sounds.

Now, contrary to windows, in linux there is no restriction for wrting at the same time to the same file, namely, you can have a file opened with two different applications for write purposes.

The question is how can I track it, at least to know if there is an application which uses the sound card.
If I run cat /dev/dsp - it doesn't show anything though I easily produce sound with
echo "something" > /dev/dsp
(I tried get the same effect as with cat /dev/mouse - where every movement of the mouse, prints jibbrish).

Any Ideas?

hw-tph 09-26-2004 02:08 PM

If an application has a file open it will show in the output of the lsof command. My Alsa audio device is /dev/snd/pcmC0D0p so if I want to check if an application is using it I can type lsof /dev/snd/pcmC0D0p, and lo and behold:
Code:

root@royne:~# lsof /dev/snd/pcmC0D0p
COMMAND    PID USER  FD  TYPE DEVICE SIZE    NODE NAME
beep-medi 27820  hw  mem    CHR 116,16      1311306 /dev/snd/pcmC0D0p
beep-medi 27820  hw  12u  CHR 116,16      1311306 /dev/snd/pcmC0D0p

I am using Beep Media Player (real executable name "beep-media-player") to play some tunes right now so it showing up is right. If I hit the stop button so it stops playing, it doesn't show up in the lsof output.


Håkan


All times are GMT -5. The time now is 03:19 AM.