From 0cdbd9642b1957f38992284c46247b1985e88815 Mon Sep 17 00:00:00 2001 From: ratchov Date: Sat, 21 Dec 2024 08:57:18 +0000 Subject: [PATCH] sndiod: Pad the last play block using the right encoding Fixes the short noise when playback of unsigned samples stops. We've to call enc_sil_do() instead of padding with 0 (0 doesn't represent silence for unsigned encodings). Mostly from gkoehler@ --- usr.bin/sndiod/sock.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/usr.bin/sndiod/sock.c b/usr.bin/sndiod/sock.c index 1894a576e10..059df107cab 100644 --- a/usr.bin/sndiod/sock.c +++ b/usr.bin/sndiod/sock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sock.c,v 1.52 2024/12/20 07:35:56 ratchov Exp $ */ +/* $OpenBSD: sock.c,v 1.53 2024/12/21 08:57:18 ratchov Exp $ */ /* * Copyright (c) 2008-2012 Alexandre Ratchov * @@ -797,6 +797,7 @@ sock_execmsg(struct sock *f) struct ctl *c; struct slot *s = f->slot; struct amsg *m = &f->rmsg; + struct conv conv; unsigned char *data; unsigned int size, ctl; int cmd; @@ -924,7 +925,8 @@ sock_execmsg(struct sock *f) panic(); } #endif - memset(data, 0, f->ralign); + enc_init(&conv, &s->par, s->mix.nch); + enc_sil_do(&conv, data, f->ralign / s->mix.bpf); abuf_wcommit(&s->mix.buf, f->ralign); f->ralign = s->round * s->mix.bpf; }