mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1347758 - part4 : add audio channel log. r=Ehsan
MozReview-Commit-ID: 3zVYtD86O82 --HG-- extra : rebase_source : 3a7726760d6e4941cdbe2e6c9ee7132420482bb4
This commit is contained in:
parent
9685905d96
commit
d8197f5d08
@ -220,8 +220,10 @@ AudioChannelAgent::NotifyStartedPlaying(AudioPlaybackConfig* aConfig,
|
||||
|
||||
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
|
||||
("AudioChannelAgent, NotifyStartedPlaying, this = %p, "
|
||||
"audible = %d, mute = %d, volume = %f, suspend = %d\n", this,
|
||||
aAudible, config.mMuted, config.mVolume, config.mSuspend));
|
||||
"audible = %s, mute = %s, volume = %f, suspend = %s\n", this,
|
||||
AudibleStateToStr(static_cast<AudioChannelService::AudibleState>(aAudible)),
|
||||
config.mMuted ? "true" : "false", config.mVolume,
|
||||
SuspendTypeToStr(config.mSuspend)));
|
||||
|
||||
aConfig->SetConfig(config.mVolume, config.mMuted, config.mSuspend);
|
||||
mIsRegToService = true;
|
||||
@ -253,7 +255,9 @@ AudioChannelAgent::NotifyStartedAudible(uint8_t aAudible, uint32_t aReason)
|
||||
{
|
||||
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
|
||||
("AudioChannelAgent, NotifyStartedAudible, this = %p, "
|
||||
"audible = %d, reason = %d\n", this, aAudible, aReason));
|
||||
"audible = %s, reason = %s\n", this,
|
||||
AudibleStateToStr(static_cast<AudioChannelService::AudibleState>(aAudible)),
|
||||
AudibleChangedReasonToStr(static_cast<AudioChannelService::AudibleChangedReasons>(aReason))));
|
||||
|
||||
RefPtr<AudioChannelService> service = AudioChannelService::GetOrCreate();
|
||||
if (NS_WARN_IF(!service)) {
|
||||
@ -287,8 +291,9 @@ AudioChannelAgent::WindowVolumeChanged()
|
||||
|
||||
AudioPlaybackConfig config = GetMediaConfig();
|
||||
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
|
||||
("AudioChannelAgent, WindowVolumeChanged, this = %p, mute = %d, "
|
||||
"volume = %f\n", this, config.mMuted, config.mVolume));
|
||||
("AudioChannelAgent, WindowVolumeChanged, this = %p, mute = %s, "
|
||||
"volume = %f\n",
|
||||
this, config.mMuted ? "true" : "false", config.mVolume));
|
||||
|
||||
callback->WindowVolumeChanged(config.mVolume, config.mMuted);
|
||||
}
|
||||
@ -307,7 +312,7 @@ AudioChannelAgent::WindowSuspendChanged(nsSuspendedTypes aSuspend)
|
||||
|
||||
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
|
||||
("AudioChannelAgent, WindowSuspendChanged, this = %p, "
|
||||
"suspended = %d\n", this, aSuspend));
|
||||
"suspended = %s\n", this, SuspendTypeToStr(aSuspend)));
|
||||
|
||||
callback->WindowSuspendChanged(aSuspend);
|
||||
}
|
||||
|
@ -93,8 +93,8 @@ public:
|
||||
: u"inactive");
|
||||
|
||||
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
|
||||
("NotifyChannelActiveRunnable, type = %" PRIu32 ", active = %d\n",
|
||||
static_cast<uint32_t>(mAudioChannel), mActive));
|
||||
("NotifyChannelActiveRunnable, type = %" PRIu32 ", active = %s\n",
|
||||
static_cast<uint32_t>(mAudioChannel), mActive ? "true" : "false"));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -137,8 +137,8 @@ public:
|
||||
state.get());
|
||||
|
||||
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
|
||||
("AudioPlaybackRunnable, active = %d, reason = %d\n",
|
||||
mActive, mReason));
|
||||
("AudioPlaybackRunnable, active = %s, reason = %s\n",
|
||||
mActive ? "true" : "false", AudibleChangedReasonToStr(mReason)));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -180,6 +180,72 @@ IsEnableAudioCompetingForAllAgents()
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
const char*
|
||||
SuspendTypeToStr(const nsSuspendedTypes& aSuspend)
|
||||
{
|
||||
MOZ_ASSERT(aSuspend == nsISuspendedTypes::NONE_SUSPENDED ||
|
||||
aSuspend == nsISuspendedTypes::SUSPENDED_PAUSE ||
|
||||
aSuspend == nsISuspendedTypes::SUSPENDED_BLOCK ||
|
||||
aSuspend == nsISuspendedTypes::SUSPENDED_PAUSE_DISPOSABLE ||
|
||||
aSuspend == nsISuspendedTypes::SUSPENDED_STOP_DISPOSABLE);
|
||||
|
||||
switch (aSuspend) {
|
||||
case nsISuspendedTypes::NONE_SUSPENDED:
|
||||
return "none";
|
||||
case nsISuspendedTypes::SUSPENDED_PAUSE:
|
||||
return "pause";
|
||||
case nsISuspendedTypes::SUSPENDED_BLOCK:
|
||||
return "block";
|
||||
case nsISuspendedTypes::SUSPENDED_PAUSE_DISPOSABLE:
|
||||
return "disposable-pause";
|
||||
case nsISuspendedTypes::SUSPENDED_STOP_DISPOSABLE:
|
||||
return "disposable-stop";
|
||||
default:
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
const char*
|
||||
AudibleStateToStr(const AudioChannelService::AudibleState& aAudible)
|
||||
{
|
||||
MOZ_ASSERT(aAudible == AudioChannelService::AudibleState::eNotAudible ||
|
||||
aAudible == AudioChannelService::AudibleState::eMaybeAudible ||
|
||||
aAudible == AudioChannelService::AudibleState::eAudible);
|
||||
|
||||
switch (aAudible) {
|
||||
case AudioChannelService::AudibleState::eNotAudible :
|
||||
return "not-audible";
|
||||
case AudioChannelService::AudibleState::eMaybeAudible :
|
||||
return "maybe-audible";
|
||||
case AudioChannelService::AudibleState::eAudible :
|
||||
return "audible";
|
||||
default:
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
const char*
|
||||
AudibleChangedReasonToStr(const AudioChannelService::AudibleChangedReasons& aReason)
|
||||
{
|
||||
MOZ_ASSERT(aReason == AudioChannelService::AudibleChangedReasons::eVolumeChanged ||
|
||||
aReason == AudioChannelService::AudibleChangedReasons::eDataAudibleChanged ||
|
||||
aReason == AudioChannelService::AudibleChangedReasons::ePauseStateChanged);
|
||||
|
||||
switch (aReason) {
|
||||
case AudioChannelService::AudibleChangedReasons::eVolumeChanged :
|
||||
return "volume";
|
||||
case AudioChannelService::AudibleChangedReasons::eDataAudibleChanged :
|
||||
return "data-audible";
|
||||
case AudioChannelService::AudibleChangedReasons::ePauseStateChanged :
|
||||
return "pause-state";
|
||||
default:
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
StaticRefPtr<AudioChannelService> gAudioChannelService;
|
||||
|
||||
// Mappings from 'mozaudiochannel' attribute strings to an enumeration.
|
||||
@ -903,7 +969,8 @@ AudioChannelService::SetAudioChannelMuted(nsPIDOMWindowOuter* aWindow,
|
||||
|
||||
MOZ_LOG(GetAudioChannelLog(), LogLevel::Debug,
|
||||
("AudioChannelService, SetAudioChannelMuted, window = %p, type = %" PRIu32 ", "
|
||||
"mute = %d\n", aWindow, static_cast<uint32_t>(aAudioChannel), aMuted));
|
||||
"mute = %s\n", aWindow, static_cast<uint32_t>(aAudioChannel),
|
||||
aMuted ? "true" : "false"));
|
||||
|
||||
if (aAudioChannel == AudioChannel::System) {
|
||||
// Workaround for bug1183033, system channel type can always playback.
|
||||
@ -1144,8 +1211,8 @@ AudioChannelService::AudioChannelWindow::RequestAudioFocus(AudioChannelAgent* aA
|
||||
|
||||
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
|
||||
("AudioChannelWindow, RequestAudioFocus, this = %p, "
|
||||
"agent = %p, owning audio focus = %d\n",
|
||||
this, aAgent, mOwningAudioFocus));
|
||||
"agent = %p, owning audio focus = %s\n",
|
||||
this, aAgent, mOwningAudioFocus ? "true" : "false"));
|
||||
}
|
||||
|
||||
void
|
||||
@ -1246,7 +1313,7 @@ AudioChannelService::AudioChannelWindow::AudioFocusChanged(AudioChannelAgent* aN
|
||||
|
||||
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
|
||||
("AudioChannelWindow, AudioFocusChanged, this = %p, "
|
||||
"OwningAudioFocus = %d\n", this, mOwningAudioFocus));
|
||||
"OwningAudioFocus = %s\n", this, mOwningAudioFocus ? "true" : "false"));
|
||||
}
|
||||
|
||||
bool
|
||||
@ -1274,8 +1341,9 @@ AudioChannelService::AudioChannelWindow::GetCompetingBehavior(AudioChannelAgent*
|
||||
|
||||
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
|
||||
("AudioChannelWindow, GetCompetingBehavior, this = %p, "
|
||||
"present type = %d, incoming channel = %d, behavior = %d\n",
|
||||
this, presentChannelType, aIncomingChannelType, competingBehavior));
|
||||
"present type = %d, incoming channel = %d, behavior = %s\n",
|
||||
this, presentChannelType, aIncomingChannelType,
|
||||
SuspendTypeToStr(competingBehavior)));
|
||||
|
||||
return competingBehavior;
|
||||
}
|
||||
@ -1518,3 +1586,7 @@ AudioChannelService::AudioChannelWindow::MaybeNotifyMediaBlockStart(AudioChannel
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
|
@ -369,6 +369,10 @@ private:
|
||||
friend class ContentChild;
|
||||
};
|
||||
|
||||
const char* SuspendTypeToStr(const nsSuspendedTypes& aSuspend);
|
||||
const char* AudibleStateToStr(const AudioChannelService::AudibleState& aAudible);
|
||||
const char* AudibleChangedReasonToStr(const AudioChannelService::AudibleChangedReasons& aReason);
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
|
@ -4385,6 +4385,10 @@ nsPIDOMWindowOuter::MaybeActiveMediaComponents()
|
||||
return;
|
||||
}
|
||||
|
||||
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
|
||||
("nsPIDOMWindowOuter, MaybeActiveMediaComponents, "
|
||||
"resume the window from blocked, this = %p\n", this));
|
||||
|
||||
SetMediaSuspend(nsISuspendedTypes::NONE_SUSPENDED);
|
||||
}
|
||||
|
||||
|
@ -692,7 +692,8 @@ public:
|
||||
|
||||
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
|
||||
("HTMLMediaElement::AudioChannelAgentCallback, WindowVolumeChanged, "
|
||||
"this = %p, aVolume = %f, aMuted = %d\n", this, aVolume, aMuted));
|
||||
"this = %p, aVolume = %f, aMuted = %s\n",
|
||||
this, aVolume, aMuted ? "true" : "false"));
|
||||
|
||||
if (mAudioChannelVolume != aVolume) {
|
||||
mAudioChannelVolume = aVolume;
|
||||
@ -716,7 +717,7 @@ public:
|
||||
|
||||
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
|
||||
("HTMLMediaElement::AudioChannelAgentCallback, WindowSuspendChanged, "
|
||||
"this = %p, aSuspend = %d\n", this, aSuspend));
|
||||
"this = %p, aSuspend = %s\n", this, SuspendTypeToStr(aSuspend)));
|
||||
|
||||
switch (aSuspend) {
|
||||
case nsISuspendedTypes::NONE_SUSPENDED:
|
||||
@ -883,7 +884,7 @@ private:
|
||||
mSuspended = aSuspend;
|
||||
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
|
||||
("HTMLMediaElement::AudioChannelAgentCallback, SetAudioChannelSuspended, "
|
||||
"this = %p, aSuspend = %d\n", this, aSuspend));
|
||||
"this = %p, aSuspend = %s\n", this, SuspendTypeToStr(aSuspend)));
|
||||
|
||||
NotifyAudioPlaybackChanged(
|
||||
AudioChannelService::AudibleChangedReasons::ePauseStateChanged);
|
||||
|
@ -507,6 +507,11 @@ AudioDestinationNode::WindowVolumeChanged(float aVolume, bool aMuted)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
|
||||
("AudioDestinationNode, WindowVolumeChanged, "
|
||||
"this = %p, aVolume = %f, aMuted = %s\n",
|
||||
this, aVolume, aMuted ? "true" : "false"));
|
||||
|
||||
float volume = aMuted ? 0.0 : aVolume;
|
||||
mStream->SetAudioOutputVolume(&gWebAudioOutputKey, volume);
|
||||
return NS_OK;
|
||||
@ -524,6 +529,10 @@ AudioDestinationNode::WindowSuspendChanged(nsSuspendedTypes aSuspend)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
|
||||
("AudioDestinationNode, WindowSuspendChanged, "
|
||||
"this = %p, aSuspend = %s\n", this, SuspendTypeToStr(aSuspend)));
|
||||
|
||||
mAudioChannelSuspended = suspended;
|
||||
Context()->DispatchTrustedEvent(!suspended ?
|
||||
NS_LITERAL_STRING("mozinterruptend") :
|
||||
|
@ -1738,6 +1738,11 @@ nsNPAPIPluginInstance::GetOrCreateAudioChannelAgent(nsIAudioChannelAgent** aAgen
|
||||
NS_IMETHODIMP
|
||||
nsNPAPIPluginInstance::WindowVolumeChanged(float aVolume, bool aMuted)
|
||||
{
|
||||
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
|
||||
("nsNPAPIPluginInstance, WindowVolumeChanged, "
|
||||
"this = %p, aVolume = %f, aMuted = %s\n",
|
||||
this, aVolume, aMuted ? "true" : "false"));
|
||||
|
||||
// We just support mute/unmute
|
||||
nsresult rv = SetMuted(aMuted);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "SetMuted failed");
|
||||
@ -1757,6 +1762,10 @@ nsNPAPIPluginInstance::WindowVolumeChanged(float aVolume, bool aMuted)
|
||||
NS_IMETHODIMP
|
||||
nsNPAPIPluginInstance::WindowSuspendChanged(nsSuspendedTypes aSuspend)
|
||||
{
|
||||
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
|
||||
("nsNPAPIPluginInstance, WindowSuspendChanged, "
|
||||
"this = %p, aSuspend = %s\n", this, SuspendTypeToStr(aSuspend)));
|
||||
|
||||
// It doesn't support suspended, so we just do something like mute/unmute.
|
||||
WindowVolumeChanged(1.0, /* useless */
|
||||
aSuspend != nsISuspendedTypes::NONE_SUSPENDED);
|
||||
|
Loading…
Reference in New Issue
Block a user