[alsa-devel] Assert in pcm_params.c

Takashi Iwai tiwai at suse.de
Wed May 20 08:36:51 CEST 2015


At Tue, 19 May 2015 20:22:50 +0100,
Alan Horstmann wrote:
> 
> On Tuesday 19 May 2015 13:01, Takashi Iwai wrote:
> > At Fri, 1 May 2015 08:36:47 +0100, Alan Horstmann wrote:
> > > A minimal self-contained demo program ('test-format') has been developed
> > > and is attached, that demonstrates the issue 100% on the reporters
> > > machine (HDA-Intel, 6-ch I believe).  The output is:
> > >
> > > root at Xeon:/home/patest# ./test-format
> > > Testing device front
> > > Num channels 6
> > > Testing rate: 22050   Result:...Invalid Sample Rate
> > > Testing rate: 32000   Result:...Invalid Sample Rate
> > > test-format: pcm_params.c:2249: snd1_pcm_hw_params_slave: Assertion `err
> > > >= 0' failed.
> > > Testing rate: 44100   Aborted
> > >
> > > Alsa-info is at:
> > >
> > > http://www.alsa-project.org/db/?f=19dfeee29f73007e61a00a8fabe3c958f7cb8e8
> > >7
> > >
> > > This apparently happens with or without Pulseaudio running, with just the
> > > single 44100 rate, and also with surround devices.  Also, on all current
> > > Debian and Ubuntu - we have focused on Jessie.
> > >
> > > I do not have a machine with similar hardware, so cannot duplicate the
> > > results.
> > >
> > > Any comments, ideas etc would be appreciated.
> >
> > I also can't reproduce this.  So this must be pretty specific to the
> > setup.
> >
> > Could you give the exact condition to trigger the problem?  Also, this
> > happens certainly with the latest alsa-lib?
> 
> Thanks for taking a look.  Just compiling and running that test program, on 
> the reporter's machine, which has some sort of multi-channel HDA-Intel, is 
> 100% reproducible. The Alsa-lib must be the one provided by Debian Jessie 
> (which was released 25.4.2015); 1.0.28 I think.  Does the Alsa-info give 
> enough details - I can ask any specific questions.
> 
> However, Raymond seems to have some ideas of a possible cause, in connection 
> with arbitrary period size and softvol; is that plausible?

Possibly, but I wonder why I couldn't see it when I tried with
different module options.

In anyway, the fix would be simple, the patch like below.  Could you
check whether it actually fixes your issue?


thanks,

Takashi

---
diff --git a/src/pcm/pcm_params.c b/src/pcm/pcm_params.c
index 6e57904e445b..1d667a583151 100644
--- a/src/pcm/pcm_params.c
+++ b/src/pcm/pcm_params.c
@@ -2244,9 +2244,11 @@ int snd_pcm_hw_params_slave(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
 	snd_pcm_hw_params_t slave_params;
 	int err;
 	err = sprepare(pcm, &slave_params);
-	assert(err >= 0);
+	if (err < 0)
+		return err;
 	err = schange(pcm, params, &slave_params);
-	assert(err >= 0);
+	if (err < 0)
+		return err;
 	err = sparams(pcm, &slave_params);
 	if (err < 0)
 		cchange(pcm, params, &slave_params);


More information about the Alsa-devel mailing list