From: Sebastian Dröge Date: Sat, 29 Jan 2022 10:54:23 +0000 (+0200) Subject: souphttpsrc: Post context message after setting up the context from the source's... X-Git-Tag: 1.20.0~23 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1db95a61c0a1099b28b5fed9b89b9603fd9b75a5;p=platform%2Fupstream%2Fgstreamer.git souphttpsrc: Post context message after setting up the context from the source's thread This simplifies the code and especially the locking a bit, and makes sure we only export the session after it is fully set up. Part-of: --- diff --git a/subprojects/gst-plugins-good/ext/soup/gstsouphttpsrc.c b/subprojects/gst-plugins-good/ext/soup/gstsouphttpsrc.c index c8aad9b..a488b06 100644 --- a/subprojects/gst-plugins-good/ext/soup/gstsouphttpsrc.c +++ b/subprojects/gst-plugins-good/ext/soup/gstsouphttpsrc.c @@ -1031,27 +1031,6 @@ thread_func (gpointer user_data) _soup_session_add_feature_by_type (session->session, _soup_cookie_jar_get_type ()); - if (src->session_is_shared) { - GstContext *context; - GstMessage *message; - GstStructure *s; - - GST_DEBUG_OBJECT (session, "Sharing session %p", session->session); - - context = gst_context_new (GST_SOUP_SESSION_CONTEXT, TRUE); - s = gst_context_writable_structure (context); - gst_structure_set (s, "session", GST_TYPE_SOUP_SESSION, session, NULL); - - /* during this time the src is locked by the parent thread, - * which is waiting, so this is safe to do - */ - GST_OBJECT_UNLOCK (src); - gst_element_set_context (GST_ELEMENT_CAST (src), context); - message = gst_message_new_have_context (GST_OBJECT_CAST (src), context); - gst_element_post_message (GST_ELEMENT_CAST (src), message); - GST_OBJECT_LOCK (src); - } - /* soup2: connect the authenticate handler for the src that spawned the * session (i.e. the first owner); other users of this session will connect * their own after fetching the external session; the callback will handle @@ -1199,6 +1178,22 @@ gst_soup_http_src_session_open (GstSoupHTTPSrc * src) GST_OBJECT_UNLOCK (src); + if (src->session_is_shared) { + GstContext *context; + GstMessage *message; + GstStructure *s; + + GST_DEBUG_OBJECT (src->session, "Sharing session %p", src->session); + + context = gst_context_new (GST_SOUP_SESSION_CONTEXT, TRUE); + s = gst_context_writable_structure (context); + gst_structure_set (s, "session", GST_TYPE_SOUP_SESSION, src->session, NULL); + + gst_element_set_context (GST_ELEMENT_CAST (src), context); + message = gst_message_new_have_context (GST_OBJECT_CAST (src), context); + gst_element_post_message (GST_ELEMENT_CAST (src), message); + } + return TRUE; err: