Bug 147008

Summary: Media Session: add support for platform-specific interruption providers
Product: WebKit Reporter: Matt Rajca <mrajca>
Component: MediaAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: conrad_shultz, eric.carlson, mrajca, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Bug Depends on:    
Bug Blocks: 145411    
Attachments:
Description Flags
Patch eric.carlson: review+

Description Matt Rajca 2015-07-16 11:12:14 PDT
Interruption providers will notify media sessions of start/end-of-interruption events.
Comment 1 Matt Rajca 2015-07-16 11:27:54 PDT
Created attachment 256916 [details]
Patch
Comment 2 Radar WebKit Bug Importer 2015-07-16 11:29:12 PDT
<rdar://problem/21858652>
Comment 3 Eric Carlson 2015-07-16 11:40:14 PDT
Comment on attachment 256916 [details]
Patch

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

> Source/WebCore/ChangeLog:9
> +        * platform/audio/MediaSessionInterruptionProvider.cpp: Added base class to be used by MediaSessionManager to

Nit: This isn't audio-specific, so why don't you put it into a new "platform/mediasession" directory?

> Source/WebCore/platform/audio/MediaSessionInterruptionProvider.cpp:37
> +MediaSessionInterruptionProvider::MediaSessionInterruptionProvider(MediaSessionInterruptionProviderClient& client)
> +    : m_client(&client)
> +{
> +    beginListeningForInterruptions();
> +}

Will there ever be more than one interruption provider? If so, what is the lifetime of an object - who creates it?

If there will only ever be one, you need a static accessor method and you need a way to add/remove clients.
Comment 4 Matt Rajca 2015-07-16 13:43:51 PDT
(In reply to comment #3)
> Comment on attachment 256916 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=256916&action=review
> 
> > Source/WebCore/ChangeLog:9
> > +        * platform/audio/MediaSessionInterruptionProvider.cpp: Added base class to be used by MediaSessionManager to
> 
> Nit: This isn't audio-specific, so why don't you put it into a new
> "platform/mediasession" directory?

Will do.

> 
> > Source/WebCore/platform/audio/MediaSessionInterruptionProvider.cpp:37
> > +MediaSessionInterruptionProvider::MediaSessionInterruptionProvider(MediaSessionInterruptionProviderClient& client)
> > +    : m_client(&client)
> > +{
> > +    beginListeningForInterruptions();
> > +}
> 
> Will there ever be more than one interruption provider? If so, what is the
> lifetime of an object - who creates it?

The interruption provider will only be used by the MediaSessionManager singleton (there will only be one client).

> 
> If there will only ever be one, you need a static accessor method and you
> need a way to add/remove clients.
Comment 5 Eric Carlson 2015-07-16 14:11:54 PDT
Comment on attachment 256916 [details]
Patch

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

> Source/WebCore/platform/audio/MediaSessionInterruptionProvider.h:57
> +    // To be overriden by subclasses.
> +    virtual void beginListeningForInterruptions();
> +    virtual void stopListeningForInterruptions();

If these must be overridden, why not make the pure-virtual?

> Source/WebCore/platform/audio/mac/MediaSessionInterruptionProviderMac.h:37
> +    using MediaSessionInterruptionProvider::MediaSessionInterruptionProvider;

Is this necessary?
Comment 6 Matt Rajca 2015-07-16 16:19:31 PDT
(In reply to comment #5)
> Comment on attachment 256916 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=256916&action=review
> 
> > Source/WebCore/platform/audio/MediaSessionInterruptionProvider.h:57
> > +    // To be overriden by subclasses.
> > +    virtual void beginListeningForInterruptions();
> > +    virtual void stopListeningForInterruptions();
> 
> If these must be overridden, why not make the pure-virtual?

These methods are called from the base class's constructor and destructor so they cannot be pure virtual.

> 
> > Source/WebCore/platform/audio/mac/MediaSessionInterruptionProviderMac.h:37
> > +    using MediaSessionInterruptionProvider::MediaSessionInterruptionProvider;
> 
> Is this necessary?

Yes, constructors aren't inherited.
Comment 7 Matt Rajca 2015-07-16 16:28:42 PDT
Committed r186917: <http://trac.webkit.org/changeset/186917>