From: Takashi Iwai Subject: Re: Detect when sound card is in use Date: Wed, 29 Apr 2009 08:40:57 +0200 Message-ID: References: <1240946186.6657.8.camel@trex> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id C73CD244CE for ; Wed, 29 Apr 2009 08:40:57 +0200 (CEST) In-Reply-To: <1240946186.6657.8.camel@trex> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: alsa-devel-bounces@alsa-project.org Errors-To: alsa-devel-bounces@alsa-project.org To: Claus Ilginnis Cc: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org 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