I’m writing a plugin that uses some callbacks which can fail, and want to gracefully stop and free the pipeline’s resources when this happens.
I’m running a separate thread that gets passed these errors through a channel, which posts an Error message to the element’s bus when it receives one such error, but while this sets the pipeline to NULL, it doesn’t actually release the elements and stop the running threads (debugger call stack shows a bunch of gst-launch and one gmain process still running).
This is what gets printed to the terminal:
ERROR: from element /(nil): Error in callback
Execution ended after 0:00:02.256119900
Setting pipeline to NULL ...
But the behaviour I want would be the same as when I return an error in e.g.: the BaseSrcImpl::start()
function:
ERROR: pipeline doesn't want to preroll.
Failed to set pipeline to PAUSED.
Setting pipeline to NULL ...
Freeing pipeline ...
I imagine sending an event/posting the error to the pipeline’s bus should do it, but so far I have been unable to find a way to do that from the element’s impl.
Is what I’m doing the right way to approach this problem?
The element’s base class is a BaseSrcImpl
if that matters.