[alsa-devel] [RFC v2 PATCH 1/1] ASoC: soc-core: symmetry checking for each DAIs separately

Timur Tabi timur at freescale.com
Thu Sep 1 20:58:51 CEST 2011

Lars-Peter Clausen wrote:
> Without the patch for example 'aplay -r 8000 ... & arecrod -r 16000 ...' would
> result in playback running twice as fast as it is supposed to.

I'm not sure I can reproduce the problem.  Executing the above command either
plays audio at the proper rate (with or without your patch), doesn't play
anything at all (it just sits there), or gives me this error message:

soc-audio soc-audio: set sample size in capture stream first

(sometimes it says "playback" instead of "capture").

This message is generated by this code in fsl_ssi.c:

/* This is the second stream open, so we need to impose sample
 * rate and maybe sample size constraints.  Note that this can
 * cause a race condition if the second stream is opened before
 * the first stream is fully initialized.
 * We provide some protection by checking to make sure the first
 * stream is initialized, but it's not perfect.  ALSA sometimes
 * re-initializes the driver with a different sample rate or
 * size.  If the second stream is opened before the first stream
 * has received its final parameters, then the second stream may
 * be constrained to the wrong sample rate or size.
 * FIXME: This code does not handle opening and closing streams
 * repeatedly.  If you open two streams and then close the first
 * one, you may not be able to open another stream until you
 * close the second one as well.
struct snd_pcm_runtime *first_runtime =

if (!first_runtime->sample_bits) {
		"set sample size in %s stream first\n",
		substream->stream == SNDRV_PCM_STREAM_PLAYBACK
		? "capture" : "playback");
	return -EAGAIN;

I don't think I've ever actually tested this code, and it's pretty old, so I
don't even know if the comment is actually valid any more.  I think the FIXME is
actually fixed, but I've forgotten the mental exercise that prompted me to
create this code in the first place.

Timur Tabi
Linux kernel developer at Freescale

More information about the Alsa-devel mailing list