[alsa-devel] [PATCH] add number of periods constraint to snd-aoa

Takashi Iwai tiwai at suse.de
Fri Nov 23 10:22:16 CET 2007


At Fri, 23 Nov 2007 11:43:31 +0200 (EET),
Heikki O Lindholm wrote:
> 
> From: Heikki Lindholm <holindho at cs.helsinki.fi>
> 
> The aoa driver is not specifying constraints on number of periods, and, it 
> seems, it might end with a non-integer number, which it cannot deal with. 
> Fix by adding a proper constraint.
> 
> Signed-off-by: Heikki Lindholm  <holindho at cs.helsinki.fi>
> ---
> diff -r 1b54a8725ded aoa/soundbus/i2sbus/i2sbus-pcm.c
> --- a/aoa/soundbus/i2sbus/i2sbus-pcm.c	Wed Nov 14 17:07:17 2007 +0100
> +++ b/aoa/soundbus/i2sbus/i2sbus-pcm.c	Fri Nov 23 11:35:17 2007 +0200
> @@ -196,7 +196,10 @@ static int i2sbus_pcm_open(struct i2sbus
>  	hw->periods_max = MAX_DBDMA_COMMANDS;
>  	list_for_each_entry(cii, &sdev->codec_list, list) {
>  		if (cii->codec->open) {
> -			err = cii->codec->open(cii, pi->substream);
> +			if ((err = cii->codec->open(cii, pi->substream)) == 0)
> +				err = snd_pcm_hw_constraint_integer(
> +					pi->substream->runtime,
> +					SNDRV_PCM_HW_PARAM_PERIODS);
>  			if (err) {
>  				result = err;
>  				/* unwind */

It's better to put it outside the loop.
How about the patch below?


Takashi


diff -r a5df1adc825c aoa/soundbus/i2sbus/i2sbus-pcm.c
--- a/aoa/soundbus/i2sbus/i2sbus-pcm.c	Thu Nov 22 11:51:54 2007 +0100
+++ b/aoa/soundbus/i2sbus/i2sbus-pcm.c	Fri Nov 23 11:09:41 2007 +0100
@@ -194,6 +194,12 @@ static int i2sbus_pcm_open(struct i2sbus
 	hw->period_bytes_max = 16384;
 	hw->periods_min = 3;
 	hw->periods_max = MAX_DBDMA_COMMANDS;
+
+	result = snd_pcm_hw_constraint_integer(pi->substream->runtime,
+					       SNDRV_PCM_HW_PARAM_PERIODS);
+	if (result < 0)
+		goto out_unlock;
+
 	list_for_each_entry(cii, &sdev->codec_list, list) {
 		if (cii->codec->open) {
 			err = cii->codec->open(cii, pi->substream);


More information about the Alsa-devel mailing list