Bug 1195051 - Part 2: Mute the destination node when the AudioContext is suspended, and unmute when resumed; r=padenot

This commit is contained in:
Ehsan Akhgari 2015-08-15 18:36:13 -04:00
Родитель 53b1ca8619
Коммит bd4b9d61f6
3 изменённых файлов: 36 добавлений и 2 удалений

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

@ -855,7 +855,7 @@ AudioContext::Suspend(ErrorResult& aRv)
return promise.forget();
}
Destination()->DestroyAudioChannelAgent();
Destination()->Suspend();
MediaStream* ds = DestinationStream();
if (ds) {
@ -895,7 +895,7 @@ AudioContext::Resume(ErrorResult& aRv)
return promise.forget();
}
Destination()->CreateAudioChannelAgent();
Destination()->Resume();
MediaStream* ds = DestinationStream();
if (ds) {

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

@ -244,6 +244,7 @@ public:
: AudioNodeEngine(aNode)
, mVolume(1.0f)
, mLastInputMuted(true)
, mSuspended(false)
{
MOZ_ASSERT(aNode);
}
@ -256,6 +257,10 @@ public:
*aOutput = aInput;
aOutput->mVolume *= mVolume;
if (mSuspended) {
return;
}
bool newInputMuted = aInput.IsNull() || aInput.IsMuted();
if (newInputMuted != mLastInputMuted) {
mLastInputMuted = newInputMuted;
@ -274,8 +279,19 @@ public:
}
}
virtual void SetInt32Parameter(uint32_t aIndex, int32_t aParam) override
{
if (aIndex == SUSPENDED) {
mSuspended = !!aParam;
if (mSuspended) {
mLastInputMuted = true;
}
}
}
enum Parameters {
VOLUME,
SUSPENDED,
};
virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override
@ -286,6 +302,7 @@ public:
private:
float mVolume;
bool mLastInputMuted;
bool mSuspended;
};
static bool UseAudioChannelService()
@ -451,6 +468,20 @@ AudioDestinationNode::Unmute()
SendDoubleParameterToStream(DestinationNodeEngine::VOLUME, 1.0f);
}
void
AudioDestinationNode::Suspend()
{
DestroyAudioChannelAgent();
SendInt32ParameterToStream(DestinationNodeEngine::SUSPENDED, 1);
}
void
AudioDestinationNode::Resume()
{
CreateAudioChannelAgent();
SendInt32ParameterToStream(DestinationNodeEngine::SUSPENDED, 0);
}
void
AudioDestinationNode::OfflineShutdown()
{

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

@ -53,6 +53,9 @@ public:
void Mute();
void Unmute();
void Suspend();
void Resume();
void StartRendering(Promise* aPromise);
void OfflineShutdown();