summaryrefslogtreecommitdiffstats
path: root/audio/gstsbcdec.c
diff options
context:
space:
mode:
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)