[PATCH] audio/oss: fix buffer pos calculation

Gerd Hoffmann posted 1 patch 6 years ago
Test docker-quick@centos7 passed
Test docker-mingw@fedora passed
Test FreeBSD passed
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20200120101804.29578-1-kraxel@redhat.com
Maintainers: Gerd Hoffmann <kraxel@redhat.com>
audio/ossaudio.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] audio/oss: fix buffer pos calculation
Posted by Gerd Hoffmann 6 years ago
Fixes: 3ba4066d085f ("ossaudio: port to the new audio backend api")
Reported-by: ziming zhang <ezrakiez@gmail.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 audio/ossaudio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/audio/ossaudio.c b/audio/ossaudio.c
index c43faeeea4aa..94564916fbf0 100644
--- a/audio/ossaudio.c
+++ b/audio/ossaudio.c
@@ -420,7 +420,7 @@ static size_t oss_write(HWVoiceOut *hw, void *buf, size_t len)
             size_t to_copy = MIN(len, hw->size_emul - hw->pos_emul);
             memcpy(hw->buf_emul + hw->pos_emul, buf, to_copy);
 
-            hw->pos_emul = (hw->pos_emul + to_copy) % hw->pos_emul;
+            hw->pos_emul = (hw->pos_emul + to_copy) % hw->size_emul;
             buf += to_copy;
             len -= to_copy;
         }
-- 
2.18.1


Re: [PATCH] audio/oss: fix buffer pos calculation
Posted by Philippe Mathieu-Daudé 6 years ago
On 1/20/20 11:18 AM, Gerd Hoffmann wrote:
> Fixes: 3ba4066d085f ("ossaudio: port to the new audio backend api")
> Reported-by: ziming zhang <ezrakiez@gmail.com>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>   audio/ossaudio.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/audio/ossaudio.c b/audio/ossaudio.c
> index c43faeeea4aa..94564916fbf0 100644
> --- a/audio/ossaudio.c
> +++ b/audio/ossaudio.c
> @@ -420,7 +420,7 @@ static size_t oss_write(HWVoiceOut *hw, void *buf, size_t len)
>               size_t to_copy = MIN(len, hw->size_emul - hw->pos_emul);
>               memcpy(hw->buf_emul + hw->pos_emul, buf, to_copy);
>   
> -            hw->pos_emul = (hw->pos_emul + to_copy) % hw->pos_emul;
> +            hw->pos_emul = (hw->pos_emul + to_copy) % hw->size_emul;

Interestingly oss_put_buffer_out() is correct.

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

>               buf += to_copy;
>               len -= to_copy;
>           }
>