Bug 1578615 - part0.5 : simply the logic of "IsOwnerAudible()". r=chunmin
authoralwu <alwu@mozilla.com>
Wed, 25 Sep 2019 20:32:46 +0000
changeset 495042 750bba4665926d2c79f5bec1a5760d0e2362951f
parent 495041 c2c9dbf826fe7b81bc8535988d2a48570a43c7e3
child 495043 6690d621d726c579344ad9adbb3cd3bd8e092814
push id114131
push userdluca@mozilla.com
push dateThu, 26 Sep 2019 09:47:34 +0000
treeherdermozilla-inbound@1dc1a755079a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschunmin
bugs1578615
milestone71.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1578615 - part0.5 : simply the logic of "IsOwnerAudible()". r=chunmin There are some checking conditions can be reordered or simplified in order to remove some unnecessary check. Differential Revision: https://phabricator.services.mozilla.com/D47027
dom/html/HTMLMediaElement.cpp
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -1318,39 +1318,35 @@ class HTMLMediaElement::AudioChannelAgen
 
   bool IsSuspended() const {
     return (mSuspended == nsISuspendedTypes::SUSPENDED_PAUSE ||
             mSuspended == nsISuspendedTypes::SUSPENDED_PAUSE_DISPOSABLE ||
             mSuspended == nsISuspendedTypes::SUSPENDED_BLOCK);
   }
 
   AudibleState IsOwnerAudible() const {
-    // Muted or the volume should not be ~0
-    if (mOwner->mMuted || (std::fabs(mOwner->Volume()) <= 1e-7)) {
-      return mOwner->HasAudio()
-                 ? AudioChannelService::AudibleState::eMaybeAudible
-                 : AudioChannelService::AudibleState::eNotAudible;
-    }
-
     // No audio track.
     if (!mOwner->HasAudio()) {
       return AudioChannelService::AudibleState::eNotAudible;
     }
 
-    // Might be audible but not yet.
-    if (mOwner->HasAudio() && !mOwner->mIsAudioTrackAudible) {
+    // Muted or the volume should not be ~0
+    if (mOwner->mMuted || (std::fabs(mOwner->Volume()) <= 1e-7)) {
       return AudioChannelService::AudibleState::eMaybeAudible;
     }
 
     // Suspended or paused media doesn't produce any sound.
     if (mSuspended != nsISuspendedTypes::NONE_SUSPENDED || mOwner->mPaused) {
       return AudioChannelService::AudibleState::eNotAudible;
     }
 
-    return AudioChannelService::AudibleState::eAudible;
+    // Might be audible but not yet.
+    return mOwner->mIsAudioTrackAudible
+               ? AudioChannelService::AudibleState::eAudible
+               : AudioChannelService::AudibleState::eMaybeAudible;
   }
 
   bool IsPlayingThroughTheAudioChannel() const {
     // If we have an error, we are not playing.
     if (mOwner->GetError()) {
       return false;
     }