Bug 1222902 - Create log system for the AudioChannel. r=baku

This commit is contained in:
Alastor Wu 2015-11-10 14:43:59 +08:00
parent 120469e1be
commit 4c59db9d25
6 changed files with 56 additions and 0 deletions

View File

@ -130,6 +130,11 @@ AudioChannelAgent::InitInternal(nsIDOMWindow* aWindow, int32_t aChannelType,
mCallback = aCallback;
}
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
("AudioChannelAgent, InitInternal, this = %p, type = %d, "
"owner = %p, hasCallback = %d\n", this, mAudioChannelType,
mWindow.get(), (!!mCallback || !!mWeakCallback)));
return NS_OK;
}
@ -158,6 +163,10 @@ NS_IMETHODIMP AudioChannelAgent::NotifyStartedPlaying(uint32_t aNotifyPlayback,
service->GetState(mWindow, mAudioChannelType, aVolume, aMuted);
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
("AudioChannelAgent, NotifyStartedPlaying, this = %p, mute = %d, "
"volume = %f\n", this, *aMuted, *aVolume));
mNotifyPlayback = aNotifyPlayback;
mIsRegToService = true;
return NS_OK;
@ -170,6 +179,9 @@ NS_IMETHODIMP AudioChannelAgent::NotifyStoppedPlaying()
return NS_ERROR_FAILURE;
}
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
("AudioChannelAgent, NotifyStoppedPlaying, this = %p\n", this));
RefPtr<AudioChannelService> service = AudioChannelService::GetOrCreate();
service->UnregisterAudioChannelAgent(this, mNotifyPlayback);
mIsRegToService = false;
@ -200,6 +212,10 @@ AudioChannelAgent::WindowVolumeChanged()
RefPtr<AudioChannelService> service = AudioChannelService::GetOrCreate();
service->GetState(mWindow, mAudioChannelType, &volume, &muted);
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
("AudioChannelAgent, WindowVolumeChanged, this = %p, mute = %d, "
"volume = %f\n", this, muted, volume));
callback->WindowVolumeChanged(volume, muted);
}

View File

@ -78,6 +78,11 @@ public:
mActive
? MOZ_UTF16("active")
: MOZ_UTF16("inactive"));
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
("NotifyChannelActiveRunnable, type = %d, active = %d\n",
mAudioChannel, mActive));
return NS_OK;
}
@ -178,6 +183,16 @@ AudioChannelService::GetOrCreate()
return service.forget();
}
/* static */ PRLogModuleInfo*
AudioChannelService::GetAudioChannelLog()
{
static PRLogModuleInfo *gAudioChannelLog;
if (!gAudioChannelLog) {
gAudioChannelLog = PR_NewLogModule("AudioChannel");
}
return gAudioChannelLog;
}
void
AudioChannelService::Shutdown()
{
@ -719,6 +734,10 @@ AudioChannelService::SetAudioChannelVolume(nsPIDOMWindow* aWindow,
MOZ_ASSERT(aWindow);
MOZ_ASSERT(aWindow->IsOuterWindow());
MOZ_LOG(GetAudioChannelLog(), LogLevel::Debug,
("AudioChannelService, SetAudioChannelVolume, window = %p, type = %d, "
"volume = %d\n", aWindow, aAudioChannel, aVolume));
AudioChannelWindow* winData = GetOrCreateWindowData(aWindow);
winData->mChannels[(uint32_t)aAudioChannel].mVolume = aVolume;
RefreshAgentsVolume(aWindow);
@ -773,6 +792,10 @@ AudioChannelService::SetAudioChannelMuted(nsPIDOMWindow* aWindow,
MOZ_ASSERT(aWindow);
MOZ_ASSERT(aWindow->IsOuterWindow());
MOZ_LOG(GetAudioChannelLog(), LogLevel::Debug,
("AudioChannelService, SetAudioChannelMuted, window = %p, type = %d, "
"mute = %d\n", aWindow, aAudioChannel, aMuted));
if (aAudioChannel == AudioChannel::System) {
// Workaround for bug1183033, system channel type can always playback.
return;

View File

@ -19,6 +19,7 @@
class nsIRunnable;
class nsPIDOMWindow;
class PRLogModuleInfo;
namespace mozilla {
namespace dom {
@ -45,6 +46,8 @@ public:
static bool IsAudioChannelMutedByDefault();
static PRLogModuleInfo* GetAudioChannelLog();
/**
* Any audio channel agent that starts playing should register itself to
* this service, sharing the AudioChannel.

View File

@ -68,6 +68,10 @@ BrowserElementAudioChannel::Create(nsPIDOMWindow* aWindow,
return nullptr;
}
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
("BrowserElementAudioChannel, Create, channel = %p, type = %d\n",
ac.get(), aAudioChannel));
return ac.forget();
}
@ -608,6 +612,10 @@ BrowserElementAudioChannel::Observe(nsISupports* aSubject, const char* aTopic,
void
BrowserElementAudioChannel::ProcessStateChanged(const char16_t* aData)
{
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
("BrowserElementAudioChannel, ProcessStateChanged, this = %p, "
"type = %d\n", this, mAudioChannel));
nsAutoString value(aData);
mState = value.EqualsASCII("active") ? eStateActive : eStateInactive;
DispatchTrustedEvent(NS_LITERAL_STRING("activestatechanged"));

View File

@ -563,6 +563,9 @@ nsBrowserElement::GetAllowedAudioChannels(
return;
}
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
("nsBrowserElement, GetAllowedAudioChannels, this = %p\n", this));
GenerateAllowedAudioChannels(window, frameLoader, mBrowserElementAPI,
manifestURL, mBrowserElementAudioChannels,
aRv);

View File

@ -693,6 +693,9 @@ TabChild::Observe(nsISupports *aSubject,
// In theory a tabChild should contain just 1 top window, but let's double
// check it comparing the windowID.
if (window->WindowID() != windowID) {
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
("TabChild, Observe, different windowID, owner ID = %lld, "
"ID from wrapper = %lld", window->WindowID(), windowID));
return NS_OK;
}