@@ -819,8 +819,10 @@ static snd_pcm_sframes_t snd_pcm_hw_writei(snd_pcm_t *pcm, const void *buffer, s
xferi.buf = (char*) buffer;
xferi.frames = size;
xferi.result = 0; /* make valgrind happy */
- err = ioctl(fd, SNDRV_PCM_IOCTL_WRITEI_FRAMES, &xferi);
- err = err >= 0 ? sync_ptr(hw, SNDRV_PCM_SYNC_PTR_APPL) : -errno;
+ if (ioctl(fd, SNDRV_PCM_IOCTL_WRITEI_FRAMES, &xferi) < 0)
+ err = -errno;
+ else
+ err = query_state(hw);
#ifdef DEBUG_RW
fprintf(stderr, "hw_writei: frames = %li, xferi.result = %li, err = %i\n", size, xferi.result, err);
#endif
@@ -838,8 +840,10 @@ static snd_pcm_sframes_t snd_pcm_hw_writen(snd_pcm_t *pcm, void **bufs, snd_pcm_
memset(&xfern, 0, sizeof(xfern)); /* make valgrind happy */
xfern.bufs = bufs;
xfern.frames = size;
- err = ioctl(fd, SNDRV_PCM_IOCTL_WRITEN_FRAMES, &xfern);
- err = err >= 0 ? sync_ptr(hw, SNDRV_PCM_SYNC_PTR_APPL) : -errno;
+ if (ioctl(fd, SNDRV_PCM_IOCTL_WRITEN_FRAMES, &xfern) < 0)
+ err = -errno;
+ else
+ err = query_state(hw);
#ifdef DEBUG_RW
fprintf(stderr, "hw_writen: frames = %li, result = %li, err = %i\n", size, xfern.result, err);
#endif
@@ -857,8 +861,10 @@ static snd_pcm_sframes_t snd_pcm_hw_readi(snd_pcm_t *pcm, void *buffer, snd_pcm_
xferi.buf = buffer;
xferi.frames = size;
xferi.result = 0; /* make valgrind happy */
- err = ioctl(fd, SNDRV_PCM_IOCTL_READI_FRAMES, &xferi);
- err = err >= 0 ? sync_ptr(hw, SNDRV_PCM_SYNC_PTR_APPL) : -errno;
+ if (ioctl(fd, SNDRV_PCM_IOCTL_READI_FRAMES, &xferi) < 0)
+ err = -errno;
+ else
+ err = query_state(hw);
#ifdef DEBUG_RW
fprintf(stderr, "hw_readi: frames = %li, result = %li, err = %i\n", size, xferi.result, err);
#endif
@@ -876,8 +882,10 @@ static snd_pcm_sframes_t snd_pcm_hw_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_u
memset(&xfern, 0, sizeof(xfern)); /* make valgrind happy */
xfern.bufs = bufs;
xfern.frames = size;
- err = ioctl(fd, SNDRV_PCM_IOCTL_READN_FRAMES, &xfern);
- err = err >= 0 ? sync_ptr(hw, SNDRV_PCM_SYNC_PTR_APPL) : -errno;
+ if (ioctl(fd, SNDRV_PCM_IOCTL_READN_FRAMES, &xfern) < 0)
+ err = -errno;
+ else
+ err = query_state(hw);
#ifdef DEBUG_RW
fprintf(stderr, "hw_readn: frames = %li, result = %li, err = %i\n", size, xfern.result, err);
#endif
When executing ioctl(2) with SNDRV_PCM_IOCTL_[READ|WRITE][N|I], applications request ALSA PCM core to handle PCM frames for buffer given as an argument. This operation moves appl_ptr of runtime of PCM substream in kernel space. Additionally, for some cases, the operation shifts state of the runtime. When alsa-lib applications run with fallback mode from failure of page mapping of status/control data, the data in user space should be updated. Current implementation of alsa-lib follows this principle, however for this purpose, an added helper function can be available. This commit replaces with the function. In this timing, no need to change avail_min of runtime, thus this commit also suppresses it. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> --- src/pcm/pcm_hw.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)