<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [GStreamer] Use MainThreadNotifier to send notifications to main thread in WebKitWebSourceGStreamer"
   href="https://bugs.webkit.org/show_bug.cgi?id=150890#c3">Comment # 3</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [GStreamer] Use MainThreadNotifier to send notifications to main thread in WebKitWebSourceGStreamer"
   href="https://bugs.webkit.org/show_bug.cgi?id=150890">bug 150890</a>
              from <span class="vcard"><a class="email" href="mailto:zan&#64;falconsigh.net" title="Zan Dobersek &lt;zan&#64;falconsigh.net&gt;"> <span class="fn">Zan Dobersek</span></a>
</span></b>
        <pre>Comment on <span class=""><a href="attachment.cgi?id=264788&amp;action=diff" name="attach_264788" title="Patch">attachment 264788</a> <a href="attachment.cgi?id=264788&amp;action=edit" title="Patch">[details]</a></span>
Patch

View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=264788&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=264788&amp;action=review</a>

All the uses of MainThreadNotifier&lt;&gt;::notify() need updating, otherwise looks fine.

<span class="quote">&gt; Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:177
&gt; +    // NeedData</span >

I usually write these in the same C-style they're declared in: need_data, enough_data, seek_data.

<span class="quote">&gt; Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:194
&gt; +        {
&gt; +            WTF::GMutexLocker&lt;GMutex&gt; locker(*GST_OBJECT_GET_LOCK(src));
&gt; +            if (!priv-&gt;paused)
&gt; +                return;
&gt; +
&gt; +            if (!isMainThread()) {
&gt; +                GRefPtr&lt;WebKitWebSrc&gt; protector(src);
&gt; +                priv-&gt;notifier.notify(MainThreadSourceNotification::NeedData, [protector] { webKitWebSrcNeedData(protector.get()); });
&gt; +                return;
&gt; +            }
&gt; +        }
&gt; +
&gt; +        webKitWebSrcNeedData(src);</span >

Can webKitWebSrcNeedData(), webKitWebSrcEnoughData() and webKitWebSrcSeek() all be rewritten and used with the expectation that the GST_OBJECT_GET_LOCK() is already locked? That way the lock can be held throughout the lambda scope, and there's no need for the isMainThread() check at this level.

<span class="quote">&gt; Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:656
&gt; +        if (isMainThread())
&gt; +            webKitWebSrcStart(src);
&gt; +        else {
&gt; +            GRefPtr&lt;WebKitWebSrc&gt; protector(src);
&gt; +            priv-&gt;notifier.notify(MainThreadSourceNotification::Start, [protector] { webKitWebSrcStart(protector.get()); });
&gt; +        }</span >

Similarly, webKitWebSrcStart() and webKitWebSrcStop() could just work with the assumption (or an actual run-time assertion) that the GstObject lock is locked.

<span class="quote">&gt; Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:833
&gt; +static void webKitWebSrcSeek(WebKitWebSrc* src)</span >

If all the above is possible, don't forget to set up the lock here.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>