summaryrefslogtreecommitdiffstats
path: root/audio/gstsbcdec.c
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2008-01-30 14:21:43 +0000
committerLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2008-01-30 14:21:43 +0000
commit3ad6867c8c7251c3192378a1a0e2ed937ee47d1b (patch)
tree879d3e37febab470e4b46c01f8b627dfd79308ae /audio/gstsbcdec.c
parenta104e5ff05aa758b5499b316d1923f1c83915e55 (diff)
Fixes gstreamer caps and code cleanup.
Diffstat (limited to 'audio/gstsbcdec.c')
-rw-r--r--audio/gstsbcdec.c45
1 files changed, 28 insertions, 17 deletions
diff --git a/audio/gstsbcdec.c b/audio/gstsbcdec.c
index 8c27daba..a686a406 100644
--- a/audio/gstsbcdec.c
+++ b/audio/gstsbcdec.c
@@ -80,26 +80,12 @@ static GstFlowReturn sbc_dec_chain(GstPad *pad, GstBuffer *buffer)
while (offset < size) {
GstBuffer *output;
GstPadTemplate *template;
- GstCaps *caps, *temp;
+ GstCaps *caps;
int consumed;
- caps = gst_caps_new_simple("audio/x-raw-int",
- "rate", G_TYPE_INT, dec->sbc.rate,
- "channels", G_TYPE_INT, dec->sbc.channels,
- NULL);
-
- template = gst_static_pad_template_get(&sbc_dec_src_factory);
-
- temp = gst_caps_intersect(caps,
- gst_pad_template_get_caps(template));
-
- gst_caps_unref(caps);
-
res = gst_pad_alloc_buffer_and_set_caps(dec->srcpad,
GST_BUFFER_OFFSET_NONE,
- codesize, temp, &output);
-
- gst_caps_unref(temp);
+ codesize, NULL, &output);
if (res != GST_FLOW_OK)
goto done;
@@ -110,7 +96,25 @@ static GstFlowReturn sbc_dec_chain(GstPad *pad, GstBuffer *buffer)
if (consumed <= 0)
break;
- GST_BUFFER_TIMESTAMP(output) = GST_BUFFER_TIMESTAMP(buffer);
+ /* we will reuse the same caps object */
+ if (dec->outcaps == NULL) {
+ caps = gst_caps_new_simple("audio/x-raw-int",
+ "rate", G_TYPE_INT, dec->sbc.rate,
+ "channels", G_TYPE_INT, dec->sbc.channels,
+ NULL);
+
+ template = gst_static_pad_template_get(&sbc_dec_src_factory);
+
+ dec->outcaps = gst_caps_intersect(caps,
+ gst_pad_template_get_caps(template));
+
+ gst_caps_unref(caps);
+ }
+
+ gst_buffer_set_caps(output, dec->outcaps);
+
+ /* FIXME get a real timestamp */
+ GST_BUFFER_TIMESTAMP(output) = GST_CLOCK_TIME_NONE;
res = gst_pad_push(dec->srcpad, output);
if (res != GST_FLOW_OK)
@@ -143,6 +147,7 @@ static GstStateChangeReturn sbc_dec_change_state(GstElement *element,
dec->buffer = NULL;
}
sbc_init(&dec->sbc, 0);
+ dec->outcaps = NULL;
break;
case GST_STATE_CHANGE_PAUSED_TO_READY:
@@ -152,6 +157,10 @@ static GstStateChangeReturn sbc_dec_change_state(GstElement *element,
dec->buffer = NULL;
}
sbc_finish(&dec->sbc);
+ if (dec->outcaps) {
+ gst_caps_unref(dec->outcaps);
+ dec->outcaps = NULL;
+ }
break;
default:
@@ -197,6 +206,8 @@ static void gst_sbc_dec_init(GstSbcDec *self, GstSbcDecClass *klass)
self->srcpad = gst_pad_new_from_static_template(
&sbc_dec_src_factory, "src");
gst_element_add_pad(GST_ELEMENT(self), self->srcpad);
+
+ self->outcaps = NULL;
}
gboolean gst_sbc_dec_plugin_init (GstPlugin * plugin)