diff --git a/dom/audiochannel/AudioChannelAgent.cpp b/dom/audiochannel/AudioChannelAgent.cpp index a5d121bf0b1a..95f2f2d9710b 100644 --- a/dom/audiochannel/AudioChannelAgent.cpp +++ b/dom/audiochannel/AudioChannelAgent.cpp @@ -202,7 +202,8 @@ AudioChannelAgent::InitInternal(nsPIDOMWindowInner* aWindow, } NS_IMETHODIMP -AudioChannelAgent::NotifyStartedPlaying(AudioPlaybackConfig* aConfig) +AudioChannelAgent::NotifyStartedPlaying(AudioPlaybackConfig* aConfig, + bool aAudible) { if (NS_WARN_IF(!aConfig)) { return NS_ERROR_FAILURE; @@ -214,7 +215,10 @@ AudioChannelAgent::NotifyStartedPlaying(AudioPlaybackConfig* aConfig) return NS_ERROR_FAILURE; } - service->RegisterAudioChannelAgent(this); + MOZ_ASSERT(AudioChannelService::AudibleState::eAudible == true && + AudioChannelService::AudibleState::eNotAudible == false); + service->RegisterAudioChannelAgent(this, + static_cast(aAudible)); AudioPlaybackConfig config = service->GetMediaConfig(mWindow, mAudioChannelType); diff --git a/dom/audiochannel/AudioChannelService.cpp b/dom/audiochannel/AudioChannelService.cpp index 4c53c087853f..7a06281bff2d 100644 --- a/dom/audiochannel/AudioChannelService.cpp +++ b/dom/audiochannel/AudioChannelService.cpp @@ -248,7 +248,8 @@ AudioChannelService::~AudioChannelService() } void -AudioChannelService::RegisterAudioChannelAgent(AudioChannelAgent* aAgent) +AudioChannelService::RegisterAudioChannelAgent(AudioChannelAgent* aAgent, + AudibleState aAudible) { MOZ_ASSERT(aAgent); @@ -263,7 +264,7 @@ AudioChannelService::RegisterAudioChannelAgent(AudioChannelAgent* aAgent) // callback function of AudioChannelAgentOwner that means the agent might be // released in their callback. RefPtr kungFuDeathGrip(aAgent); - winData->AppendAgent(aAgent); + winData->AppendAgent(aAgent, aAudible); MaybeSendStatusUpdate(); } @@ -1001,13 +1002,14 @@ AudioChannelService::IsAudioChannelMutedByDefault() } void -AudioChannelService::AudioChannelWindow::AppendAgent(AudioChannelAgent* aAgent) +AudioChannelService::AudioChannelWindow::AppendAgent(AudioChannelAgent* aAgent, + AudibleState aAudible) { MOZ_ASSERT(aAgent); AppendAgentAndIncreaseAgentsNum(aAgent); AudioCapturedChanged(aAgent, AudioCaptureState::eCapturing); - // Audio-playback would be notified when the agent owner starts audible. + AudioAudibleChanged(aAgent, aAudible); } void diff --git a/dom/audiochannel/AudioChannelService.h b/dom/audiochannel/AudioChannelService.h index 87eb519d724d..3b4fd19f0293 100644 --- a/dom/audiochannel/AudioChannelService.h +++ b/dom/audiochannel/AudioChannelService.h @@ -93,7 +93,8 @@ public: * Any audio channel agent that starts playing should register itself to * this service, sharing the AudioChannel. */ - void RegisterAudioChannelAgent(AudioChannelAgent* aAgent); + void RegisterAudioChannelAgent(AudioChannelAgent* aAgent, + AudibleState aAudible); /** * Any audio channel agent that stops playing should unregister itself to @@ -244,7 +245,7 @@ private: void AudioAudibleChanged(AudioChannelAgent* aAgent, AudibleState aAudible); - void AppendAgent(AudioChannelAgent* aAgent); + void AppendAgent(AudioChannelAgent* aAgent, AudibleState aAudible); void RemoveAgent(AudioChannelAgent* aAgent); uint64_t mWindowID; diff --git a/dom/audiochannel/nsIAudioChannelAgent.idl b/dom/audiochannel/nsIAudioChannelAgent.idl index 5150c7c184b7..812e389d526e 100644 --- a/dom/audiochannel/nsIAudioChannelAgent.idl +++ b/dom/audiochannel/nsIAudioChannelAgent.idl @@ -163,7 +163,7 @@ interface nsIAudioChannelAgent : nsISupports * @param config * It contains the playback related states (volume/mute/suspend) */ - void notifyStartedPlaying(in AudioPlaybackConfig config); + void notifyStartedPlaying(in AudioPlaybackConfig config, in bool audible); /** * Notify the agent we no longer want to play.