diff options
author | Laxminath Kasam <lkasam@codeaurora.org> | 2020-07-09 19:36:36 +0530 |
---|---|---|
committer | Alexander Grund <flamefire89@gmail.com> | 2023-12-23 19:58:20 +0100 |
commit | ce75dd05065bc32b0a67b1ea38de5ee9aaba3985 (patch) | |
tree | c136edcaa082a1c8848282880374ddbc46849f29 | |
parent | 1f5e1652174f8c66c94b37fdf5fa2a43fe246650 (diff) |
asoc: Reset the buffer if size is partial or zero
Sometimes during device switch in recording,
observe size 0 is return from DSP due to EOS
handling. For ALSA pcm_read to unblock, buffer
appl_ptr is elapsed without actually updating
the buffer. And userspace copies the stale
data(old buffer) causing issue sometimes.
Reset the buffer for that period_size in
such cases instead of transfer stale data.
Change-Id: I0d3ac133a8d95fad0710586e3e947410a41c9c5a
Signed-off-by: Laxminath Kasam <lkasam@codeaurora.org>
-rw-r--r-- | sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c b/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c index 5f4225e675ad..88b8f3f9a205 100644 --- a/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c +++ b/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c @@ -1004,6 +1004,11 @@ static int msm_pcm_capture_copy(struct snd_pcm_substream *substream, goto fail; } + if (size == 0 || size < fbytes) { + memset(bufptr + offset + size, 0, fbytes - size); + size = xfer = fbytes; + } + if (copy_to_user(buf, bufptr+offset, xfer)) { pr_err("Failed to copy buf to user\n"); ret = -EFAULT; |