Skip to content

webrtcsink: use spawn_blocking instead of call_async

In webrtcsink, we terminate a session by setting the session's pipeline to Null like this:

    pipeline.call_async(|pipeline| {
        [...]
        pipeline.set_state(gst::State::Null);
        [...]
        // the following cvar is awaited in unprepare()
        cvar.notify_one();
    });

However, pipeline.call_async keeps a ref on the pipeline until it's done, which means the cvar is notified before pipeline is actually 'disposed', which happens in a different thread than unprepare's. gst_rtp_bin_dispose releases some resources when the pipeline is unrefed. In some cases, those resources are actually released after the main thread has returned, leading to various issues.

This commit uses tokio runtime's spawn_blocking instead, which allows owning and disposing of the pipeline before the cvar is notified.

Edited by François Laignel

Merge request reports

Loading