summaryrefslogtreecommitdiffstats
path: root/audio/gstsbcdec.c
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2007-11-12 18:15:59 +0000
committerLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2007-11-12 18:15:59 +0000
commit397d6c2b3bc7661f978c1777442d33fd86ada21e (patch)
tree7ac2b0d3768715896e286eab291dccfde333cfb8 /audio/gstsbcdec.c
parentf89c7796c7882c65e829e5203a79606c3d1d63b0 (diff)
Make sbc codec to write directly in application buffers and so avoiding memcpys.
Diffstat (limited to 'audio/gstsbcdec.c')
-rw-r--r--audio/gstsbcdec.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/audio/gstsbcdec.c b/audio/gstsbcdec.c
index 98504d4d..a60c3e69 100644
--- a/audio/gstsbcdec.c
+++ b/audio/gstsbcdec.c
@@ -58,10 +58,11 @@ static GstFlowReturn sbc_dec_chain(GstPad *pad, GstBuffer *buffer)
{
GstSbcDec *dec = GST_SBC_DEC(gst_pad_get_parent(pad));
GstFlowReturn res = GST_FLOW_OK;
- guint size, offset = 0;
+ guint size, codesize, offset = 0;
guint8 *data;
GstClockTime timestamp;
+ codesize = sbc_get_codesize(&dec->sbc);
timestamp = GST_BUFFER_TIMESTAMP(buffer);
if (dec->buffer) {
@@ -82,10 +83,6 @@ static GstFlowReturn sbc_dec_chain(GstPad *pad, GstBuffer *buffer)
GstCaps *caps, *temp;
int consumed;
- consumed = sbc_decode(&dec->sbc, data + offset, size - offset);
- if (consumed <= 0)
- break;
-
caps = gst_caps_new_simple("audio/x-raw-int",
"rate", G_TYPE_INT, dec->sbc.rate,
"channels", G_TYPE_INT, dec->sbc.channels,
@@ -100,14 +97,20 @@ static GstFlowReturn sbc_dec_chain(GstPad *pad, GstBuffer *buffer)
res = gst_pad_alloc_buffer_and_set_caps(dec->srcpad,
GST_BUFFER_OFFSET_NONE,
- dec->sbc.len, temp, &output);
+ codesize, temp, &output);
gst_caps_unref(temp);
if (res != GST_FLOW_OK)
goto done;
- memcpy(GST_BUFFER_DATA(output), dec->sbc.data, dec->sbc.len);
+ consumed = sbc_decode(&dec->sbc, data + offset, size - offset,
+ GST_BUFFER_DATA(output), codesize,
+ NULL);
+ if (consumed <= 0)
+ break;
+
+ GST_BUFFER_TIMESTAMP(output) = GST_BUFFER_TIMESTAMP(buffer);
res = gst_pad_push(dec->srcpad, output);
if (res != GST_FLOW_OK)