commit 110bb7a949aa16a2fa78cafdd53ceafb14f16aae sin <sin@2f30.org> 2014-12-31 18:31:03 +0000 Keep a copy of the buffer to simplify freeing resources Should revisit all of this code at some point.
output.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/output.c b/output.c index 1891429..802c3db 100644 --- a/output.c +++ b/output.c @@ -178,13 +178,17 @@ playoutput(Format *fmt, Outputdesc *desc, void *buf, size_t nbytes) return 0; /* perform mono to stereo conversion */ - inbuf = NULL; if (fmt->channels == 1 && desc->fmt.channels == 2) { inbuf = malloc(nbytes * 2); if (!inbuf) err(1, "malloc"); s16monotostereo(buf, buf, inbuf, nbytes / 2); nbytes *= 2; + } else { + inbuf = malloc(nbytes); + if (!inbuf) + err(1, "malloc"); + memcpy(inbuf, buf, nbytes); } if (desc->fmt.rate == fmt->rate) {