Stop the old decodebin after starting the new one to (hopefully) fix an occasional race condition/deadlock.

This commit is contained in:
David Sansome 2010-07-12 19:10:32 +00:00
parent fbd6b46e20
commit 8b36f12cc3

View File

@ -78,8 +78,8 @@ bool GstEnginePipeline::ReplaceDecodeBin(const QUrl& url) {
if (uridecodebin_) { if (uridecodebin_) {
gst_bin_remove(GST_BIN(pipeline_), uridecodebin_); gst_bin_remove(GST_BIN(pipeline_), uridecodebin_);
// Set its state to NULL later in the main thread // Note that the caller to this function MUST schedule StopUriDecodeBin in
g_idle_add(GSourceFunc(StopUriDecodeBin), uridecodebin_); // the main thread on the old bin.
} }
uridecodebin_ = new_bin; uridecodebin_ = new_bin;
@ -345,6 +345,8 @@ void GstEnginePipeline::SourceDrainedCallback(GstURIDecodeBin* bin, gpointer sel
GstEnginePipeline* instance = reinterpret_cast<GstEnginePipeline*>(self); GstEnginePipeline* instance = reinterpret_cast<GstEnginePipeline*>(self);
if (instance->next_url_.isValid()) { if (instance->next_url_.isValid()) {
GstElement* old_decode_bin = instance->uridecodebin_;
instance->ReplaceDecodeBin(instance->next_url_); instance->ReplaceDecodeBin(instance->next_url_);
gst_element_set_state(instance->uridecodebin_, GST_STATE_PLAYING); gst_element_set_state(instance->uridecodebin_, GST_STATE_PLAYING);
@ -353,6 +355,10 @@ void GstEnginePipeline::SourceDrainedCallback(GstURIDecodeBin* bin, gpointer sel
// This just tells the UI that we've moved on to the next song // This just tells the UI that we've moved on to the next song
emit instance->EndOfStreamReached(true); emit instance->EndOfStreamReached(true);
// This has to happen *after* the gst_element_set_state on the new bin to
// fix an occasional race condition deadlock.
g_idle_add(GSourceFunc(StopUriDecodeBin), old_decode_bin);
} }
} }