[alsa-devel] [PATCH] ALSA - HDA - Add period time constraint to hda-intel

Raymond Yau superquad.vortex2 at gmail.com
Thu May 26 04:01:14 CEST 2011


2011/5/24 Takashi Iwai <tiwai at suse.de>:

>> ALSA hda_intel.c:1680: azx_pcm_prepare: bufsize=0x1aeb00, format=0x4111
>> ...
>> ALSA pcm_native.c:1531: playback drain error (DMA or IRQ trouble?)
>
> Wouldn't it be better to fix the PCM timeout itself?
> Does the patch below work?
>
>
> thanks,
>
> Takashi
>
> ---
> diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
> index abfeff16..a754722 100644
> --- a/sound/core/pcm_lib.c
> +++ b/sound/core/pcm_lib.c
> @@ -1756,8 +1756,16 @@ static int wait_for_avail(struct snd_pcm_substream *substream,
>        wait_queue_t wait;
>        int err = 0;
>        snd_pcm_uframes_t avail = 0;
> +       long wait_time = 10; /* 10 seconds timeout as default */
>        long tout;
>
> +       if (runtime->rate) {
> +               long t = (runtime->period_size * 2 + runtime->rate - 1) /
> +                       runtime->rate;
> +               wait_time = max(t, wait_time);
> +       }
> +       wait_time = msecs_to_jiffies(wait_time * 1000);
> +
>        init_waitqueue_entry(&wait, current);
>        add_wait_queue(&runtime->tsleep, &wait);
>        for (;;) {
> @@ -1767,7 +1775,7 @@ static int wait_for_avail(struct snd_pcm_substream *substream,
>                }
>                set_current_state(TASK_INTERRUPTIBLE);
>                snd_pcm_stream_unlock_irq(substream);
> -               tout = schedule_timeout(msecs_to_jiffies(10000));
> +               tout = schedule_timeout(wait_time);
>                snd_pcm_stream_lock_irq(substream);
>                switch (runtime->status->state) {
>                case SNDRV_PCM_STATE_SUSPENDED:
>

you patch only fix the playback write/capture read error .

does it mean that even when the application (e.g. PA server) set
stop_threshold to boundary can only freerun for 10 seconds only ?


The drain error in pcm_native.c still occur when application use a
period time longer than 10 seconds and some of the audio signal at the
end seem lost in snd_pcm_drain()



		tout = schedule_timeout(10 * HZ);

...

		if (tout == 0) {
			if (substream->runtime->status->state == SNDRV_PCM_STATE_SUSPENDED)
				result = -ESTRPIPE;
			else {
				snd_printd("playback drain error (DMA or IRQ trouble?)\n");
				snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP);
				result = -EIO;
			}
			break;
		}


More information about the Alsa-devel mailing list