Bug 868409 - ScriptProcessorNode's playing ref should remain active as long as there are outstanding connections; r=roc

This commit is contained in:
Ehsan Akhgari 2013-05-03 10:59:41 -04:00
Родитель 9a4ea6d3e9
Коммит 026206633a
2 изменённых файлов: 40 добавлений и 2 удалений

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

@ -59,6 +59,44 @@ private:
bool mHeld;
};
template<class T>
class SelfCountedReference {
public:
SelfCountedReference() : mRefCnt(0) {}
~SelfCountedReference()
{
NS_ASSERTION(mRefCnt == 0, "Forgot to drop the self reference?");
}
void Take(T* t)
{
if (mRefCnt++ == 0) {
t->AddRef();
}
}
void Drop(T* t)
{
if (mRefCnt > 0) {
--mRefCnt;
if (mRefCnt == 0) {
t->Release();
}
}
}
void ForceDrop(T* t)
{
if (mRefCnt > 0) {
mRefCnt = 0;
t->Release();
}
}
operator bool() const { return mRefCnt > 0; }
private:
nsrefcnt mRefCnt;
};
/**
* The DOM object representing a Web Audio AudioNode.
*

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

@ -82,14 +82,14 @@ public:
void Stop()
{
mPlayingRef.Drop(this);
mPlayingRef.ForceDrop(this);
}
private:
nsAutoPtr<SharedBuffers> mSharedBuffers;
const uint32_t mBufferSize;
const uint32_t mNumberOfOutputChannels;
SelfReference<ScriptProcessorNode> mPlayingRef; // a reference to self while planing
SelfCountedReference<ScriptProcessorNode> mPlayingRef; // a reference to self while planing
};
}