Re: [PATCH] ASoC: pcm: allow changing the playback/capture rates for symmetric links

From: Mark Brown
Date: Wed Apr 27 2016 - 12:15:23 EST


On Wed, Apr 27, 2016 at 10:49:19AM +0200, Peter Rosin wrote:

> The below program fails on a dai link with symmetric rates without this
> patch. The patch makes it work.

You've not articulated the problem you're trying to fix here, what in
concrete terms is the program trying to accomplish and why should it
succeed?

> if ((fd = open("/dev/dsp", O_WRONLY, 0)) == -1) {
> perror("open");
> return 1;
> }

This is using the OSS interfaces which really haven't ever been
especially supported for ASoC.

> + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
> + if (!cpu_dai->capture_active)
> + return 0;
> + } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
> + if (!cpu_dai->playback_active)
> + return 0;
> + }
> +
> rate = params_rate(params);
> channels = params_channels(params);
> sample_bits = snd_pcm_format_physical_width(params_format(params));

This means we've opened up a race where the stream is configured but not
started where the opposite direction can configure a different setup.
Since starting both directions very close together is a common operation
it seems likely to cause issues.

Attachment: signature.asc
Description: PGP signature