From 30aa38e29a03250192c3c0d4faa3c37a9d4d0357 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Sun, 5 Sep 2010 18:26:30 +0200 Subject: Rewrote encoder/decoder setup to use streams instead of buffers. --- decoders/decoder_mpg123.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'decoders/decoder_mpg123.c') diff --git a/decoders/decoder_mpg123.c b/decoders/decoder_mpg123.c index e80bac3..a7cf3d0 100644 --- a/decoders/decoder_mpg123.c +++ b/decoders/decoder_mpg123.c @@ -29,13 +29,19 @@ static gboolean mpg123_decoder_init(gpointer *data) { return TRUE; } -static gssize mpg123_decoder_decode(gpointer data, const guchar *inbuf, - gsize inbuf_size, guchar *outbuf, gsize outbuf_size) { +static gssize mpg123_decoder_decode(gpointer data, GInputStream *input, + GOutputStream *output) { mpg123_handle *handle = data; gssize size; int ret; + const int inbuf_size = 0x400*8; + const int outbuf_size = 0x400*8; + char inbuf[inbuf_size]; + char outbuf[inbuf_size]; - if(mpg123_feed(handle, inbuf, inbuf_size) != MPG123_OK) { + gsize inbuf_read = g_input_stream_read(input, inbuf, inbuf_size, NULL, NULL); + + if(mpg123_feed(handle, inbuf, inbuf_read) != MPG123_OK) { g_debug("asdfasdf"); g_warning(mpg123_strerror(handle)); return -1; @@ -57,6 +63,8 @@ static gssize mpg123_decoder_decode(gpointer data, const guchar *inbuf, return -1; } + g_output_stream_write(output, outbuf, size, NULL, NULL); + return size; } -- cgit v1.2.3