mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 916384 - Stop calling onaudioprocess on the ScriptProcessorNode it has no inputs or outputs. r=roc
Quoting the spec: "audioprocess events are only dispatched if the ScriptProcessorNode has at least one input or one output connected". --HG-- extra : rebase_source : bbf52a183a55b75d394a885624a4080a9467fac4
This commit is contained in:
parent
58cae1ed05
commit
fe52bb44ee
@ -445,6 +445,10 @@ public:
|
||||
{
|
||||
mConsumers.RemoveElement(aPort);
|
||||
}
|
||||
uint32_t ConsumerCount()
|
||||
{
|
||||
return mConsumers.Length();
|
||||
}
|
||||
const StreamBuffer& GetStreamBuffer() { return mBuffer; }
|
||||
GraphTime GetStreamBufferStartTime() { return mBufferStartTime; }
|
||||
/**
|
||||
@ -944,6 +948,10 @@ public:
|
||||
{
|
||||
return mInputs.Contains(aPort);
|
||||
}
|
||||
uint32_t InputPortCount()
|
||||
{
|
||||
return mInputs.Length();
|
||||
}
|
||||
virtual void DestroyImpl();
|
||||
/**
|
||||
* This gets called after we've computed the blocking states for all
|
||||
|
@ -67,6 +67,13 @@ private:
|
||||
return front;
|
||||
}
|
||||
|
||||
// Empties the buffer queue.
|
||||
void Clear()
|
||||
{
|
||||
mMutex.AssertCurrentThreadOwns();
|
||||
mBufferList.clear();
|
||||
}
|
||||
|
||||
private:
|
||||
typedef std::deque<AudioChunk> BufferList;
|
||||
|
||||
@ -167,6 +174,18 @@ public:
|
||||
return mDelaySoFar == TRACK_TICKS_MAX ? 0 : mDelaySoFar;
|
||||
}
|
||||
|
||||
void Reset()
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
mDelaySoFar = TRACK_TICKS_MAX;
|
||||
mLatency = 0.0f;
|
||||
{
|
||||
MutexAutoLock lock(mOutputQueue.Lock());
|
||||
mOutputQueue.Clear();
|
||||
}
|
||||
mLastEventTime = TimeStamp();
|
||||
}
|
||||
|
||||
private:
|
||||
OutputQueue mOutputQueue;
|
||||
// How much delay we've seen so far. This measures the amount of delay
|
||||
@ -224,6 +243,18 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
// 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())) {
|
||||
aOutput->SetNull(WEBAUDIO_BLOCK_SIZE);
|
||||
mSharedBuffers->Reset();
|
||||
mSeenNonSilenceInput = false;
|
||||
mInputWriteIndex = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
// First, record our input buffer
|
||||
for (uint32_t i = 0; i < mInputChannels.Length(); ++i) {
|
||||
if (aInput.IsNull()) {
|
||||
|
@ -108,6 +108,7 @@ support-files =
|
||||
[test_scriptProcessorNode.html]
|
||||
[test_scriptProcessorNodeChannelCount.html]
|
||||
[test_scriptProcessorNodeZeroInputOutput.html]
|
||||
[test_scriptProcessorNodeNotConnected.html]
|
||||
[test_singleSourceDest.html]
|
||||
[test_waveShaper.html]
|
||||
[test_waveShaperNoCurve.html]
|
||||
|
@ -0,0 +1,33 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test AudioBufferSourceNode: should not fire audioprocess if not connected.</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="webaudio.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(function() {
|
||||
var context = new AudioContext();
|
||||
|
||||
var sp = context.createScriptProcessor(2048, 2, 2);
|
||||
sp.onaudioprocess = function(e) {
|
||||
ok(false, "Should not call onaudioprocess if the node is not connected.");
|
||||
sp.onaudioprocess = null;
|
||||
SimpleTest.finish();
|
||||
};
|
||||
setTimeout(function() {
|
||||
console.log(sp.onaudioprocess);
|
||||
if (sp.onaudioprocess) {
|
||||
ok(true, "onaudioprocess not fired.");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}, 4000);
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -28,7 +28,9 @@ addLoadEvent(function() {
|
||||
|
||||
SimpleTest.finish();
|
||||
};
|
||||
sp.connect(context.destination);
|
||||
};
|
||||
sp.connect(context.destination);
|
||||
});
|
||||
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user