[alsa-devel] XRUN handling

Jaroslav Kysela perex at perex.cz
Mon Jul 19 16:37:31 CEST 2010


On Wed, 14 Jul 2010, melwyn lobo wrote:

> Another query, if setting runtime parameters like:
> runtime->silence_threshold = runtime->boundary;
> runtime->silence_size = runtime->boundary;
> runtime->stop_threshold = runtime->boundary;
>
> Also to avoid the bug in snd_pcm_playback_silence()  i.e.,
> snd_BUG_ON(frames > runtime->buffer_size),
> I have added a tweak in the driver IRQ handler:

This patch might fix this problem:

diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
index bcf95d3..e23e0e7 100644
--- a/sound/core/pcm_lib.c
+++ b/sound/core/pcm_lib.c
@@ -67,6 +67,8 @@ void snd_pcm_playback_silence(struct snd_pcm_substream *substream, snd_pcm_ufram
  	} else {
  		if (new_hw_ptr == ULONG_MAX) {	/* initialization */
  			snd_pcm_sframes_t avail = snd_pcm_playback_hw_avail(runtime);
+			if (avail > runtime->buffer_size)
+				avail = runtime->buffer_size;
  			runtime->silence_filled = avail > 0 ? avail : 0;
  			runtime->silence_start = (runtime->status->hw_ptr +
  						  runtime->silence_filled) %

But it looks that you do something wrong with hw_ptr or appl_ptr in your 
driver, because this condition would be true only when an large underrun 
occurs immediatelly.

 					Jaroslav

-----
Jaroslav Kysela <perex at perex.cz>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.



More information about the Alsa-devel mailing list