<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Media Session: push paused state to the media session focus manager instead of polling"
   href="https://bugs.webkit.org/show_bug.cgi?id=147633#c4">Comment # 4</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Media Session: push paused state to the media session focus manager instead of polling"
   href="https://bugs.webkit.org/show_bug.cgi?id=147633">bug 147633</a>
              from <span class="vcard"><a class="email" href="mailto:mrajca&#64;apple.com" title="Matt Rajca &lt;mrajca&#64;apple.com&gt;"> <span class="fn">Matt Rajca</span></a>
</span></b>
        <pre>(In reply to <a href="show_bug.cgi?id=147633#c3">comment #3</a>)
<span class="quote">&gt; Comment on <span class=""><a href="attachment.cgi?id=258277&amp;action=diff" name="attach_258277" title="Patch">attachment 258277</a> <a href="attachment.cgi?id=258277&amp;action=edit" title="Patch">[details]</a></span>
&gt; Patch
&gt; 
&gt; View in context:
&gt; <a href="https://bugs.webkit.org/attachment.cgi?id=258277&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=258277&amp;action=review</a>
&gt; 
&gt; This looks good modulo my minor comments, but I am now a WK2 reviewer so
&gt; someone else will have to give the official r+.
&gt; 
&gt; &gt; Source/WebCore/Modules/webaudio/AudioContext.cpp:344
&gt; &gt; +#if ENABLE(MEDIA_SESSION)
&gt; &gt; +    document()-&gt;updateIsPlayingMedia(HTMLMediaElementUnknownID);
&gt; &gt; +#else
&gt; &gt; +    document()-&gt;updateIsPlayingMedia(0);
&gt; &gt; +#endif
&gt; 
&gt; Nit: if you don't guard HTMLMediaElementUnknownID with
&gt; &quot;ENABLE(MEDIA_SESSION)&quot; you won't need the #if here.</span >

Removed it to simplify subsequent code (1).

<span class="quote">&gt; 
&gt; Also, the name &quot;HTMLMediaElementUnknownID&quot; is not quite correct because it
&gt; isn't an HTMLMediaElement at all. Maybe HTMLMediaElementInvalidID?</span >

Renamed.

<span class="quote">&gt; 
&gt; &gt; Source/WebCore/Modules/webaudio/AudioContext.cpp:1085
&gt; &gt; +#if ENABLE(MEDIA_SESSION)
&gt; &gt; +            strongThis-&gt;document()-&gt;updateIsPlayingMedia(HTMLMediaElementUnknownID);
&gt; &gt; +#else
&gt; &gt; +            strongThis-&gt;document()-&gt;updateIsPlayingMedia(0);
&gt; &gt; +#endif
&gt; 
&gt; Ditto.</span >

Simplified this after fixing (1).

<span class="quote">&gt; 
&gt; &gt; Source/WebCore/dom/Document.cpp:3505
&gt; &gt; +#if ENABLE(MEDIA_SESSION)
&gt; &gt; +    updateIsPlayingMedia(HTMLMediaElementUnknownID);
&gt; &gt; +#else
&gt; &gt; +    updateIsPlayingMedia(0);
&gt; &gt; +#endif
&gt; 
&gt; Ditto.</span >

Simplified this after fixing (1).

<span class="quote">&gt; 
&gt; &gt; Source/WebCore/dom/Document.cpp:3516
&gt; &gt; +#if ENABLE(MEDIA_SESSION)
&gt; &gt; +    updateIsPlayingMedia(HTMLMediaElementUnknownID);
&gt; &gt; +#else
&gt; &gt; +    updateIsPlayingMedia(0);
&gt; &gt; +#endif
&gt; 
&gt; Ditto.</span >

Simplified this after fixing (1).

<span class="quote">&gt; 
&gt; &gt; Source/WebCore/dom/Document.cpp:3529
&gt; &gt; +    if (HTMLMediaElement* sourceElement = HTMLMediaElement::elementWithID(sourceElementID)) {
&gt; &gt; +        if (sourceElement-&gt;isPlaying())
&gt; &gt; +            state |= MediaProducer::IsSourcePlaying;
&gt; &gt; +    }
&gt; 
&gt; Nit: you can prevent the failed lookup by checking for
&gt; HTMLMediaElementUnknownID (or HTMLMediaElementInvalidID, or whatever you
&gt; use).</span >

I prefer just checking if the pointer is null (even if it's logically equivalent to checking for an invalid ID). Feels safer.

<span class="quote">&gt; 
&gt; &gt; Source/WebCore/page/MediaProducer.h:43
&gt; &gt; +#if ENABLE(MEDIA_SESSION)
&gt; &gt; +        IsSourcePlaying = 1 &lt;&lt; 6,
&gt; &gt; +#endif
&gt; 
&gt; I don't think you need to #if this flag.</span >

Removed.

<span class="quote">&gt; 
&gt; &gt; Source/WebKit2/UIProcess/WebPageProxy.cpp:5947
&gt; &gt; +    if (focusManager-&gt;focusedMediaElementPage() == this &amp;&amp; focusManager-&gt;focusedMediaElementID() == sourceElementID)
&gt; &gt; +        focusManager-&gt;setFocusedMediaElementIsPlaying(state &amp; MediaProducer::IsSourcePlaying);
&gt; 
&gt; This seems like the wrong place for this logic. Why not pass the element ID
&gt; into the focus manager so you can keep all of the focus logic there.</span >

Refactored.</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>