Bug 1302350 - part2 : provide a method to check whether the agent was started. r=baku

Since the agent is created in beginning in patch1, we need another way to know
whether we have already called notifyStartedPlaying().

MozReview-Commit-ID: 5YNhwEl5Xfp

--HG--
extra : rebase_source : 6a2913e5d81591faf1a7383d9fcb9db2cf3f83d3
This commit is contained in:
Alastor Wu 2016-11-01 17:46:09 +08:00
Родитель 8dda44f0e7
Коммит c2f555c0fd
3 изменённых файлов: 17 добавлений и 5 удалений

Просмотреть файл

@ -354,3 +354,10 @@ AudioChannelAgent::WindowAudioCaptureChanged(uint64_t aInnerWindowID,
callback->WindowAudioCaptureChanged(aCapture);
}
bool
AudioChannelAgent::IsPlayingStarted() const
{
return mIsRegToService;
}

Просмотреть файл

@ -48,6 +48,8 @@ public:
uint64_t WindowID() const;
uint64_t InnerWindowID() const;
bool IsPlayingStarted() const;
private:
virtual ~AudioChannelAgent();

Просмотреть файл

@ -6430,7 +6430,9 @@ HTMLMediaElement::SetAudibleState(bool aAudible)
void
HTMLMediaElement::NotifyAudioPlaybackChanged(AudibleChangedReasons aReason)
{
if (!mAudioChannelAgent) {
MOZ_ASSERT(mAudioChannelAgent);
if (!mAudioChannelAgent->IsPlayingStarted()) {
return;
}
@ -6554,16 +6556,17 @@ HTMLMediaElement::SetMediaInfo(const MediaInfo& aInfo)
void
HTMLMediaElement::AudioCaptureStreamChangeIfNeeded()
{
// Window audio capturing only happens after creating audio channel agent.
if (!mAudioChannelAgent) {
return;
}
MOZ_ASSERT(mAudioChannelAgent);
// No need to capture a silence media element.
if (!HasAudio()) {
return;
}
if (!mAudioChannelAgent->IsPlayingStarted()) {
return;
}
if (mAudioCapturedByWindow && !mCaptureStreamPort) {
nsCOMPtr<nsPIDOMWindowInner> window = OwnerDoc()->GetInnerWindow();
if (!OwnerDoc()->GetInnerWindow()) {