]> git.alsa-project.org Git - alsa-lib.git/commitdiff
pcm: fix snd_pcm_mmap_hw_avail() near the boundary
authorAlexander E. Patrakov <patrakov@gmail.com>
Sun, 31 Aug 2014 16:23:47 +0000 (22:23 +0600)
committerTakashi Iwai <tiwai@suse.de>
Mon, 1 Sep 2014 13:27:46 +0000 (15:27 +0200)
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 <patrakov@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
src/pcm/pcm_local.h

index 80bbe5973bdb0c8c0cafeea12df1e63a20cb5cf7..74ebd609334a57d31e36466ddf611386291a3cb4 100644 (file)
@@ -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)