summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorAlexandre Ratchov <ratchov@cvs.openbsd.org>2017-11-07 11:39:25 +0000
committerAlexandre Ratchov <ratchov@cvs.openbsd.org>2017-11-07 11:39:25 +0000
commit9d46c0fb15ecc07a325c953463b8c3d836a13dfe (patch)
tree8dac3466cb6bd1b0984a58242f660e3a188c6475 /usr.bin
parent002dbf534b796aa995481fde7747e1d35ad540b0 (diff)
prefill with silence the buffer where cmap_copy() stores samples
rather than the file buffer. Fixes initialized data being treated as recorded samples when resampling or format conversions are involved but mono->stereo conversion is disabled.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/aucat/aucat.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/usr.bin/aucat/aucat.c b/usr.bin/aucat/aucat.c
index 5c4f5667a65..b2a50f8e0cd 100644
--- a/usr.bin/aucat/aucat.c
+++ b/usr.bin/aucat/aucat.c
@@ -345,7 +345,20 @@ slot_init(struct slot *s)
enc_init(&s->conv, &s->afile.par, slot_nch);
s->convbuf =
xmalloc(s->round * slot_nch * sizeof(adata_t));
- enc_sil_do(&s->conv, s->buf.data, bufsz);
+ }
+
+ /*
+ * 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->resampbuf) {
+ memset(s->resampbuf, 0,
+ dev_round * slot_nch * sizeof(adata_t));
+ } else if (s->convbuf) {
+ memset(s->convbuf, 0,
+ s->round * slot_nch * sizeof(adata_t));
} else {
memset(s->buf.data, 0,
bufsz * slot_nch * sizeof(adata_t));