Bug 1129882 - only send mozinterrupt when interrupt happens. r=baku.

This commit is contained in:
Alastor Wu 2015-07-24 17:36:34 +08:00
parent 9401ab6f5a
commit 2b0990fe9b
3 changed files with 20 additions and 17 deletions

View File

@ -2025,7 +2025,8 @@ HTMLMediaElement::HTMLMediaElement(already_AddRefed<mozilla::dom::NodeInfo>& aNo
mAutoplaying(true),
mAutoplayEnabled(true),
mPaused(true),
mMuted(0),
mMuted(AudioChannelService::IsAudioChannelMutedByDefault()
? MUTED_BY_AUDIO_CHANNEL : 0),
mStatsShowing(false),
mAllowCasting(false),
mIsCasting(false),
@ -4447,18 +4448,20 @@ nsresult HTMLMediaElement::UpdateChannelMuteState(float aVolume, bool aMuted)
SetVolumeInternal();
}
// We have to mute this channel.
if (aMuted && !ComputedMuted()) {
SetMutedInternal(mMuted | MUTED_BY_AUDIO_CHANNEL);
if (UseAudioChannelAPI()) {
DispatchAsyncEvent(NS_LITERAL_STRING("mozinterruptbegin"));
mHaveDispatchedInterruptBeginEvent = true;
}
} else if (!aMuted && ComputedMuted()) {
SetMutedInternal(mMuted & ~MUTED_BY_AUDIO_CHANNEL);
if (UseAudioChannelAPI() && mHaveDispatchedInterruptBeginEvent) {
mHaveDispatchedInterruptBeginEvent = false;
DispatchAsyncEvent(NS_LITERAL_STRING("mozinterruptend"));
if (aMuted != ComputedMuted()) {
// We have to mute this channel.
if (aMuted && !ComputedMuted()) {
SetMutedInternal(mMuted | MUTED_BY_AUDIO_CHANNEL);
if (UseAudioChannelAPI() && !mHaveDispatchedInterruptBeginEvent) {
DispatchAsyncEvent(NS_LITERAL_STRING("mozinterruptbegin"));
mHaveDispatchedInterruptBeginEvent = true;
}
} else if (!aMuted && ComputedMuted()) {
SetMutedInternal(mMuted & ~MUTED_BY_AUDIO_CHANNEL);
if (UseAudioChannelAPI() && mHaveDispatchedInterruptBeginEvent) {
mHaveDispatchedInterruptBeginEvent = false;
DispatchAsyncEvent(NS_LITERAL_STRING("mozinterruptend"));
}
}
}

View File

@ -322,7 +322,7 @@ AudioDestinationNode::AudioDestinationNode(AudioContext* aContext,
, mFramesToProduce(aLength)
, mAudioChannel(AudioChannel::Normal)
, mIsOffline(aIsOffline)
, mAudioChannelAgentPlaying(false)
, mAudioChannelAgentMuted(AudioChannelService::IsAudioChannelMutedByDefault())
, mExtraCurrentTime(0)
, mExtraCurrentTimeSinceLastStartedBlocking(0)
, mExtraCurrentTimeUpdatedSinceLastStableState(false)
@ -492,8 +492,8 @@ AudioDestinationNode::SetCanPlay(float aVolume, bool aMuted)
NS_IMETHODIMP
AudioDestinationNode::WindowVolumeChanged(float aVolume, bool aMuted)
{
if (aMuted != mAudioChannelAgentPlaying) {
mAudioChannelAgentPlaying = aMuted;
if (aMuted != mAudioChannelAgentMuted) {
mAudioChannelAgentMuted = aMuted;
if (UseAudioChannelAPI() &&
(mHaveDispatchedInterruptBeginEvent || aMuted)) {

View File

@ -105,7 +105,7 @@ private:
// Audio Channel Type.
AudioChannel mAudioChannel;
bool mIsOffline;
bool mAudioChannelAgentPlaying;
bool mAudioChannelAgentMuted;
TimeStamp mStartedBlockingDueToBeingOnlyNode;
double mExtraCurrentTime;