resindvd: More hacking on the audio decoder.

This commit is contained in:
Jan Schmidt 2009-03-10 10:39:22 +00:00
parent 12625af8d8
commit 4a320ec12a

View file

@ -205,8 +205,12 @@ error:
static gboolean static gboolean
rsn_audiodec_sink_event (GstPad * pad, GstEvent * event) rsn_audiodec_sink_event (GstPad * pad, GstEvent * event)
{ {
RsnAudioDec *self = (RsnAudioDec *) gst_pad_get_parent (pad); GstPad *sinkpad = GST_PAD (gst_pad_get_parent (pad));
RsnAudioDec *self = (RsnAudioDec *) gst_pad_get_parent (sinkpad);
gboolean res; gboolean res;
gst_object_unref (sinkpad);
if (self == NULL) if (self == NULL)
goto error; goto error;
@ -225,16 +229,15 @@ error:
static GstCaps * static GstCaps *
rsn_audiodec_get_proxy_sink_caps (GstPad * pad) rsn_audiodec_get_proxy_sink_caps (GstPad * pad)
{ {
RsnAudioDec *self = (RsnAudioDec *) gst_pad_get_parent (pad); GstPad *sinkpad = GST_PAD (gst_pad_get_parent (pad));
GstCaps *ret; GstCaps *ret;
if (self != NULL && self->child_sink != NULL) { if (sinkpad != NULL) {
ret = gst_pad_get_caps (self->child_sink); ret = gst_pad_get_caps (sinkpad);
} else } else
ret = gst_caps_new_any (); ret = gst_caps_new_any ();
if (self) gst_object_unref (sinkpad);
gst_object_unref (self);
return ret; return ret;
} }
@ -242,16 +245,15 @@ rsn_audiodec_get_proxy_sink_caps (GstPad * pad)
static GstCaps * static GstCaps *
rsn_audiodec_get_proxy_src_caps (GstPad * pad) rsn_audiodec_get_proxy_src_caps (GstPad * pad)
{ {
RsnAudioDec *self = (RsnAudioDec *) gst_pad_get_parent (pad); GstPad *srcpad = GST_PAD (gst_pad_get_parent (pad));
GstCaps *ret; GstCaps *ret;
if (self != NULL && self->child_src != NULL) { if (srcpad != NULL) {
ret = gst_pad_get_caps (self->child_src); ret = gst_pad_get_caps (srcpad);
} else } else
ret = gst_caps_new_any (); ret = gst_caps_new_any ();
if (self) gst_object_unref (srcpad);
gst_object_unref (self);
return ret; return ret;
} }
@ -259,19 +261,21 @@ rsn_audiodec_get_proxy_src_caps (GstPad * pad)
static GstFlowReturn static GstFlowReturn
rsn_audiodec_proxy_src_chain (GstPad * pad, GstBuffer * buf) rsn_audiodec_proxy_src_chain (GstPad * pad, GstBuffer * buf)
{ {
RsnAudioDec *self = (RsnAudioDec *) gst_pad_get_parent (pad); GstPad *srcpad = GST_PAD (gst_pad_get_parent (pad));
RsnAudioDec *self = (RsnAudioDec *) gst_pad_get_parent (srcpad);
GstFlowReturn ret; GstFlowReturn ret;
g_print ("srcpad %p\n", self->srcpad); gst_object_unref (srcpad);
if (self != NULL && self->srcpad != NULL) {
GST_DEBUG_OBJECT (self, "Data from decoder, pushing to pad %"
GST_PTR_FORMAT, self->srcpad);
ret = gst_pad_push (self->srcpad, buf);
} else
ret = GST_FLOW_ERROR;
if (self) g_print ("srcpad %p\n", self->srcpad);
gst_object_unref (self); if (self == NULL)
return GST_FLOW_ERROR;
GST_DEBUG_OBJECT (self, "Data from decoder, pushing to pad %"
GST_PTR_FORMAT, self->srcpad);
ret = gst_pad_push (self->srcpad, buf);
gst_object_unref (self);
return ret; return ret;
} }
@ -279,17 +283,18 @@ rsn_audiodec_proxy_src_chain (GstPad * pad, GstBuffer * buf)
static gboolean static gboolean
rsn_audiodec_proxy_src_event (GstPad * pad, GstEvent * event) rsn_audiodec_proxy_src_event (GstPad * pad, GstEvent * event)
{ {
RsnAudioDec *self = (RsnAudioDec *) gst_pad_get_parent (pad); GstPad *srcpad = GST_PAD (gst_pad_get_parent (pad));
RsnAudioDec *self = (RsnAudioDec *) gst_pad_get_parent (srcpad);
gboolean ret; gboolean ret;
if (self != NULL && self->srcpad != NULL) { gst_object_unref (srcpad);
ret = gst_pad_push_event (self->srcpad, event);
} else
ret = GST_FLOW_ERROR;
if (self) if (self == NULL)
gst_object_unref (self); return FALSE;
ret = gst_pad_push_event (self->srcpad, event);
gst_object_unref (self);
return ret; return ret;
} }
@ -299,17 +304,17 @@ create_proxy_pads (RsnAudioDec * self)
if (self->child_sink_proxy == NULL) { if (self->child_sink_proxy == NULL) {
/* A src pad the child can query/send events to */ /* A src pad the child can query/send events to */
self->child_sink_proxy = gst_pad_new ("sink_proxy", GST_PAD_SRC); self->child_sink_proxy = gst_pad_new ("sink_proxy", GST_PAD_SRC);
gst_object_set_parent ((GstObject *) self->child_sink_proxy,
(GstObject *) self->sinkpad);
gst_pad_set_getcaps_function (self->child_sink_proxy, gst_pad_set_getcaps_function (self->child_sink_proxy,
GST_DEBUG_FUNCPTR (rsn_audiodec_get_proxy_sink_caps)); GST_DEBUG_FUNCPTR (rsn_audiodec_get_proxy_sink_caps));
gst_object_set_parent ((GstObject *) self->child_sink_proxy,
(GstObject *) self);
} }
if (self->child_src_proxy == NULL) { if (self->child_src_proxy == NULL) {
/* A sink pad the child can push to */ /* A sink pad the child can push to */
self->child_src_proxy = gst_pad_new ("src_proxy", GST_PAD_SINK); self->child_src_proxy = gst_pad_new ("src_proxy", GST_PAD_SINK);
gst_object_set_parent ((GstObject *) self->child_src_proxy, gst_object_set_parent ((GstObject *) self->child_src_proxy,
(GstObject *) self); (GstObject *) self->srcpad);
gst_pad_set_getcaps_function (self->child_src_proxy, gst_pad_set_getcaps_function (self->child_src_proxy,
GST_DEBUG_FUNCPTR (rsn_audiodec_get_proxy_src_caps)); GST_DEBUG_FUNCPTR (rsn_audiodec_get_proxy_src_caps));
gst_pad_set_chain_function (self->child_src_proxy, gst_pad_set_chain_function (self->child_src_proxy,
@ -341,13 +346,16 @@ rsn_audiodec_set_child (RsnAudioDec * self, GstElement * new_child)
return TRUE; return TRUE;
self->child_sink = gst_element_get_static_pad (new_child, "sink"); self->child_sink = gst_element_get_static_pad (new_child, "sink");
if (self->child_sink == NULL) if (self->child_sink == NULL) {
return FALSE; return FALSE;
}
self->child_src = gst_element_get_static_pad (new_child, "src"); self->child_src = gst_element_get_static_pad (new_child, "src");
if (self->child_src == NULL) if (self->child_src == NULL) {
return FALSE; return FALSE;
if (!gst_bin_add ((GstBin *) self, new_child)) }
if (!gst_bin_add ((GstBin *) self, new_child)) {
return FALSE; return FALSE;
}
GST_DEBUG_OBJECT (self, "Add child %" GST_PTR_FORMAT, new_child); GST_DEBUG_OBJECT (self, "Add child %" GST_PTR_FORMAT, new_child);
self->current_decoder = new_child; self->current_decoder = new_child;
@ -362,8 +370,6 @@ rsn_audiodec_set_child (RsnAudioDec * self, GstElement * new_child)
GST_DEBUG_OBJECT (self, "linked child src pad %" GST_PTR_FORMAT GST_DEBUG_OBJECT (self, "linked child src pad %" GST_PTR_FORMAT
" to proxy pad %" GST_PTR_FORMAT, self->child_src, self->child_src_proxy); " to proxy pad %" GST_PTR_FORMAT, self->child_src, self->child_src_proxy);
g_print ("Returning TRUE\n");
return TRUE; return TRUE;
} }