Skip to content

Conversation

@MaZderMind
Copy link
Contributor

When GSTPAD_API.gst_pad_add_probe is called with a mask of IDLE which usually is what we want when calling block(), it can, if the pad is already IDLE directly call the probe-callback from the calling thread.

In the case of block() this will directly jump into the Pads eventReceived method, which will directly call removeCallback.

removeCallback tries to find the callback-object in the Pad's signals but fails to do so, because we actually have not yet created the actual callback object - we're still stuck in the constructor-call of the GCallback object.

Actually the GCallback is registered only after the actual callback has been executed for the first time, and it will be called again – and only on the second invocation it will actually be removed. Often, especially when unlinking the pad in the block-callback, there might not be a second invocation and the probe might be dangling forever.

The solution to this is to return PadProbeReturn.REMOVE from the block-callback. This will cause GSTPAD_API.gst_pad_add_probe to return a probe-id of 0, which can be used in addEventProbe to detect that the requested probe has already been handled and there is no need for it to be registered on the GObject. I implemented this optimization in this PR.

This fix is part of a set of fixes for #184 and is extracted from #186

@neilcsmith-net
Copy link
Member

Thanks, looks good.

@neilcsmith-net neilcsmith-net added this to the 1.2 milestone Apr 13, 2020
@neilcsmith-net neilcsmith-net merged commit 5f83304 into gstreamer-java:master Apr 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants