diff --git a/dom/html/HTMLMediaElement.cpp b/dom/html/HTMLMediaElement.cpp index a2471b67b9e4..493bbd26678a 100644 --- a/dom/html/HTMLMediaElement.cpp +++ b/dom/html/HTMLMediaElement.cpp @@ -2055,8 +2055,7 @@ HTMLMediaElement::HTMLMediaElement(already_AddRefed& aNo mPlayingThroughTheAudioChannel(false), mDisableVideo(false), mPlayBlockedBecauseHidden(false), - mElementInTreeState(ELEMENT_NOT_INTREE), - mHaveDispatchedInterruptBeginEvent(false) + mElementInTreeState(ELEMENT_NOT_INTREE) { if (!gMediaElementLog) { gMediaElementLog = PR_NewLogModule("nsMediaElement"); @@ -4452,12 +4451,10 @@ nsresult HTMLMediaElement::UpdateChannelMuteState(float aVolume, bool aMuted) 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; + if (UseAudioChannelAPI()) { DispatchAsyncEvent(NS_LITERAL_STRING("mozinterruptend")); } } diff --git a/dom/html/HTMLMediaElement.h b/dom/html/HTMLMediaElement.h index 80aeac5a5c20..84f4ed0d9cd8 100644 --- a/dom/html/HTMLMediaElement.h +++ b/dom/html/HTMLMediaElement.h @@ -1414,8 +1414,6 @@ protected: ElementInTreeState mElementInTreeState; - bool mHaveDispatchedInterruptBeginEvent; - public: // Helper class to measure times for MSE telemetry stats class TimeDurationAccumulator { diff --git a/dom/media/webaudio/AudioDestinationNode.cpp b/dom/media/webaudio/AudioDestinationNode.cpp index a7c328d4f41f..95ab1b413459 100644 --- a/dom/media/webaudio/AudioDestinationNode.cpp +++ b/dom/media/webaudio/AudioDestinationNode.cpp @@ -326,7 +326,6 @@ AudioDestinationNode::AudioDestinationNode(AudioContext* aContext, , mExtraCurrentTime(0) , mExtraCurrentTimeSinceLastStartedBlocking(0) , mExtraCurrentTimeUpdatedSinceLastStableState(false) - , mHaveDispatchedInterruptBeginEvent(false) { bool startWithAudioDriver = true; MediaStreamGraph* graph = aIsOffline ? @@ -495,12 +494,10 @@ AudioDestinationNode::WindowVolumeChanged(float aVolume, bool aMuted) if (aMuted != mAudioChannelAgentPlaying) { mAudioChannelAgentPlaying = aMuted; - if (UseAudioChannelAPI() && - (mHaveDispatchedInterruptBeginEvent || aMuted)) { + if (UseAudioChannelAPI()) { Context()->DispatchTrustedEvent( !aMuted ? NS_LITERAL_STRING("mozinterruptend") : NS_LITERAL_STRING("mozinterruptbegin")); - mHaveDispatchedInterruptBeginEvent = aMuted; } } diff --git a/dom/media/webaudio/AudioDestinationNode.h b/dom/media/webaudio/AudioDestinationNode.h index 9fecfbb19d78..db5418a9cb51 100644 --- a/dom/media/webaudio/AudioDestinationNode.h +++ b/dom/media/webaudio/AudioDestinationNode.h @@ -111,7 +111,6 @@ private: double mExtraCurrentTime; double mExtraCurrentTimeSinceLastStartedBlocking; bool mExtraCurrentTimeUpdatedSinceLastStableState; - bool mHaveDispatchedInterruptBeginEvent; }; } // namespace dom diff --git a/dom/telephony/Telephony.cpp b/dom/telephony/Telephony.cpp index 1349b6e464fb..d3146b5890b2 100644 --- a/dom/telephony/Telephony.cpp +++ b/dom/telephony/Telephony.cpp @@ -21,7 +21,7 @@ #include "nsServiceManagerUtils.h" #include "nsThreadUtils.h" -#include "AudioChannelService.h" +#include "AudioChannelAgent.h" #include "CallsList.h" #include "TelephonyCall.h" #include "TelephonyCallGroup.h" @@ -65,8 +65,7 @@ public: Telephony::Telephony(nsPIDOMWindow* aOwner) : DOMEventTargetHelper(aOwner), - mIsAudioStartPlaying(false), - mHaveDispatchedInterruptBeginEvent(false) + mIsAudioStartPlaying(false) { MOZ_ASSERT(aOwner); nsCOMPtr global = do_QueryInterface(aOwner); @@ -77,7 +76,6 @@ Telephony::Telephony(nsPIDOMWindow* aOwner) MOZ_ASSERT(!rv.Failed()); mReadyPromise = promise; - mMuted = AudioChannelService::IsAudioChannelMutedByDefault(); } Telephony::~Telephony() @@ -682,21 +680,6 @@ Telephony::WindowVolumeChanged(float aVolume, bool aMuted) return rv.StealNSResult(); } - // These events will be triggered when the telephony is interrupted by other - // audio channel. - if (mMuted != aMuted) { - mMuted = aMuted; - // We should not dispatch "mozinterruptend" when the system app initializes - // the telephony audio from muted to unmuted at the first time. The event - // "mozinterruptend" must be dispatched after the "mozinterruptbegin". - if (!mHaveDispatchedInterruptBeginEvent && mMuted) { - DispatchTrustedEvent(NS_LITERAL_STRING("mozinterruptbegin")); - mHaveDispatchedInterruptBeginEvent = mMuted; - } else if (mHaveDispatchedInterruptBeginEvent && !mMuted) { - DispatchTrustedEvent(NS_LITERAL_STRING("mozinterruptend")); - mHaveDispatchedInterruptBeginEvent = mMuted; - } - } return NS_OK; } diff --git a/dom/telephony/Telephony.h b/dom/telephony/Telephony.h index d4a84e1615d9..f295461414e8 100644 --- a/dom/telephony/Telephony.h +++ b/dom/telephony/Telephony.h @@ -59,8 +59,6 @@ class Telephony final : public DOMEventTargetHelper, nsRefPtr mReadyPromise; bool mIsAudioStartPlaying; - bool mHaveDispatchedInterruptBeginEvent; - bool mMuted; public: NS_DECL_ISUPPORTS_INHERITED