<div dir="ltr">2013/2/14 Krzysztof Konopko <span dir="ltr"><<a href="mailto:krzysztof.konopko@gmail.com" target="_blank">krzysztof.konopko@gmail.com</a>></span><br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div dir="ltr">Ehlo good people,<div><br></div><div>In my app I need to take some action before sending first buffer in a new segment. To achieve this I tried the following:</div><div><br></div><div>- add an event probe on a sink pad in my custom sink element</div>
<div>- in an event probe callback find out if it's a segment event and add a buffer probe on the sink pad</div><div>- in the buffer probe callback do my stuff and return GST_PAD_PROBE_REMOVE</div><div>
<br></div><div>This unfortunately generates some spurious segment event duplicates once I try to add another probe within the first probe callback.</div><div><br></div><div>The question is whether probes are "reentrant"--can I add a probe from another probe callback?</div>
<div><br></div><div>Is this approach OK or maybe I'm barking up the wrong tree?</div><div><br></div><div>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).</div>
<div><br></div><div>Thanks,</div><div>Kris</div></div>
</blockquote></div><br></div><div class="gmail_extra"><br></div><div class="gmail_extra" style>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].</div>
<div class="gmail_extra" style><br></div><div class="gmail_extra" style>The following event probe callback:</div><div class="gmail_extra" style><div class="gmail_extra"><br></div><div class="gmail_extra">static GstPadProbeReturn</div>
<div class="gmail_extra">event_probe(GstPad * pad, GstPadProbeInfo * info, gpointer user_data)</div><div class="gmail_extra">{</div><div class="gmail_extra"> GstEvent *event = GST_PAD_PROBE_INFO_EVENT(info);</div><div class="gmail_extra">
g_print ("Got event: %s\n", GST_EVENT_TYPE_NAME (event));</div><div class="gmail_extra"><br></div><div class="gmail_extra"> if (GST_PAD_PROBE_INFO_TYPE(info) & GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM) {</div>
<div class="gmail_extra"> if (GST_EVENT_TYPE (event) == GST_EVENT_SEGMENT) {</div><div class="gmail_extra"> gint64 duration = 0;</div><div class="gmail_extra"><br></div><div class="gmail_extra"> gst_pad_peer_query_duration (pad, GST_FORMAT_TIME, &duration);</div>
<div class="gmail_extra"><br></div><div class="gmail_extra"> gst_pad_add_probe (pad,</div><div class="gmail_extra"> GST_PAD_PROBE_TYPE_BUFFER,</div><div class="gmail_extra"> buffer_probe, NULL, NULL);</div>
<div class="gmail_extra"> }</div><div class="gmail_extra"> }</div><div class="gmail_extra"><br></div><div class="gmail_extra"> return GST_PAD_PROBE_OK;</div><div class="gmail_extra">}</div></div><div class="gmail_extra" style>
<br></div><div class="gmail_extra" style>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</div>
<div class="gmail_extra" style>* buffer probe registration</div><div class="gmail_extra" style>* duration query</div><div class="gmail_extra" style>from the event callback above, all runs fine.</div><div class="gmail_extra" style>
<br></div><div class="gmail_extra" style>Any ideas? Am I abusing probes?</div><div class="gmail_extra" style><br></div><div class="gmail_extra" style>Kris</div><div class="gmail_extra" style><br></div><div class="gmail_extra" style>
[1] <a href="https://gist.github.com/kkonopko/5483869">https://gist.github.com/kkonopko/5483869</a></div></div>