mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1495064 - part2 : don't request wakelock for video without audio track. r=jya
There are often websites using videos without an audio track as background image or as GIF-like image. For these cases, we don't want to hold a wakelock. Differential Revision: https://phabricator.services.mozilla.com/D7215 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
985d65ec0c
commit
f9668b6e7e
@ -7763,6 +7763,7 @@ HTMLMediaElement::SetMediaInfo(const MediaInfo& aInfo)
|
|||||||
if (mAudioChannelWrapper) {
|
if (mAudioChannelWrapper) {
|
||||||
mAudioChannelWrapper->AudioCaptureStreamChangeIfNeeded();
|
mAudioChannelWrapper->AudioCaptureStreamChangeIfNeeded();
|
||||||
}
|
}
|
||||||
|
UpdateWakeLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -315,10 +315,19 @@ HTMLVideoElement::UpdateWakeLock()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
HTMLVideoElement::ShouldCreateVideoWakeLock() const
|
||||||
|
{
|
||||||
|
// Make sure we only request wake lock for video with audio track, because
|
||||||
|
// video without audio track is often used as background image which seems no
|
||||||
|
// need to hold a wakelock.
|
||||||
|
return HasVideo() && HasAudio();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
HTMLVideoElement::CreateVideoWakeLockIfNeeded()
|
HTMLVideoElement::CreateVideoWakeLockIfNeeded()
|
||||||
{
|
{
|
||||||
if (!mScreenWakeLock && HasVideo()) {
|
if (!mScreenWakeLock && ShouldCreateVideoWakeLock()) {
|
||||||
RefPtr<power::PowerManagerService> pmService =
|
RefPtr<power::PowerManagerService> pmService =
|
||||||
power::PowerManagerService::GetInstance();
|
power::PowerManagerService::GetInstance();
|
||||||
NS_ENSURE_TRUE_VOID(pmService);
|
NS_ENSURE_TRUE_VOID(pmService);
|
||||||
|
@ -164,6 +164,7 @@ protected:
|
|||||||
void WakeLockRelease() override;
|
void WakeLockRelease() override;
|
||||||
void UpdateWakeLock() override;
|
void UpdateWakeLock() override;
|
||||||
|
|
||||||
|
bool ShouldCreateVideoWakeLock() const;
|
||||||
void CreateVideoWakeLockIfNeeded();
|
void CreateVideoWakeLockIfNeeded();
|
||||||
void ReleaseVideoWakeLockIfExists();
|
void ReleaseVideoWakeLockIfExists();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user