From: Alexander E. Patrakov Date: Sun, 31 Aug 2014 16:23:47 +0000 (+0600) Subject: pcm: fix snd_pcm_mmap_hw_avail() near the boundary X-Git-Tag: v1.0.29~54 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=99a2254f5f2a085b81efcc80950033a2b6110ecd;p=alsa-lib.git pcm: fix snd_pcm_mmap_hw_avail() near the boundary This function returned incorrect results when hw.ptr was near the boundary and hw.appl_ptr was near zero. Here "incorrect" means "greater than the boundary". The result was incorrect, because it was used as a return value of various *_rewindable() functions and also as the delay for ioplug. Signed-off-by: Alexander E. Patrakov Signed-off-by: Takashi Iwai --- diff --git a/src/pcm/pcm_local.h b/src/pcm/pcm_local.h index 80bbe597..74ebd609 100644 --- a/src/pcm/pcm_local.h +++ b/src/pcm/pcm_local.h @@ -461,13 +461,7 @@ static inline snd_pcm_sframes_t snd_pcm_mmap_capture_hw_avail(snd_pcm_t *pcm) static inline snd_pcm_sframes_t snd_pcm_mmap_hw_avail(snd_pcm_t *pcm) { - snd_pcm_sframes_t avail; - avail = *pcm->hw.ptr - *pcm->appl.ptr; - if (pcm->stream == SND_PCM_STREAM_PLAYBACK) - avail += pcm->buffer_size; - if (avail < 0) - avail += pcm->boundary; - return pcm->buffer_size - avail; + return pcm->buffer_size - snd_pcm_mmap_avail(pcm); } static inline const snd_pcm_channel_area_t *snd_pcm_mmap_areas(snd_pcm_t *pcm)