It is currently Tue May 21, 2013 1:56 pm

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: How to programmatically test whether sound is playing?
PostPosted: Sat Apr 12, 2008 10:45 pm 
Experienced Zenwalker
Experienced Zenwalker

Joined: Mon Mar 03, 2008 7:02 pm
Posts: 227
hey all,

I'm attempting to modify a small C program to test for whether or not sound is playing. The behavior of the function I'm looking for is that it would query the system somehow, then if the system is playing sounds (ie, music) then it would return 1, or 0 otherwise.

I'm a C novice and a linux novice as well, so I'm not really sure how to do this or where to start. I'm guessing that I should look in the /proc directory, or possibly something like /dev/dsp?

Thanks for helping!


 Profile Send private message  
 
 Post subject: Re: How to programmatically test whether sound is playing?
PostPosted: Sat Apr 12, 2008 11:23 pm 

I think you can play with what's under /dev/snd, /dev/dsp and lsof. In my system if audacious is playing through alsa I can do:
Code:
george[~]$ lsof /dev/snd/pcmC0D0p
COMMAND    PID   USER   FD   TYPE DEVICE SIZE NODE NAME
audacious 1579 george  mem    CHR  116,5      6240 /dev/snd/pcmC0D0p
audacious 1579 george   12u   CHR  116,5      6240 /dev/snd/pcmC0D0p

and if it's playing through the included OSS driver in audacious-crossfader I get
Code:
george[~]$ lsof /dev/dsp
COMMAND    PID   USER   FD   TYPE DEVICE SIZE NODE NAME
audacious 1654 george   11u   CHR   14,3      7372 /dev/sound/dsp


  
 
 Post subject: Re: How to programmatically test whether sound is playing?
PostPosted: Sat Apr 12, 2008 11:39 pm 
Experienced Zenwalker
Experienced Zenwalker

Joined: Mon Mar 03, 2008 7:02 pm
Posts: 227
ah nice! That seems to work for me too, I'll see what I can do with it.


 Profile Send private message  
 
 Post subject: Re: How to programmatically test whether sound is playing?
PostPosted: Sun Apr 13, 2008 1:24 pm 
Experienced Zenwalker
Experienced Zenwalker

Joined: Mon Mar 03, 2008 7:02 pm
Posts: 227
I've done i!

I patched xautolock to check for sound, and preliminary tests are looking good. I need some more testing and whatnot, but so far things are looking up.


 Profile Send private message  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


 Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
 
cron