adaptivedemux2: Fix download helper with libsoup 3.0.x

libsoup 3.0.x dispatches using a single source attached when the session
is created, so we need to create the session with the same context that
our download thread is later using.

2.74 or 3.1 will dispatch a response using the context which sent the
request. However, for any context other than the one that created the
session, this will also create and destroy sources, so there's still
some slight performance benefit.

Fixes: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/1384
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2913>
This commit is contained in:
Jan Alexander Steffens (heftig) 2022-08-18 16:36:45 +02:00 committed by GStreamer Marge Bot
parent 135edee484
commit 5ae3c9318d

View file

@ -609,10 +609,16 @@ downloadhelper_new (GstAdaptiveDemuxClock * clock)
g_async_queue_new_full ((GDestroyNotify) g_object_unref);
dh->transfer_requests_source = NULL;
/* libsoup 3.0 (not 2.74 or 3.1) dispatches using a single source attached
* when the session is created, so we need to ensure it matches here. */
g_main_context_push_thread_default (dh->transfer_context);
/* Set 10 second timeout. Any longer is likely
* an attempt to reuse an already closed connection */
dh->session = _soup_session_new_with_options ("timeout", 10, NULL);
g_main_context_pop_thread_default (dh->transfer_context);
return dh;
}