Bug 1214659 - HTMLMediaElement::UpdateAudioChannelPlayingState() should be easy to read, r=roc

This commit is contained in:
Andrea Marchesini
2015-10-15 00:59:00 +02:00
parent 7419a8a820
commit 0ed5d72754
2 changed files with 37 additions and 8 deletions

View File

@@ -4714,17 +4714,43 @@ HTMLMediaElement::MaybeCreateAudioChannelAgent()
return true;
}
bool
HTMLMediaElement::IsPlayingThroughTheAudioChannel() const
{
// Are we paused or muted
if (mPaused || Muted()) {
return false;
}
// The volume should not be ~0
if (std::fabs(Volume()) <= 1e-7) {
return false;
}
// A loop always is playing
if (HasAttr(kNameSpaceID_None, nsGkAtoms::loop)) {
return true;
}
// If we are actually playing...
if (mReadyState >= nsIDOMHTMLMediaElement::HAVE_CURRENT_DATA &&
!IsPlaybackEnded()) {
return true;
}
// If we are seeking, we consider it as playing
if (mPlayingThroughTheAudioChannelBeforeSeek) {
return true;
}
return false;
}
void
HTMLMediaElement::UpdateAudioChannelPlayingState()
{
bool playingThroughTheAudioChannel =
(!mPaused &&
!Muted() &&
std::fabs(Volume()) > 1e-7 &&
(HasAttr(kNameSpaceID_None, nsGkAtoms::loop) ||
(mReadyState >= nsIDOMHTMLMediaElement::HAVE_CURRENT_DATA &&
!IsPlaybackEnded()) ||
mPlayingThroughTheAudioChannelBeforeSeek));
bool playingThroughTheAudioChannel = IsPlayingThroughTheAudioChannel();
if (playingThroughTheAudioChannel != mPlayingThroughTheAudioChannel) {
mPlayingThroughTheAudioChannel = playingThroughTheAudioChannel;