gst/auparse/gstauparse.c: Hack around spider. Remove me some day please.

Original commit message from CVS:
* gst/auparse/gstauparse.c: (gst_auparse_class_init),
(gst_auparse_init), (gst_auparse_chain),
(gst_auparse_change_state):
Hack around spider. Remove me some day please.
This commit is contained in:
Ronald S. Bultje 2004-05-11 00:20:02 +00:00
parent 3eb5b6313b
commit d303506bca
2 changed files with 48 additions and 4 deletions

View file

@ -1,3 +1,10 @@
2004-05-10 Ronald Bultje <rbultje@ronald.bitfreak.net>
* gst/auparse/gstauparse.c: (gst_auparse_class_init),
(gst_auparse_init), (gst_auparse_chain),
(gst_auparse_change_state):
Hack around spider. Remove me some day please.
2004-05-10 Ronald Bultje <rbultje@ronald.bitfreak.net> 2004-05-10 Ronald Bultje <rbultje@ronald.bitfreak.net>
* gst/auparse/gstauparse.c: (gst_auparse_chain): * gst/auparse/gstauparse.c: (gst_auparse_chain):

View file

@ -48,7 +48,7 @@ GST_STATIC_PAD_TEMPLATE ("sink",
static GstStaticPadTemplate gst_auparse_src_template = static GstStaticPadTemplate gst_auparse_src_template =
GST_STATIC_PAD_TEMPLATE ("src", GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC, GST_PAD_SRC,
GST_PAD_ALWAYS, GST_PAD_SOMETIMES, /* FIXME: spider */
GST_STATIC_CAPS (GST_AUDIO_INT_PAD_TEMPLATE_CAPS "; " /* does not support 24bit without patch */ GST_STATIC_CAPS (GST_AUDIO_INT_PAD_TEMPLATE_CAPS "; " /* does not support 24bit without patch */
GST_AUDIO_FLOAT_PAD_TEMPLATE_CAPS "; " GST_AUDIO_FLOAT_PAD_TEMPLATE_CAPS "; "
"audio/x-alaw, " "audio/x-alaw, "
@ -77,6 +77,8 @@ static void gst_auparse_init (GstAuParse * auparse);
static void gst_auparse_chain (GstPad * pad, GstData * _data); static void gst_auparse_chain (GstPad * pad, GstData * _data);
static GstElementStateReturn gst_auparse_change_state (GstElement * element);
static GstElementClass *parent_class = NULL; static GstElementClass *parent_class = NULL;
/*static guint gst_auparse_signals[LAST_SIGNAL] = { 0 }; */ /*static guint gst_auparse_signals[LAST_SIGNAL] = { 0 }; */
@ -127,6 +129,8 @@ gst_auparse_class_init (GstAuParseClass * klass)
gstelement_class = (GstElementClass *) klass; gstelement_class = (GstElementClass *) klass;
parent_class = g_type_class_ref (GST_TYPE_ELEMENT); parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
gstelement_class->change_state = gst_auparse_change_state;
} }
static void static void
@ -138,11 +142,13 @@ gst_auparse_init (GstAuParse * auparse)
gst_element_add_pad (GST_ELEMENT (auparse), auparse->sinkpad); gst_element_add_pad (GST_ELEMENT (auparse), auparse->sinkpad);
gst_pad_set_chain_function (auparse->sinkpad, gst_auparse_chain); gst_pad_set_chain_function (auparse->sinkpad, gst_auparse_chain);
auparse->srcpad = auparse->srcpad = NULL;
gst_pad_new_from_template (gst_static_pad_template_get #if 0 /* FIXME: spider */
gst_pad_new_from_template (gst_static_pad_template_get
(&gst_auparse_src_template), "src"); (&gst_auparse_src_template), "src");
gst_element_add_pad (GST_ELEMENT (auparse), auparse->srcpad); gst_element_add_pad (GST_ELEMENT (auparse), auparse->srcpad);
gst_pad_use_explicit_caps (auparse->srcpad); gst_pad_use_explicit_caps (auparse->srcpad);
#endif
auparse->offset = 0; auparse->offset = 0;
auparse->size = 0; auparse->size = 0;
@ -268,10 +274,16 @@ Samples :
case 26: /* 5 bit CCITT G723 ADPCM */ case 26: /* 5 bit CCITT G723 ADPCM */
default: default:
g_warning ("help!, dont know how to deal with this format yet\n"); GST_ELEMENT_ERROR (auparse, STREAM, FORMAT, (NULL), (NULL));
gst_buffer_unref (buf);
return; return;
} }
auparse->srcpad =
gst_pad_new_from_template (gst_static_pad_template_get
(&gst_auparse_src_template), "src");
gst_pad_use_explicit_caps (auparse->srcpad);
if (law) { if (law) {
tempcaps = tempcaps =
gst_caps_new_simple ((law == 1) ? "audio/x-mulaw" : "audio/x-alaw", gst_caps_new_simple ((law == 1) ? "audio/x-mulaw" : "audio/x-alaw",
@ -293,9 +305,13 @@ Samples :
if (!gst_pad_set_explicit_caps (auparse->srcpad, tempcaps)) { if (!gst_pad_set_explicit_caps (auparse->srcpad, tempcaps)) {
gst_buffer_unref (buf); gst_buffer_unref (buf);
gst_object_unref (GST_OBJECT (auparse->srcpad));
auparse->srcpad = NULL;
return; return;
} }
gst_element_add_pad (GST_ELEMENT (auparse), auparse->srcpad);
newbuf = gst_buffer_new (); newbuf = gst_buffer_new ();
GST_BUFFER_DATA (newbuf) = (gpointer) malloc (size - (auparse->offset)); GST_BUFFER_DATA (newbuf) = (gpointer) malloc (size - (auparse->offset));
memcpy (GST_BUFFER_DATA (newbuf), data + 24, size - (auparse->offset)); memcpy (GST_BUFFER_DATA (newbuf), data + 24, size - (auparse->offset));
@ -310,6 +326,27 @@ Samples :
gst_pad_push (auparse->srcpad, GST_DATA (buf)); gst_pad_push (auparse->srcpad, GST_DATA (buf));
} }
static GstElementStateReturn
gst_auparse_change_state (GstElement * element)
{
GstAuParse *auparse = GST_AUPARSE (element);
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_PAUSED_TO_READY:
if (auparse->srcpad) {
gst_element_remove_pad (element, auparse->srcpad);
auparse->srcpad = NULL;
}
break;
default:
break;
}
if (parent_class->change_state)
return parent_class->change_state (element);
return GST_STATE_SUCCESS;
}
static gboolean static gboolean
plugin_init (GstPlugin * plugin) plugin_init (GstPlugin * plugin)