From: Takashi Iwai Subject: Re: View alsa-lib plugins setup for any app? Date: Wed, 22 Oct 2008 08:39:34 +0200 Message-ID: References: <48FD3070.7080406@audioscience.com> <200810220955.01218.linux@audioscience.com> 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 BDCA724451 for ; Wed, 22 Oct 2008 08:39:51 +0200 (CEST) In-Reply-To: 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: Eliot Blennerhassett Cc: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org At Wed, 22 Oct 2008 07:58:45 +0200, I wrote: > > At Wed, 22 Oct 2008 09:55:01 +1300, > Eliot Blennerhassett wrote: > > > > On Tuesday 21 October 2008 19:34:49 Takashi Iwai wrote: > > > Sorry, I don't understand well your question. Do you want to see the > > > alsa-plugin chain of a running application from the outside, > > > > Yes. Basically see something that looks like the result of "aplay -v", but for > > a running app from the outside. > > > > E.g. to see if the app is using dmix, plughw etc, what parameters the app sees > > vs how the card is accessed. > > > > Best if this info was available like the proc files for the driver, but if it > > required running the app in a special context (debugger-like or LD_PRELOAD) > > that would probably still be useful. > > > > The app should not have to be recompiled. > > Well, right now it's almost impossible because the alsa-lib stuff is > purely a user-space thing and not exposed to anywhere else. > > An easy hack is to add snd_pcm_dump() to snd_pcm_hw_params() in > alsa-lib (better with a conditional check, such as a certain > environment variable). But this function may be called recursively, > it should have a certain re-entrace check. ... like the patch below. Takashi diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c index 59e433f..1c89d7e 100644 --- a/src/pcm/pcm.c +++ b/src/pcm/pcm.c @@ -814,11 +814,27 @@ int snd_pcm_hw_params_current(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) int snd_pcm_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) { int err; + static int enter; + assert(pcm && params); + enter++; err = _snd_pcm_hw_params(pcm, params); if (err < 0) - return err; + goto out; err = snd_pcm_prepare(pcm); + out: + enter--; + if (!err && !enter) { + const char *v = getenv("ALSA_PCM_DUMP"); + if (v && *v) { + snd_output_t *log; + err = snd_output_stdio_attach(&log, stderr, 0); + if (!err) { + snd_pcm_dump(pcm, log); + snd_output_close(log); + } + } + } return err; }