Skip to contentSkip to conversation

audio/oss: fix buffer pos calculation

PATCH In review Gerd Hoffmann 2 participants 2 messages Jan 20, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 audio/oss: fix buffer pos calculation

Fixes 3ba4066d085f ("ossaudio: port to the new audio backend api")
---
 audio/ossaudio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
audio/ossaudio.c +1 -1
index c43faeeea4aa..94564916fbf0 100644
@@ -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;
         }
Signature · 1 line
2.18.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 12 lines · Gerd Hoffmann
Fixes 3ba4066d085f ("ossaudio: port to the new audio backend api")
---
  audio/ossaudio.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
audio/ossaudio.c +0 -0
index c43faeeea4aa..94564916fbf0 100644

audio/ossaudio.c static size_t oss_write(HWVoiceOut *hw, void *buf, size_t len) · line 423

Quoted 5 lines
audio/ossaudio.c +1 -1
@@ -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.

Quoted 4 lines
audio/ossaudio.c +0 -0
              buf += to_copy;
              len -= to_copy;
          }