Closed Bug 1759033 Opened 2 years ago Closed 2 years ago

Use a static helper to automatically start and shutdown Media Foundation

Categories

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

task

Tracking

()

RESOLVED FIXED
100 Branch
Tracking Status
firefox100 --- fixed

People

(Reporter: alwu, Assigned: alwu)

References

(Depends on 1 open bug)

Details

Attachments

(1 file)

According to [1], MFShutdown will shutdown the media foundation for every other calls of MFStartup, which means it's possible to shutdown the media foundation even if other components are still using that.

Therefore, we should consider to make the media foundation alive when the first time any component wants to use it, and shutdown it when the whole process destroys.

We already did similar thing on the RDD process [2] so it makes sense to do it as well on other places. Especially considering we will move the MFT decoder into the RDD process in the future, we definitely don't want an encoder incorrectly shutdown the media foundation while decoder is using it.

Also, it saves time to call MFStartup if the media foundation is already started.

[1] https://docs.microsoft.com/en-us/windows/win32/api/mfapi/nf-mfapi-mfshutdown
[2] https://searchfox.org/mozilla-central/rev/eeeba8183d3268e0d563c2becf9f4adc21a37368/dom/media/ipc/RDDParent.cpp#111,303,315

According to [1], MFShutdown will shutdown the media foundation for every other call of MFStartup, which means it's possible to shutdown the media foundation even if other components are still using that.

Therefore, we should consider make the media foundation alive when the first time any component wants to use it, and shutdown it when the whole process destroys.

We already did similar thing on the RDD process [2] so it makes sense to do it as well on other places. Especially considering we will move the MFT decoder into the RDD process in the future, we definitely don't want an encoder incorrectly shutdown the media foundation the decoder is using.

Also, it saves time to call MFStartup if the media foundation is already started.

[1] https://docs.microsoft.com/en-us/windows/win32/api/mfapi/nf-mfapi-mfshutdown
[2] https://searchfox.org/mozilla-central/rev/eeeba8183d3268e0d563c2becf9f4adc21a37368/dom/media/ipc/RDDParent.cpp#111,303,315

Pushed by alwu@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/65d5050fe312
no longer start or shutdown MediaFoundation explictly, and ensure the media foundation's life cycle long enough. r=bryce
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 100 Branch
Regressions: 1761959
Regressions: 1764065
No longer regressions: 1764065
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: