Closed Bug 1593131 Opened 4 months ago Closed 3 months ago

Start listening media key event only when we have media controller

Categories

(Core :: Audio/Video: Playback, task, P2)

task

Tracking

()

RESOLVED FIXED
mozilla72
Tracking Status
firefox72 --- fixed

People

(Reporter: alwu, Assigned: alwu)

References

(Blocks 1 open bug)

Details

Attachments

(6 files)

We found that some MediaControlKeysEventSource have a need to request some kind of focus from platform, in order to retrigger the event listening.

Therefore, instead of letting the event source to handle this issue directly, we can let MediaControlKeysManager to create an event source intelligently according to the MediaController number.

If there is one more controller in the media service, which means we have to listen the media key event in order to control them, then we would create an event source. Otherwise, we don't need to have an event source because nothing needs to be controlled. So event source could be created or destroyed dynamically according to the controller's amount.

As we have a need to know if there is any existing controller needs to be controlled in order to achieve dynamically creation and destruction of media keys event source. (that will be implemented in patch2)

Therefore, using the media event to send the current media controller amount when the total media controller amount changed in the media service.

In this patch, we dynamically create or destroy media keys event source according to the media controller amount.

We would create the event source when we have a controller which needs to be controlled, and destory the event source when there is no controllers existing.

In addition, create a Init() function for media service for calling any other owned module's initialization, which is used to ensure that we finish setting the gMediaControlService before any other classes call MediaControlService::GetService().

The event source in MediaControlKeysManager now is created dynamically, so that means sometime we don't have an event source to allow people add or remove listener.

Therefore, make MediaControlKeysManager being a wrapper of MediaControlKeysEventSource, it would manage all listeners and make sure add them to the real event source.

Attachment #9106431 - Attachment description: Bug 1593131 - part2 : dynamically create or destroy media keys event source according to the media controller amount → Bug 1593131 - part2 : dynamically create or destroy media keys event source according to the amount of media controller

Make MediaControlKeysEventListener and MediaControlKeysEventSource being a pure interface, then we can allow an usage such like inheritting from both MediaControlKeysEventListener and MediaControlKeysEventSource at the same time, which doesn't be allowed in old implementation because we can only have one parent class owning mRefCnt.

Attachment #9108155 - Attachment description: Bug 1593131 - part3 : inherit nsISupport to use ref counting. → Bug 1593131 - part3 : make 'MediaControlKeysEventListener' and 'MediaControlKeysEventSource' being a pure interface
Attachment #9106432 - Attachment description: Bug 1593131 - part3 : let mMediaControlKeysManager manage all listeners. → Bug 1593131 - part4 : make 'MediaControlKeysManager' being both an event source and listener.

To make sure it never happens.

Attachment #9108155 - Attachment description: Bug 1593131 - part3 : make 'MediaControlKeysEventListener' and 'MediaControlKeysEventSource' being a pure interface → Bug 1593131 - part3 : use nsISupport for ref counting
Pushed by alwu@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/d168bfd2524c
part1 : use media event to notity media controller amount changed. r=chunmin
https://hg.mozilla.org/integration/autoland/rev/222533f6446e
part2 : dynamically create or destroy media keys event source according to the amount of media controller  r=chunmin
https://hg.mozilla.org/integration/autoland/rev/9d1e133ed17c
part3 : use nsISupport for ref counting r=chunmin
https://hg.mozilla.org/integration/autoland/rev/103ad9fe9fea
part4 : make 'MediaControlKeysManager' being both an event source and listener. r=chunmin
https://hg.mozilla.org/integration/autoland/rev/55fe1b2e71c4
part5 : use unreachable assertion to replace debug log. r=chunmin
https://hg.mozilla.org/integration/autoland/rev/f0ceeb68fff9
part6 : modify log name. r=chunmin
You need to log in before you can comment on or make changes to this bug.