ALSA: pcm core - add a safe check to the silence filling function
authorJaroslav Kysela <perex@perex.cz>
Mon, 19 Jul 2010 14:37:39 +0000 (16:37 +0200)
committerJaroslav Kysela <perex@perex.cz>
Mon, 19 Jul 2010 14:47:01 +0000 (16:47 +0200)
In situation when appl_ptr is far greater then hw_ptr, the hw_avail value
can be greater than buffer_size. Check for this.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
sound/core/pcm_lib.c

index bcf95d3ff5c70b8f19616c925fed8306845a60a3..e23e0e7ab26f9ff5f02204ca62422a14cc674e5e 100644 (file)
@@ -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) %