audiodecoder: Rename ::event() to ::sink_event() and add ::src_event()

This commit is contained in:
Sebastian Dröge 2012-03-30 12:10:15 +02:00
parent dccfbef7f9
commit d8cb235fe4
2 changed files with 43 additions and 16 deletions

View file

@ -282,6 +282,8 @@ static GstStateChangeReturn gst_audio_decoder_change_state (GstElement *
element, GstStateChange transition); element, GstStateChange transition);
static gboolean gst_audio_decoder_sink_eventfunc (GstAudioDecoder * dec, static gboolean gst_audio_decoder_sink_eventfunc (GstAudioDecoder * dec,
GstEvent * event); GstEvent * event);
static gboolean gst_audio_decoder_src_eventfunc (GstAudioDecoder * dec,
GstEvent * event);
static gboolean gst_audio_decoder_sink_event (GstPad * pad, GstObject * parent, static gboolean gst_audio_decoder_sink_event (GstPad * pad, GstObject * parent,
GstEvent * event); GstEvent * event);
static gboolean gst_audio_decoder_src_event (GstPad * pad, GstObject * parent, static gboolean gst_audio_decoder_src_event (GstPad * pad, GstObject * parent,
@ -372,8 +374,10 @@ gst_audio_decoder_class_init (GstAudioDecoderClass * klass)
"Perform packet loss concealment (if supported)", "Perform packet loss concealment (if supported)",
DEFAULT_PLC, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); DEFAULT_PLC, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
audiodecoder_class->event = audiodecoder_class->sink_event =
GST_DEBUG_FUNCPTR (gst_audio_decoder_sink_eventfunc); GST_DEBUG_FUNCPTR (gst_audio_decoder_sink_eventfunc);
audiodecoder_class->src_event =
GST_DEBUG_FUNCPTR (gst_audio_decoder_src_eventfunc);
} }
static void static void
@ -1622,8 +1626,8 @@ gst_audio_decoder_sink_event (GstPad * pad, GstObject * parent,
GST_DEBUG_OBJECT (dec, "received event %d, %s", GST_EVENT_TYPE (event), GST_DEBUG_OBJECT (dec, "received event %d, %s", GST_EVENT_TYPE (event),
GST_EVENT_TYPE_NAME (event)); GST_EVENT_TYPE_NAME (event));
if (klass->event) if (klass->sink_event)
ret = klass->event (dec, event); ret = klass->sink_event (dec, event);
else { else {
gst_event_unref (event); gst_event_unref (event);
ret = FALSE; ret = FALSE;
@ -1690,15 +1694,9 @@ gst_audio_decoder_do_seek (GstAudioDecoder * dec, GstEvent * event)
} }
static gboolean static gboolean
gst_audio_decoder_src_event (GstPad * pad, GstObject * parent, GstEvent * event) gst_audio_decoder_src_eventfunc (GstAudioDecoder * dec, GstEvent * event)
{ {
GstAudioDecoder *dec; gboolean res;
gboolean res = FALSE;
dec = GST_AUDIO_DECODER (parent);
GST_DEBUG_OBJECT (dec, "received event %d, %s", GST_EVENT_TYPE (event),
GST_EVENT_TYPE_NAME (event));
switch (GST_EVENT_TYPE (event)) { switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_SEEK: case GST_EVENT_SEEK:
@ -1729,10 +1727,11 @@ gst_audio_decoder_src_event (GstPad * pad, GstObject * parent, GstEvent * event)
/* ... though a non-time seek can be aided as well */ /* ... though a non-time seek can be aided as well */
/* First bring the requested format to time */ /* First bring the requested format to time */
if (!(res = if (!(res =
gst_pad_query_convert (pad, format, cur, GST_FORMAT_TIME, &tcur))) gst_pad_query_convert (dec->srcpad, format, cur, GST_FORMAT_TIME,
&tcur)))
goto convert_error; goto convert_error;
if (!(res = if (!(res =
gst_pad_query_convert (pad, format, stop, GST_FORMAT_TIME, gst_pad_query_convert (dec->srcpad, format, stop, GST_FORMAT_TIME,
&tstop))) &tstop)))
goto convert_error; goto convert_error;
@ -1745,7 +1744,7 @@ gst_audio_decoder_src_event (GstPad * pad, GstObject * parent, GstEvent * event)
break; break;
} }
default: default:
res = gst_pad_event_default (pad, parent, event); res = gst_pad_event_default (dec->srcpad, GST_OBJECT_CAST (dec), event);
break; break;
} }
done: done:
@ -1759,6 +1758,29 @@ convert_error:
} }
} }
static gboolean
gst_audio_decoder_src_event (GstPad * pad, GstObject * parent, GstEvent * event)
{
GstAudioDecoder *dec;
GstAudioDecoderClass *klass;
gboolean ret;
dec = GST_AUDIO_DECODER (parent);
klass = GST_AUDIO_DECODER_GET_CLASS (dec);
GST_DEBUG_OBJECT (dec, "received event %d, %s", GST_EVENT_TYPE (event),
GST_EVENT_TYPE_NAME (event));
if (klass->src_event)
ret = klass->src_event (dec, event);
else {
gst_event_unref (event);
ret = FALSE;
}
return ret;
}
/* /*
* gst_audio_encoded_audio_convert: * gst_audio_encoded_audio_convert:
* @fmt: audio format of the encoded audio * @fmt: audio format of the encoded audio

View file

@ -194,9 +194,12 @@ struct _GstAudioDecoder
* any pending samples and not yet returned decoded data. * any pending samples and not yet returned decoded data.
* @hard indicates whether a FLUSH is being processed, * @hard indicates whether a FLUSH is being processed,
* or otherwise a DISCONT (or conceptually similar). * or otherwise a DISCONT (or conceptually similar).
* @event: Optional. * @sink_event: Optional.
* Event handler on the sink pad. Subclasses should chain up to * Event handler on the sink pad. Subclasses should chain up to
* the parent implementation to invoke the default handler. * the parent implementation to invoke the default handler.
* @src_event: Optional.
* Event handler on the src pad. Subclasses should chain up to
* the parent implementation to invoke the default handler.
* @pre_push: Optional. * @pre_push: Optional.
* Called just prior to pushing (encoded data) buffer downstream. * Called just prior to pushing (encoded data) buffer downstream.
* Subclass has full discretionary access to buffer, * Subclass has full discretionary access to buffer,
@ -240,7 +243,9 @@ struct _GstAudioDecoderClass
GstFlowReturn (*pre_push) (GstAudioDecoder *dec, GstFlowReturn (*pre_push) (GstAudioDecoder *dec,
GstBuffer **buffer); GstBuffer **buffer);
gboolean (*event) (GstAudioDecoder *dec, gboolean (*sink_event) (GstAudioDecoder *dec,
GstEvent *event);
gboolean (*src_event) (GstAudioDecoder *dec,
GstEvent *event); GstEvent *event);
gboolean (*open) (GstAudioDecoder *dec); gboolean (*open) (GstAudioDecoder *dec);