Bug 144332

Summary: [Mac] Simplify code to support media engines which do not support target playback
Product: WebKit Reporter: Eric Carlson <eric.carlson>
Component: MediaAssignee: Eric Carlson <eric.carlson>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Proposed patch
none
Rebased patch.
jer.noble: review+
Patch for landing none

Description Eric Carlson 2015-04-28 08:35:54 PDT
Simplify the code added in r182240 to support media engines that do not support a playback target.
Comment 1 Radar WebKit Bug Importer 2015-04-28 08:37:57 PDT
<rdar://problem/20727457>
Comment 2 Eric Carlson 2015-04-28 11:24:19 PDT
Created attachment 251868 [details]
Proposed patch
Comment 3 Eric Carlson 2015-04-28 12:07:54 PDT
Created attachment 251873 [details]
Rebased patch.
Comment 4 WebKit Commit Bot 2015-04-28 12:10:06 PDT
Attachment 251873 [details] did not pass style-queue:


ERROR: Source/WebCore/html/HTMLMediaSession.cpp:207:  Missing space before {  [whitespace/braces] [5]
Total errors found: 1 in 9 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 5 Jer Noble 2015-04-28 12:36:26 PDT
Comment on attachment 251873 [details]
Rebased patch.

View in context: https://bugs.webkit.org/attachment.cgi?id=251873&action=review

r=me, with nits:

> Source/WebCore/html/HTMLMediaElement.cpp:748
> +    if (m_pendingActionFlags & StopPlayingToTarget) {
> +        if (m_player && m_player->isCurrentPlaybackTargetWireless() && !m_player->canPlayToWirelessPlaybackTarget()) {

No need to nest these if statements.

> Source/WebCore/html/HTMLMediaElement.cpp:4899
> +    RefPtr<Event> event = prpEvent;
> +    bool cancelled = HTMLElement::dispatchEvent(event);
> +
> +    if (event->type() != eventNames().webkitcurrentplaybacktargetiswirelesschangedEvent)
> +        return cancelled;
> +    if (!m_player || !m_player->isCurrentPlaybackTargetWireless() || m_player->canPlayToWirelessPlaybackTarget())
> +        return cancelled;
> +
> +    scheduleDelayedAction(StopPlayingToTarget);

Since we have to double check these have to be double-checked anyway inside of pendingActionTimerFired(), could we just re-write this to be?:

if (event->type() == eventNames().webkitcurrentplaybacktargetiswirelesschangedEvent)
    scheduleDelayedAction(StopPlayingToTarget);
return HTMLElement::dispatchEvent(event);

> Source/WebCore/html/HTMLMediaElement.cpp:5905
> -    return potentiallyPlaying() ? requestedPlaybackRate() : 0;
> +    double requestedPlaybackRate = this->requestedPlaybackRate();
> +    bool potentiallyPlaying = this->potentiallyPlaying();
> +    LOG(Media, "HTMLMediaElement::mediaPlayerRequestedPlaybackRate(%p) - potentiallyPlaying = %s, returning %f", this, boolString(potentiallyPlaying), requestedPlaybackRate);
> +    return potentiallyPlaying ? requestedPlaybackRate : 0;

Seems like this logging may potentially be very noisy.

> Source/WebCore/html/HTMLMediaSession.cpp:385
> -    setWirelessVideoPlaybackDisabled(element, m_restrictions & WirelessVideoPlaybackDisabled);
> +    if (m_restrictions & WirelessVideoPlaybackDisabled)
> +        setWirelessVideoPlaybackDisabled(element, true);

Is there some reason we're no longer setting this to false if the restriction has been lifted?
Comment 6 Eric Carlson 2015-04-28 14:34:24 PDT
Created attachment 251888 [details]
Patch for landing
Comment 7 Eric Carlson 2015-04-28 14:42:08 PDT
Committed r183509: https://trac.webkit.org/r183509