diff options
author | Thierry Bultel <thierry.bultel@iot.bzh> | 2018-06-06 09:32:12 +0200 |
---|---|---|
committer | Thierry Bultel <thierry.bultel@iot.bzh> | 2018-06-06 09:32:12 +0200 |
commit | 7aaf36d8e729400f7efc75d7e03e162e1f262293 (patch) | |
tree | c2dce02dbb6a617d73af17da2fa104212a786343 /plugins/alsa/alsa-core-pcm.c | |
parent | 38b5a2d09ae3ac33a31434a480549e778b16242d (diff) |
Fixed the buffer copy size in read callback
Fixes the UNDERRUN issue (seen while playing radio, for instance)
Signed-off-by: Thierry Bultel <thierry.bultel@iot.bzh>
Diffstat (limited to 'plugins/alsa/alsa-core-pcm.c')
-rw-r--r-- | plugins/alsa/alsa-core-pcm.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/plugins/alsa/alsa-core-pcm.c b/plugins/alsa/alsa-core-pcm.c index de2c437..32c7678 100644 --- a/plugins/alsa/alsa-core-pcm.c +++ b/plugins/alsa/alsa-core-pcm.c @@ -147,6 +147,7 @@ OnErrorExit: return -1; } + STATIC int AlsaPcmReadCB(sd_event_source* src, int fd, uint32_t revents, void* userData) { char string[32]; int error; @@ -214,9 +215,10 @@ STATIC int AlsaPcmReadCB(sd_event_source* src, int fd, uint32_t revents, void* u } // effectively read pcmIn and push frame to pcmOut - framesIn = snd_pcm_readi(pcmCopyHandle->pcmIn, pcmCopyHandle->buffer, availOut); + framesIn = snd_pcm_readi(pcmCopyHandle->pcmIn, pcmCopyHandle->buffer, availIn); if (framesIn < 0 || framesIn != availIn) { - AFB_ApiNotice(pcmCopyHandle->api, "AlsaPcmReadCB PcmIn=%s UNDERUN frame=%ld", ALSA_PCM_UID(pcmCopyHandle->pcmIn, string), framesIn); + AFB_ApiNotice(pcmCopyHandle->api, "AlsaPcmReadCB PcmIn=%s UNDERUN framesIn=%ld, availIn %ld, max %d", + ALSA_PCM_UID(pcmCopyHandle->pcmIn, string), framesIn, availIn, pcmCopyHandle->frameCount); snd_pcm_prepare(pcmCopyHandle->pcmIn); goto ExitOnSuccess; } @@ -225,7 +227,7 @@ STATIC int AlsaPcmReadCB(sd_event_source* src, int fd, uint32_t revents, void* u framesOut = snd_pcm_writei(pcmCopyHandle->pcmOut, pcmCopyHandle->buffer, framesIn); //framesOut = snd_pcm_mmap_writei (pcmCopyHandle->pcmOut, pcmCopyHandle->buffer, framesIn); if (framesOut < 0 || framesOut != framesIn) { - AFB_ApiNotice(pcmCopyHandle->api, "AlsaPcmReadCB PcmOut=%s UNDERUN frame=%ld", ALSA_PCM_UID(pcmCopyHandle->pcmOut, string), (framesIn - framesOut)); + AFB_ApiNotice(pcmCopyHandle->api, "AlsaPcmReadCB PcmOut=%s UNDERUN frame=%ld / %ld", ALSA_PCM_UID(pcmCopyHandle->pcmOut, string), framesOut ,framesIn); snd_pcm_prepare(pcmCopyHandle->pcmOut); goto ExitOnSuccess; } |