summaryrefslogtreecommitdiff
path: root/encoders
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2010-09-05 18:26:30 +0200
committerJon Bergli Heier <snakebite@jvnv.net>2010-09-05 18:26:30 +0200
commit30aa38e29a03250192c3c0d4faa3c37a9d4d0357 (patch)
treee18de4873a9f3e993086b9cfdd1b5c2a3dcc171f /encoders
parentb6567cbdf77f0ebf1790b1e7d800ad4df88253ca (diff)
Rewrote encoder/decoder setup to use streams instead of buffers.
Diffstat (limited to 'encoders')
-rw-r--r--encoders/encoder_lame.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/encoders/encoder_lame.c b/encoders/encoder_lame.c
index ec50047..b28e52e 100644
--- a/encoders/encoder_lame.c
+++ b/encoders/encoder_lame.c
@@ -12,13 +12,21 @@ static gboolean lame_encoder_init(gpointer *data) {
return (ret >= 0 ? TRUE : FALSE);
}
-static gssize lame_encoder_encode(gpointer data, const guchar *inbuf, gsize inbuf_size,
- guchar *outbuf, gsize outbuf_size) {
+static gssize lame_encoder_encode(gpointer data, GInputStream *input,
+ GOutputStream *output) {
lame_global_flags *gfp = data;
+ const inbuf_size = 0x400*8;
+ const outbuf_size = 0x400*8;
+ gchar inbuf[inbuf_size];
+ gchar outbuf[inbuf_size];
- int ret = lame_encode_buffer_interleaved(gfp, (short*)inbuf, inbuf_size / 4,
+ int inbuf_read = g_input_stream_read(input, inbuf, inbuf_size, NULL, NULL);
+
+ int ret = lame_encode_buffer_interleaved(gfp, (short*)inbuf, inbuf_read / 4,
outbuf, outbuf_size);
+ g_output_stream_write(output, outbuf, ret, NULL, NULL);
+
return ret;
}