From 1ac328b553df550c25bd0000e190d4cdd7c54a08 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 9 Feb 2009 16:36:11 +0100 Subject: shout: clear buffer before calling the encoder Always assume the buffer is empty before calling the encoder. Always flush the buffer immediately after there has been added something. This reduces the risk of buffer overruns, because there will never be a "rest" in the current buffer. --- src/output/shout_mp3.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/output/shout_mp3.c') diff --git a/src/output/shout_mp3.c b/src/output/shout_mp3.c index 86d39fc66..6086c843e 100644 --- a/src/output/shout_mp3.c +++ b/src/output/shout_mp3.c @@ -43,8 +43,8 @@ static int shout_mp3_encoder_clear_encoder(struct shout_data *sd) struct shout_buffer *buf = &sd->buf; int ret; - if ((ret = lame_encode_flush(ld->gfp, buf->data + buf->len, - buf->len)) < 0) + ret = lame_encode_flush(ld->gfp, buf->data, sizeof(buf->data)); + if (ret < 0) g_warning("error flushing lame buffers\n"); lame_close(ld->gfp); @@ -164,7 +164,7 @@ static int shout_mp3_encoder_encode(struct shout_data *sd, bytes_out = lame_encode_buffer_float(ld->gfp, left, right, samples, buf->data, - sizeof(buf->data) - buf->len); + sizeof(buf->data)); g_free(left); if (right != left) -- cgit v1.2.3