зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1195051 - Part 2: Mute the destination node when the AudioContext is suspended, and unmute when resumed; r=padenot
This commit is contained in:
Родитель
53b1ca8619
Коммит
bd4b9d61f6
|
@ -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();
|
||||
|
|
Загрузка…
Ссылка в новой задаче