mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-18 21:35:44 +00:00
urisourcebin: Avoid races when setting up typefind
The state of urisourcebin (and all elements contained within) can change at any point in time, including when setting up the typefind element. In order to avoid ending up with typefind starting without being fully connected, lock the state and connect to the 'have-type' signal.
This commit is contained in:
parent
d0c1b34288
commit
90e86b8638
1 changed files with 7 additions and 2 deletions
|
@ -1996,6 +1996,9 @@ setup_typefind (GstURISourceBin * urisrc, GstPad * srcpad)
|
|||
if (!typefind)
|
||||
goto no_typefind;
|
||||
|
||||
/* Make sure the bin doesn't set the typefind running yet */
|
||||
gst_element_set_locked_state (typefind, TRUE);
|
||||
|
||||
gst_bin_add (GST_BIN_CAST (urisrc), typefind);
|
||||
|
||||
if (!srcpad) {
|
||||
|
@ -2011,14 +2014,16 @@ setup_typefind (GstURISourceBin * urisrc, GstPad * srcpad)
|
|||
goto could_not_link;
|
||||
}
|
||||
|
||||
gst_element_sync_state_with_parent (typefind);
|
||||
|
||||
urisrc->typefinds = g_list_append (urisrc->typefinds, typefind);
|
||||
|
||||
/* connect a signal to find out when the typefind element found
|
||||
* a type */
|
||||
g_signal_connect (typefind, "have-type", G_CALLBACK (type_found), urisrc);
|
||||
|
||||
/* Now it can start */
|
||||
gst_element_set_locked_state (typefind, FALSE);
|
||||
gst_element_sync_state_with_parent (typefind);
|
||||
|
||||
return TRUE;
|
||||
|
||||
/* ERRORS */
|
||||
|
|
Loading…
Reference in a new issue