зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1579588
- part1 : split NotifyAudioChannelAgent() to StartAudioChannelAgent() and StopAudioChanelAgent(). r=chunmin
Spliting NotifyAudioChannelAgent() to StartAudioChannelAgent() and StopAudioChanelAgent() allows us to start and stop an AudioChannelAgent in a clear naming function, and to do related operation and checking every time we start/stop the agent. Differential Revision: https://phabricator.services.mozilla.com/D45590 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
b4ce4fda42
Коммит
a54c7c082a
|
@ -1005,7 +1005,11 @@ class HTMLMediaElement::AudioChannelAgentCallback final
|
|||
}
|
||||
|
||||
mPlayingThroughTheAudioChannel = playingThroughTheAudioChannel;
|
||||
NotifyAudioChannelAgent(mPlayingThroughTheAudioChannel);
|
||||
if (mPlayingThroughTheAudioChannel) {
|
||||
StartAudioChannelAgent();
|
||||
} else {
|
||||
StopAudioChanelAgent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1145,10 +1149,10 @@ class HTMLMediaElement::AudioChannelAgentCallback final
|
|||
|
||||
void Shutdown() {
|
||||
MOZ_ASSERT(!mIsShutDown);
|
||||
if (mAudioChannelAgent) {
|
||||
mAudioChannelAgent->NotifyStoppedPlaying();
|
||||
mAudioChannelAgent = nullptr;
|
||||
if (mAudioChannelAgent && mAudioChannelAgent->IsPlayingStarted()) {
|
||||
StopAudioChanelAgent();
|
||||
}
|
||||
mAudioChannelAgent = nullptr;
|
||||
mIsShutDown = true;
|
||||
}
|
||||
|
||||
|
@ -1186,22 +1190,23 @@ class HTMLMediaElement::AudioChannelAgentCallback final
|
|||
return true;
|
||||
}
|
||||
|
||||
void NotifyAudioChannelAgent(bool aPlaying) {
|
||||
void StartAudioChannelAgent() {
|
||||
MOZ_ASSERT(mAudioChannelAgent);
|
||||
|
||||
if (aPlaying) {
|
||||
AudioPlaybackConfig config;
|
||||
nsresult rv =
|
||||
mAudioChannelAgent->NotifyStartedPlaying(&config, IsOwnerAudible());
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return;
|
||||
}
|
||||
|
||||
WindowVolumeChanged(config.mVolume, config.mMuted);
|
||||
WindowSuspendChanged(config.mSuspend);
|
||||
} else {
|
||||
mAudioChannelAgent->NotifyStoppedPlaying();
|
||||
MOZ_ASSERT(!mAudioChannelAgent->IsPlayingStarted());
|
||||
AudioPlaybackConfig config;
|
||||
if (NS_WARN_IF(NS_FAILED(mAudioChannelAgent->NotifyStartedPlaying(
|
||||
&config, IsOwnerAudible())))) {
|
||||
return;
|
||||
}
|
||||
|
||||
WindowVolumeChanged(config.mVolume, config.mMuted);
|
||||
WindowSuspendChanged(config.mSuspend);
|
||||
}
|
||||
|
||||
void StopAudioChanelAgent() {
|
||||
MOZ_ASSERT(mAudioChannelAgent);
|
||||
MOZ_ASSERT(mAudioChannelAgent->IsPlayingStarted());
|
||||
mAudioChannelAgent->NotifyStoppedPlaying();
|
||||
}
|
||||
|
||||
void SetSuspended(SuspendTypes aSuspend) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче