* Detect when sound card is in use
@ 2009-04-28 19:16 Claus Ilginnis
2009-04-29 6:40 ` Takashi Iwai
0 siblings, 1 reply; 3+ messages in thread
From: Claus Ilginnis @ 2009-04-28 19:16 UTC (permalink / raw)
To: alsa-devel
Hi everyone,
I have a problem and I dont't know where to ask my questions anymore, so
I hope this mailing list can help me make progress with my problem....
I have a speaker set connected to an USB-Power-Plug (by which I can turn
the speakers on and off )
Now I want to detect, when the soundcard is in use and when not.
(to turn the speakers on when needed...)
(I am a C++ programmer so I can mess some things up)
So my question is:
Which way is best to detect wheather my sound card is in use or not ?
Is there a general overview/documentation of the sound kernel modules
which describes the general relationship between them ?
What would you do ?
PLEASE help !
-
Mit freundlichen Grüßen / Best regards
Claus Ilginnis
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Detect when sound card is in use
2009-04-28 19:16 Detect when sound card is in use Claus Ilginnis
@ 2009-04-29 6:40 ` Takashi Iwai
2009-04-29 7:16 ` Clemens Ladisch
0 siblings, 1 reply; 3+ messages in thread
From: Takashi Iwai @ 2009-04-29 6:40 UTC (permalink / raw)
To: Claus Ilginnis; +Cc: alsa-devel
At Tue, 28 Apr 2009 21:16:26 +0200,
Claus Ilginnis wrote:
>
>
> Hi everyone,
>
> I have a problem and I dont't know where to ask my questions anymore, so
> I hope this mailing list can help me make progress with my problem....
>
> I have a speaker set connected to an USB-Power-Plug (by which I can turn
> the speakers on and off )
>
> Now I want to detect, when the soundcard is in use and when not.
> (to turn the speakers on when needed...)
> (I am a C++ programmer so I can mess some things up)
>
> So my question is:
> Which way is best to detect wheather my sound card is in use or not ?
> Is there a general overview/documentation of the sound kernel modules
> which describes the general relationship between them ?
> What would you do ?
The easiest way would be to check the status of device files, such as
/dev/snd/*, whether any process opens it, e.g. via lsof command.
But, this doesn't cover the case like an app such as a mixer applet
which keeps opening the device but access only occasionally.
Takashi
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Detect when sound card is in use
2009-04-29 6:40 ` Takashi Iwai
@ 2009-04-29 7:16 ` Clemens Ladisch
0 siblings, 0 replies; 3+ messages in thread
From: Clemens Ladisch @ 2009-04-29 7:16 UTC (permalink / raw)
To: Takashi Iwai; +Cc: alsa-devel, Claus Ilginnis
Takashi Iwai wrote:
> Claus Ilginnis wrote:
> > I have a speaker set connected to an USB-Power-Plug (by which I can turn
> > the speakers on and off )
> >
> > Now I want to detect, when the soundcard is in use and when not.
> > (to turn the speakers on when needed...)
> >
> > Which way is best to detect wheather my sound card is in use or not ?
> > Is there a general overview/documentation of the sound kernel modules
> > which describes the general relationship between them ?
> > What would you do ?
>
> The easiest way would be to check the status of device files, such as
> /dev/snd/*, whether any process opens it, e.g. via lsof command.
This would require polling.
> But, this doesn't cover the case like an app such as a mixer applet
> which keeps opening the device but access only occasionally.
I guess the mixer doesn't matter as long as nothing is playing, so it
would be enough to monitor /dev/snd/pcm*.
The easiest way would be to wrap your playback application in a script,
but this works only if that is the only application that plays sounds.
If all your applications use the ALSA API (and not OSS), you could
write a filter plugin that just passes through all requests to the
actual device and switches the power plug in the open/close callbacks.
Best regards,
Clemens
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-04-29 7:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-28 19:16 Detect when sound card is in use Claus Ilginnis
2009-04-29 6:40 ` Takashi Iwai
2009-04-29 7:16 ` Clemens Ladisch
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.