diff options
author | 2017-11-07 11:41:07 +0000 | |
---|---|---|
committer | 2017-11-07 11:41:07 +0000 | |
commit | 98ccfc6e93b786dc3925714a3ed0ffde1faa6952 (patch) | |
tree | 87c2f5887b0efdaac5bc6720e65988dee8cdcbbf | |
parent | prefill with silence the buffer where cmap_copy() stores samples (diff) | |
download | wireguard-openbsd-98ccfc6e93b786dc3925714a3ed0ffde1faa6952.tar.xz wireguard-openbsd-98ccfc6e93b786dc3925714a3ed0ffde1faa6952.zip |
prefill with silence the buffer where cmap_copy() stores samples
rather than the client buffer. Fixes uninitialized data being treated
as recorded samples when resampling or format conversions are involved
but no mono->stereo conversion is used.
-rw-r--r-- | usr.bin/sndiod/dev.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/usr.bin/sndiod/dev.c b/usr.bin/sndiod/dev.c index 642ea6386e6..801e36231be 100644 --- a/usr.bin/sndiod/dev.c +++ b/usr.bin/sndiod/dev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dev.c,v 1.29 2017/11/03 17:12:59 ratchov Exp $ */ +/* $OpenBSD: dev.c,v 1.30 2017/11/07 11:41:07 ratchov Exp $ */ /* * Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org> * @@ -1709,7 +1709,20 @@ slot_attach(struct slot *s) enc_init(&s->sub.enc, &s->par, slot_nch); s->sub.encbuf = xmalloc(s->round * slot_nch * sizeof(adata_t)); - enc_sil_do(&s->sub.enc, s->sub.buf.data, s->appbufsz); + } + + /* + * cmap_copy() doesn't write samples in all channels, + * for instance when mono->stereo conversion is + * disabled. So we have to prefill cmap_copy() output + * with silence. + */ + if (s->sub.resampbuf) { + memset(s->sub.resampbuf, 0, + d->round * slot_nch * sizeof(adata_t)); + } else if (s->sub.encbuf) { + memset(s->sub.encbuf, 0, + s->round * slot_nch * sizeof(adata_t)); } else { memset(s->sub.buf.data, 0, s->appbufsz * slot_nch * sizeof(adata_t)); |