Adding buffer probe from within event probe callback
Krzysztof Konopko
krzysztof.konopko at gmail.com
Mon Apr 29 12:23:42 PDT 2013
2013/2/14 Krzysztof Konopko <krzysztof.konopko at gmail.com>
> Ehlo good people,
>
> In my app I need to take some action before sending first buffer in a new
> segment. To achieve this I tried the following:
>
> - add an event probe on a sink pad in my custom sink element
> - in an event probe callback find out if it's a segment event and add a
> buffer probe on the sink pad
> - in the buffer probe callback do my stuff and return GST_PAD_PROBE_REMOVE
>
> This unfortunately generates some spurious segment event duplicates once I
> try to add another probe within the first probe callback.
>
> The question is whether probes are "reentrant"--can I add a probe from
> another probe callback?
>
> Is this approach OK or maybe I'm barking up the wrong tree?
>
> I'm happy to investigate further if I'm not totally mistaken. I've got an
> alternative approach that works but the one above seems to me more elegant
> (if not completely wrong).
>
> Thanks,
> Kris
>
There's either something utterly stupid I do or there's something wrong
with the probes mechanism. I reproduced some misbehaviour with a small
example [1].
The following event probe callback:
static GstPadProbeReturn
event_probe(GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
{
GstEvent *event = GST_PAD_PROBE_INFO_EVENT(info);
g_print ("Got event: %s\n", GST_EVENT_TYPE_NAME (event));
if (GST_PAD_PROBE_INFO_TYPE(info) & GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM) {
if (GST_EVENT_TYPE (event) == GST_EVENT_SEGMENT) {
gint64 duration = 0;
gst_pad_peer_query_duration (pad, GST_FORMAT_TIME, &duration);
gst_pad_add_probe (pad,
GST_PAD_PROBE_TYPE_BUFFER,
buffer_probe, NULL, NULL);
}
}
return GST_PAD_PROBE_OK;
}
leads to an infinite loop. There's something wrong that happens to
internal probe cookie and do_probe_callbacks() in gstpad.c calls my
callback over and over again. If I remove either
* buffer probe registration
* duration query
from the event callback above, all runs fine.
Any ideas? Am I abusing probes?
Kris
[1] https://gist.github.com/kkonopko/5483869
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20130429/658ae048/attachment.html>
More information about the gstreamer-devel
mailing list