bug 1388656 keep response buffer on graph thread only long enough to initialize the Reverb r=padenot

MozReview-Commit-ID: 6DvpXeWPGHp

--HG--
extra : rebase_source : 50a2f7e4df207d971894189d9de8844fab0a7954
This commit is contained in:
Karl Tomlinson 2017-08-08 16:08:21 +12:00
Родитель 0b158fb300
Коммит 46ad6041ff
1 изменённых файлов: 3 добавлений и 8 удалений

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

@ -49,7 +49,6 @@ public:
case BUFFER_LENGTH:
// BUFFER_LENGTH is the first parameter that we set when setting a new buffer,
// so we should be careful to invalidate the rest of our state here.
mBuffer = nullptr;
mSampleRate = 0.0f;
mBufferLength = aParam;
mLeftOverData = INT32_MIN;
@ -75,7 +74,7 @@ public:
}
void SetBuffer(already_AddRefed<ThreadSharedFloatArrayBufferList> aBuffer) override
{
mBuffer = aBuffer;
RefPtr<ThreadSharedFloatArrayBufferList> buffer = aBuffer;
// Note about empirical tuning (this is copied from Blink)
// The maximum FFT size affects reverb performance and accuracy.
@ -85,13 +84,13 @@ public:
// Very large FFTs will have worse phase errors. Given these constraints 32768 is a good compromise.
const size_t MaxFFTSize = 32768;
if (!mBuffer || !mBufferLength || !mSampleRate) {
if (!buffer || !mBufferLength || !mSampleRate) {
mReverb = nullptr;
mLeftOverData = INT32_MIN;
return;
}
mReverb = new WebCore::Reverb(mBuffer, mBufferLength,
mReverb = new WebCore::Reverb(buffer, mBufferLength,
MaxFFTSize, mUseBackgroundThreads,
mNormalize, mSampleRate);
}
@ -159,9 +158,6 @@ public:
size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const override
{
size_t amount = AudioNodeEngine::SizeOfExcludingThis(aMallocSizeOf);
if (mBuffer && !mBuffer->IsShared()) {
amount += mBuffer->SizeOfIncludingThis(aMallocSizeOf);
}
if (mReverb) {
amount += mReverb->sizeOfIncludingThis(aMallocSizeOf);
@ -176,7 +172,6 @@ public:
}
private:
RefPtr<ThreadSharedFloatArrayBufferList> mBuffer;
nsAutoPtr<WebCore::Reverb> mReverb;
int32_t mBufferLength;
int32_t mLeftOverData;