Skip to content

Commit

Permalink
Cherry-pick 277804@main (9e55194). https://bugs.webkit.org/show_bug.c…
Browse files Browse the repository at this point in the history
…gi?id=272912

    [GStreamer] Deadlock in webKitWebSrcCreate when handling non-flushing seeks
    https://bugs.webkit.org/show_bug.cgi?id=272912

    Reviewed by Xabier Rodriguez-Calvar.

    When handling non-flushing seeks the GStreamer basesrc base class will pause the pad task instead of
    sending a flush-start event, so in that situation the "unlock" vmethod is not called. In order to
    prevent deadlocks, unlock the streaming thread before letting basesrc handle the non-flushing seek
    event.

    * Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
    (webkit_web_src_class_init):
    (webKitWebSrcEvent):

    Canonical link: https://commits.webkit.org/277804@main

Canonical link: https://commits.webkit.org/274313.198@webkitglib/2.44
  • Loading branch information
philn authored and aperezdc committed May 2, 2024
1 parent 3357f25 commit 64f50f9
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ static gboolean webKitWebSrcGetSize(GstBaseSrc*, guint64* size);
static gboolean webKitWebSrcIsSeekable(GstBaseSrc*);
static gboolean webKitWebSrcDoSeek(GstBaseSrc*, GstSegment*);
static gboolean webKitWebSrcQuery(GstBaseSrc*, GstQuery*);
static gboolean webKitWebSrcEvent(GstBaseSrc*, GstEvent*);
static gboolean webKitWebSrcUnLock(GstBaseSrc*);
static gboolean webKitWebSrcUnLockStop(GstBaseSrc*);
static void webKitWebSrcSetContext(GstElement*, GstContext*);
Expand Down Expand Up @@ -248,6 +249,7 @@ static void webkit_web_src_class_init(WebKitWebSrcClass* klass)
baseSrcClass->is_seekable = GST_DEBUG_FUNCPTR(webKitWebSrcIsSeekable);
baseSrcClass->do_seek = GST_DEBUG_FUNCPTR(webKitWebSrcDoSeek);
baseSrcClass->query = GST_DEBUG_FUNCPTR(webKitWebSrcQuery);
baseSrcClass->event = GST_DEBUG_FUNCPTR(webKitWebSrcEvent);

GstPushSrcClass* pushSrcClass = GST_PUSH_SRC_CLASS(klass);
pushSrcClass->create = GST_DEBUG_FUNCPTR(webKitWebSrcCreate);
Expand Down Expand Up @@ -806,6 +808,29 @@ static gboolean webKitWebSrcQuery(GstBaseSrc* baseSrc, GstQuery* query)
return result;
}

static gboolean webKitWebSrcEvent(GstBaseSrc* baseSrc, GstEvent* event)
{
switch (GST_EVENT_TYPE(event)) {
case GST_EVENT_SEEK: {
GstSeekFlags flags;
gst_event_parse_seek(event, nullptr, nullptr, &flags, nullptr, nullptr, nullptr, nullptr);

if (!(flags & GST_SEEK_FLAG_FLUSH)) {
auto src = WEBKIT_WEB_SRC(baseSrc);
GST_DEBUG_OBJECT(src, "Non-flushing seek requested, unlocking streaming thread that might be expecting a response.");

DataMutexLocker members { src->priv->dataMutex };
members->isFlushing = true;
members->responseCondition.notifyOne();
}
break;
}
default:
break;
};
return GST_BASE_SRC_CLASS(parent_class)->event(baseSrc, event);
}

static gboolean webKitWebSrcUnLock(GstBaseSrc* baseSrc)
{
WebKitWebSrc* src = WEBKIT_WEB_SRC(baseSrc);
Expand Down

0 comments on commit 64f50f9

Please sign in to comment.