<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 RunLoop::Timer instead of GMainLoopSource in video sink"
   href="https://bugs.webkit.org/show_bug.cgi?id=150807#c13">Comment # 13</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [GStreamer] Use RunLoop::Timer instead of GMainLoopSource in video sink"
   href="https://bugs.webkit.org/show_bug.cgi?id=150807">bug 150807</a>
              from <span class="vcard"><a class="email" href="mailto:cgarcia&#64;igalia.com" title="Carlos Garcia Campos &lt;cgarcia&#64;igalia.com&gt;"> <span class="fn">Carlos Garcia Campos</span></a>
</span></b>
        <pre>(In reply to <a href="show_bug.cgi?id=150807#c12">comment #12</a>)
<span class="quote">&gt; (In reply to <a href="show_bug.cgi?id=150807#c11">comment #11</a>)
&gt; &gt; Comment on <span class=""><a href="attachment.cgi?id=264681&amp;action=diff" name="attach_264681" title="Updated patch">attachment 264681</a> <a href="attachment.cgi?id=264681&amp;action=edit" title="Updated patch">[details]</a></span>
&gt; &gt; Updated patch
&gt; &gt; 
&gt; &gt; View in context:
&gt; &gt; <a href="https://bugs.webkit.org/attachment.cgi?id=264681&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=264681&amp;action=review</a>
&gt; &gt; 
&gt; &gt; &gt; Source/WebCore/platform/graphics/gstreamer/VideoSinkGStreamer.cpp:180
&gt; &gt; &gt;  static GstFlowReturn webkitVideoSinkRender(GstBaseSink* baseSink, GstBuffer* buffer)
&gt; &gt; &gt;  {
&gt; &gt; &gt;      WebKitVideoSink* sink = WEBKIT_VIDEO_SINK(baseSink);
&gt; &gt; &gt;      WebKitVideoSinkPrivate* priv = sink-&gt;priv;
&gt; &gt; &gt; -
&gt; &gt; &gt; -    WTF::GMutexLocker&lt;GMutex&gt; lock(priv-&gt;sampleMutex);
&gt; &gt; &gt; -
&gt; &gt; &gt; -    if (priv-&gt;unlocked)
&gt; &gt; &gt; +    if (priv-&gt;scheduler.isUnlocked())
&gt; &gt; &gt;          return GST_FLOW_OK;
&gt; &gt; 
&gt; &gt; This is another problem.
&gt; &gt; 
&gt; &gt; Before, the sampleMutex was locked throughout this function. Now it's only
&gt; &gt; locked when querying the unlocked status of the scheduler, and when
&gt; &gt; requesting the render callback. So this now requires two locks per
&gt; &gt; webkitVideoSinkRender() invocation, and it also allows for the scheduler
&gt; &gt; state to change during these locks.
&gt; &gt; 
&gt; &gt; I would expose a `LockHolder lock();` on the VideoRenderRequestScheduler
&gt; &gt; interface, and the have the public methods accept LockHolder&amp; as their first
&gt; &gt; parameter. That way the caller is in complete control of the scope of the
&gt; &gt; lock.
&gt; &gt; (Inspired by bmalloc:
&gt; &gt; <a href="http://trac.webkit.org/browser/trunk/Source/bmalloc/bmalloc/Heap.h#L57">http://trac.webkit.org/browser/trunk/Source/bmalloc/bmalloc/Heap.h#L57</a>)
&gt; 
&gt; hmm, the mutex is supposed to protect the sample and unlocked, and non of
&gt; those change between the isUnlocked and requestRender in that function.
&gt; However, you are right that the scheduler state could change. Wouldn't it be
&gt; better to takes that into account instead and return early from
&gt; requestRender if sample is NULL?</span >

We should actually check if m_unlocked is true, instead.

<span class="quote">&gt; In the case stop() is called before
&gt; requestRender(), if we have the lock, the timer will start and right after
&gt; we wait, the scheduler will stop. If we don't have the lock, we don't even
&gt; start the timer.</span ></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>