mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 890072 - Part 2: Keep the ConvolverNode alive while its reverb buffers are being exhausted; r=roc
This commit is contained in:
parent
bc716e907a
commit
54d144cdcf
@ -26,10 +26,12 @@ NS_IMPL_RELEASE_INHERITED(ConvolverNode, AudioNode)
|
||||
|
||||
class ConvolverNodeEngine : public AudioNodeEngine
|
||||
{
|
||||
typedef PlayingRefChangeHandler<ConvolverNode> PlayingRefChanged;
|
||||
public:
|
||||
ConvolverNodeEngine(AudioNode* aNode, bool aNormalize)
|
||||
: AudioNodeEngine(aNode)
|
||||
, mBufferLength(0)
|
||||
, mLeftOverData(INT32_MIN)
|
||||
, mSampleRate(0.0f)
|
||||
, mUseBackgroundThreads(!aNode->Context()->IsOffline())
|
||||
, mNormalize(aNormalize)
|
||||
@ -51,6 +53,7 @@ public:
|
||||
mBuffer = nullptr;
|
||||
mSampleRate = 0.0f;
|
||||
mBufferLength = aParam;
|
||||
mLeftOverData = INT32_MIN;
|
||||
break;
|
||||
case SAMPLE_RATE:
|
||||
mSampleRate = aParam;
|
||||
@ -92,6 +95,7 @@ public:
|
||||
if (!mBuffer || !mBufferLength || !mSampleRate) {
|
||||
mReverb = nullptr;
|
||||
mSeenInput = false;
|
||||
mLeftOverData = INT32_MIN;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -136,12 +140,32 @@ public:
|
||||
AllocateAudioBlock(numChannels, aOutput);
|
||||
|
||||
mReverb->process(&input, aOutput, WEBAUDIO_BLOCK_SIZE);
|
||||
|
||||
if (!aInput.IsNull()) {
|
||||
if (mLeftOverData == INT32_MIN) {
|
||||
// Start counting the left over data
|
||||
mLeftOverData = mBufferLength + WEBAUDIO_BLOCK_SIZE;
|
||||
MOZ_ASSERT(mLeftOverData > 0);
|
||||
|
||||
nsRefPtr<PlayingRefChanged> refchanged =
|
||||
new PlayingRefChanged(aStream, PlayingRefChanged::ADDREF);
|
||||
NS_DispatchToMainThread(refchanged);
|
||||
} else {
|
||||
mLeftOverData -= WEBAUDIO_BLOCK_SIZE;
|
||||
}
|
||||
if (mLeftOverData <= 0) {
|
||||
nsRefPtr<PlayingRefChanged> refchanged =
|
||||
new PlayingRefChanged(aStream, PlayingRefChanged::RELEASE);
|
||||
NS_DispatchToMainThread(refchanged);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
nsRefPtr<ThreadSharedFloatArrayBufferList> mBuffer;
|
||||
nsAutoPtr<WebCore::Reverb> mReverb;
|
||||
int32_t mBufferLength;
|
||||
int32_t mLeftOverData;
|
||||
float mSampleRate;
|
||||
bool mUseBackgroundThreads;
|
||||
bool mNormalize;
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include "AudioNode.h"
|
||||
#include "AudioBuffer.h"
|
||||
#include "PlayingRefChangeHandler.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
@ -39,7 +40,10 @@ public:
|
||||
void SetNormalize(bool aNormal);
|
||||
|
||||
private:
|
||||
friend class PlayingRefChangeHandler<ConvolverNode>;
|
||||
|
||||
nsRefPtr<AudioBuffer> mBuffer;
|
||||
SelfReference<ConvolverNode> mPlayingRef;
|
||||
bool mNormalize;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user