Skip to content

Commit

Permalink
ALSA: pcm core - add a safe check to the silence filling function
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
perexg committed Jul 19, 2010
1 parent 79c944a commit 9e216e8
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sound/core/pcm_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) %
Expand Down

0 comments on commit 9e216e8

Please sign in to comment.