bug 1191649 determine ScriptProcessor connected status on main thread r=padenot

because stream inputs may be removed when only providing null data.

The ScriptProcessor is also kept alive when it has only input nodes so that it
is not garbage collected when its input nodes are collected.

--HG--
extra : rebase_source : ee70db1b3e13b212107e048620880b929c662ad6
This commit is contained in:
Karl Tomlinson 2015-08-06 16:22:56 +12:00
Родитель e35277a491
Коммит 487efc8f27
2 изменённых файлов: 29 добавлений и 3 удалений

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

@ -268,6 +268,21 @@ public:
return mSharedBuffers;
}
enum {
IS_CONNECTED,
};
virtual void SetInt32Parameter(uint32_t aIndex, int32_t aParam) override
{
switch (aIndex) {
case IS_CONNECTED:
mIsConnected = aParam;
break;
default:
NS_ERROR("Bad Int32Parameter");
} // End index switch.
}
virtual void ProcessBlock(AudioNodeStream* aStream,
const AudioChunk& aInput,
AudioChunk* aOutput,
@ -276,8 +291,7 @@ public:
// This node is not connected to anything. Per spec, we don't fire the
// onaudioprocess event. We also want to clear out the input and output
// buffer queue, and output a null buffer.
if (!(aStream->ConsumerCount() ||
aStream->AsProcessedStream()->InputPortCount())) {
if (!mIsConnected) {
aOutput->SetNull(WEBAUDIO_BLOCK_SIZE);
mSharedBuffers->Reset();
mSeenNonSilenceInput = false;
@ -483,6 +497,7 @@ private:
const uint32_t mBufferSize;
// The write index into the current input buffer
uint32_t mInputWriteIndex;
bool mIsConnected = false;
bool mSeenNonSilenceInput;
};
@ -553,7 +568,14 @@ ScriptProcessorNode::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProt
void
ScriptProcessorNode::UpdateConnectedStatus()
{
bool isConnected = !(OutputNodes().IsEmpty() && OutputParams().IsEmpty());
bool isConnected = !(OutputNodes().IsEmpty() && OutputParams().IsEmpty()
&& InputNodes().IsEmpty());
// Events are queued even when there is no listener because a listener
// may be added while events are in the queue.
SendInt32ParameterToStream(ScriptProcessorNodeEngine::IS_CONNECTED,
isConnected);
if (isConnected && HasListenersFor(nsGkAtoms::onaudioprocess)) {
MarkActive();
} else {

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

@ -58,6 +58,10 @@ public:
UpdateConnectedStatus();
}
}
virtual void NotifyInputsChanged() override
{
UpdateConnectedStatus();
}
virtual void SetChannelCount(uint32_t aChannelCount, ErrorResult& aRv) override
{