On 10/01/2021 11.02, Volker Rümelin wrote:
Fill the remaining sample buffer with silence. To fill it with
zeroes is wrong for unsigned samples because this is silence
with a DC bias.
Signed-off-by: Volker Rümelin <vr_q...@t-online.de>
---
  audio/sdlaudio.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c
index 79eed23849..01ae4c600e 100644
--- a/audio/sdlaudio.c
+++ b/audio/sdlaudio.c
@@ -235,7 +235,8 @@ static void sdl_callback (void *opaque, Uint8 *buf, int len)
        /* clear remaining buffer that we couldn't fill with data */
      if (len) {
-        memset(buf, 0, len);
+        audio_pcm_info_clear_buf(&hw->info, buf,
+                                 len / hw->info.bytes_per_frame);
      }
  }

Ignorant question: Is anybody still using unsigned samples in the 21st 
century?
Hi Thomas,

you are probably right that no one is knowingly using unsigned samples anymore. But qemu emulates audio devices from the last century. For example with the command line options -machine pcspk-audiodev=audio0 -audiodev sdl,id=audio0,out.buffer-length=3750,out.mixing-engine=off you will see 8 bit unsigned samples in the SDL callback buffer.
With best regards,
Volker

Anyway,
Reviewed-by: Thomas Huth <th...@redhat.com>


Reply via email to