mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 16:25:38 +00:00
Bug 1184058 - AudioChannelAgent should be muted when used without a proper window object, r=alwu
This commit is contained in:
parent
b68734b7da
commit
338ccab7dc
@ -85,6 +85,8 @@ AudioChannelAgent::InitInternal(nsIDOMWindow* aWindow, int32_t aChannelType,
|
|||||||
nsIAudioChannelAgentCallback *aCallback,
|
nsIAudioChannelAgentCallback *aCallback,
|
||||||
bool aUseWeakRef)
|
bool aUseWeakRef)
|
||||||
{
|
{
|
||||||
|
MOZ_ASSERT(aWindow);
|
||||||
|
|
||||||
// We syncd the enum of channel type between nsIAudioChannelAgent.idl and
|
// We syncd the enum of channel type between nsIAudioChannelAgent.idl and
|
||||||
// AudioChannelBinding.h the same.
|
// AudioChannelBinding.h the same.
|
||||||
MOZ_ASSERT(int(AUDIO_AGENT_CHANNEL_NORMAL) == int(AudioChannel::Normal) &&
|
MOZ_ASSERT(int(AUDIO_AGENT_CHANNEL_NORMAL) == int(AudioChannel::Normal) &&
|
||||||
@ -103,17 +105,19 @@ AudioChannelAgent::InitInternal(nsIDOMWindow* aWindow, int32_t aChannelType,
|
|||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aWindow) {
|
nsCOMPtr<nsPIDOMWindow> pInnerWindow = do_QueryInterface(aWindow);
|
||||||
nsCOMPtr<nsPIDOMWindow> pInnerWindow = do_QueryInterface(aWindow);
|
MOZ_ASSERT(pInnerWindow->IsInnerWindow());
|
||||||
MOZ_ASSERT(pInnerWindow->IsInnerWindow());
|
mInnerWindowID = pInnerWindow->WindowID();
|
||||||
mInnerWindowID = pInnerWindow->WindowID();
|
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMWindow> topWindow;
|
nsCOMPtr<nsIDOMWindow> topWindow;
|
||||||
aWindow->GetScriptableTop(getter_AddRefs(topWindow));
|
aWindow->GetScriptableTop(getter_AddRefs(topWindow));
|
||||||
mWindow = do_QueryInterface(topWindow);
|
mWindow = do_QueryInterface(topWindow);
|
||||||
if (mWindow) {
|
if (mWindow) {
|
||||||
mWindow = mWindow->GetOuterWindow();
|
mWindow = mWindow->GetOuterWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!mWindow) {
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
mAudioChannelType = aChannelType;
|
mAudioChannelType = aChannelType;
|
||||||
@ -134,6 +138,13 @@ NS_IMETHODIMP AudioChannelAgent::NotifyStartedPlaying(uint32_t aNotifyPlayback,
|
|||||||
MOZ_ASSERT(aVolume);
|
MOZ_ASSERT(aVolume);
|
||||||
MOZ_ASSERT(aMuted);
|
MOZ_ASSERT(aMuted);
|
||||||
|
|
||||||
|
// Window-less AudioChannelAgents are muted by default.
|
||||||
|
if (!mWindow) {
|
||||||
|
*aVolume = 0;
|
||||||
|
*aMuted = true;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
nsRefPtr<AudioChannelService> service = AudioChannelService::GetOrCreate();
|
nsRefPtr<AudioChannelService> service = AudioChannelService::GetOrCreate();
|
||||||
if (mAudioChannelType == AUDIO_AGENT_CHANNEL_ERROR ||
|
if (mAudioChannelType == AUDIO_AGENT_CHANNEL_ERROR ||
|
||||||
service == nullptr || mIsRegToService) {
|
service == nullptr || mIsRegToService) {
|
||||||
|
Loading…
Reference in New Issue
Block a user