From 0406c5ea35bcb8a86b8c661603a8f3e42b542a7f Mon Sep 17 00:00:00 2001 From: Ryan VanderMeulen Date: Tue, 25 Jun 2013 15:24:11 -0400 Subject: [PATCH] Backed out 2 changesets (bug 886618, bug 886657) for frequent OSX 10.7 mochitest-1 failures. Backed out changeset 9fd8b2adc693 (bug 886618) Backed out changeset 376fe12f4de4 (bug 886657) --- content/media/webaudio/AudioBuffer.cpp | 35 ++++++++--- content/media/webaudio/AudioBuffer.h | 7 ++- .../media/webaudio/AudioBufferSourceNode.cpp | 26 ++------- content/media/webaudio/ConvolverNode.cpp | 2 +- content/media/webaudio/test/Makefile.in | 3 - .../audioBufferSourceNodeNeutered_worker.js | 3 - .../test_audioBufferSourceNodeNeutered.html | 58 ------------------- .../test_audioBufferSourceNodeNoStart.html | 33 ----------- 8 files changed, 40 insertions(+), 127 deletions(-) delete mode 100644 content/media/webaudio/test/audioBufferSourceNodeNeutered_worker.js delete mode 100644 content/media/webaudio/test/test_audioBufferSourceNodeNeutered.html delete mode 100644 content/media/webaudio/test/test_audioBufferSourceNodeNoStart.html diff --git a/content/media/webaudio/AudioBuffer.cpp b/content/media/webaudio/AudioBuffer.cpp index 1d2c6c764e8..e7a712596f6 100644 --- a/content/media/webaudio/AudioBuffer.cpp +++ b/content/media/webaudio/AudioBuffer.cpp @@ -138,6 +138,30 @@ AudioBuffer::GetChannelData(JSContext* aJSContext, uint32_t aChannel, return mJSChannels[aChannel]; } +bool +AudioBuffer::SetChannelDataFromArrayBufferContents(JSContext* aJSContext, + uint32_t aChannel, + void* aContents) +{ + if (!RestoreJSChannelData(aJSContext)) { + return false; + } + + MOZ_ASSERT(aChannel < NumberOfChannels()); + JS::RootedObject arrayBuffer(aJSContext, JS_NewArrayBufferWithContents(aJSContext, aContents)); + if (!arrayBuffer) { + return false; + } + mJSChannels[aChannel] = JS_NewFloat32ArrayWithBuffer(aJSContext, arrayBuffer, + 0, -1); + if (!mJSChannels[aChannel]) { + return false; + } + MOZ_ASSERT(mLength == JS_GetTypedArrayLength(mJSChannels[aChannel])); + + return true; +} + static already_AddRefed StealJSArrayDataIntoThreadSharedFloatArrayBufferList(JSContext* aJSContext, const nsTArray& aJSArrays) @@ -153,7 +177,8 @@ StealJSArrayDataIntoThreadSharedFloatArrayBufferList(JSContext* aJSContext, &stolenData)) { result->SetData(i, dataToFree, reinterpret_cast(stolenData)); } else { - return nullptr; + result->Clear(); + return result.forget(); } } return result.forget(); @@ -163,13 +188,7 @@ ThreadSharedFloatArrayBufferList* AudioBuffer::GetThreadSharedChannelsForRate(JSContext* aJSContext) { if (!mSharedChannels) { - for (uint32_t i = 0; i < mJSChannels.Length(); ++i) { - if (mLength != JS_GetTypedArrayLength(mJSChannels[i])) { - // Probably one of the arrays was neutered - return nullptr; - } - } - + // Steal JS data mSharedChannels = StealJSArrayDataIntoThreadSharedFloatArrayBufferList(aJSContext, mJSChannels); } diff --git a/content/media/webaudio/AudioBuffer.h b/content/media/webaudio/AudioBuffer.h index 9ca0f6d8511..f684a005228 100644 --- a/content/media/webaudio/AudioBuffer.h +++ b/content/media/webaudio/AudioBuffer.h @@ -91,10 +91,15 @@ public: /** * Returns a ThreadSharedFloatArrayBufferList containing the sample data. - * Can return null if there is no data. */ ThreadSharedFloatArrayBufferList* GetThreadSharedChannelsForRate(JSContext* aContext); + // aContents should either come from JS_AllocateArrayBufferContents or + // JS_StealArrayBufferContents. + bool SetChannelDataFromArrayBufferContents(JSContext* aJSContext, + uint32_t aChannel, + void* aContents); + // This replaces the contents of the JS array for the given channel. // This function needs to be called on an AudioBuffer which has not been // handed off to the content yet, and right after the object has been diff --git a/content/media/webaudio/AudioBufferSourceNode.cpp b/content/media/webaudio/AudioBufferSourceNode.cpp index 2cea4904fee..b65c2d88884 100644 --- a/content/media/webaudio/AudioBufferSourceNode.cpp +++ b/content/media/webaudio/AudioBufferSourceNode.cpp @@ -41,12 +41,6 @@ NS_INTERFACE_MAP_END_INHERITING(AudioNode) NS_IMPL_ADDREF_INHERITED(AudioBufferSourceNode, AudioNode) NS_IMPL_RELEASE_INHERITED(AudioBufferSourceNode, AudioNode) -/** - * Media-thread playback engine for AudioBufferSourceNode. - * Nothing is played until a non-null buffer has been set (via - * AudioNodeStream::SetBuffer) and a non-zero duration has been set (via - * AudioNodeStream::SetInt32Parameter). - */ class AudioBufferSourceNodeEngine : public AudioNodeEngine { public: @@ -359,9 +353,8 @@ public: AudioChunk* aOutput, bool* aFinished) { - if (!mBuffer || !mDuration) { + if (!mBuffer) return; - } uint32_t channels = mBuffer->GetChannels(); if (!channels) { @@ -490,9 +483,7 @@ AudioBufferSourceNode::Start(double aWhen, double aOffset, std::numeric_limits::min(); SendOffsetAndDurationParametersToStream(ns, aOffset, duration); } else { - // Remember our arguments so that we can use them once we have a buffer. - // We can't send these parameters now because we don't know the buffer - // sample rate. + // Remember our arguments so that we can use them once we have a buffer mOffset = aOffset; mDuration = aDuration.WasPassed() ? aDuration.Value() : @@ -520,13 +511,11 @@ AudioBufferSourceNode::SendBufferParameterToStream(JSContext* aCx) mBuffer->GetThreadSharedChannelsForRate(aCx); ns->SetBuffer(data.forget()); ns->SetInt32Parameter(SAMPLE_RATE, rate); - - if (mStartCalled) { - SendOffsetAndDurationParametersToStream(ns, mOffset, mDuration); - } } else { ns->SetBuffer(nullptr); } + + SendOffsetAndDurationParametersToStream(ns, mOffset, mDuration); } void @@ -534,11 +523,8 @@ AudioBufferSourceNode::SendOffsetAndDurationParametersToStream(AudioNodeStream* double aOffset, double aDuration) { - NS_ASSERTION(mBuffer && mStartCalled, - "Only call this when we have a buffer and start() has been called"); - - float rate = mBuffer->SampleRate(); - int32_t lengthSamples = mBuffer->Length(); + float rate = mBuffer ? mBuffer->SampleRate() : Context()->SampleRate(); + int32_t lengthSamples = mBuffer ? mBuffer->Length() : 0; double length = double(lengthSamples) / rate; double offset = std::max(0.0, aOffset); double endOffset = aDuration == std::numeric_limits::min() ? diff --git a/content/media/webaudio/ConvolverNode.cpp b/content/media/webaudio/ConvolverNode.cpp index df8280ea6f2..a84a78ec1ee 100644 --- a/content/media/webaudio/ConvolverNode.cpp +++ b/content/media/webaudio/ConvolverNode.cpp @@ -188,7 +188,7 @@ ConvolverNode::SetBuffer(JSContext* aCx, AudioBuffer* aBuffer, ErrorResult& aRv) uint32_t length = mBuffer->Length(); nsRefPtr data = mBuffer->GetThreadSharedChannelsForRate(aCx); - if (data && length < WEBAUDIO_BLOCK_SIZE) { + if (length < WEBAUDIO_BLOCK_SIZE) { // For very small impulse response buffers, we need to pad the // buffer with 0 to make sure that the Reverb implementation // has enough data to compute FFTs from. diff --git a/content/media/webaudio/test/Makefile.in b/content/media/webaudio/test/Makefile.in index 419fd057c36..7aeb580e7fa 100644 --- a/content/media/webaudio/test/Makefile.in +++ b/content/media/webaudio/test/Makefile.in @@ -11,7 +11,6 @@ relativesrcdir := @relativesrcdir@ include $(DEPTH)/config/autoconf.mk MOCHITEST_FILES := \ - audioBufferSourceNodeNeutered_worker.js \ webaudio.js \ layouttest-glue.js \ test_bug808374.html \ @@ -45,8 +44,6 @@ MOCHITEST_FILES := \ test_audioBufferSourceNodeLoop.html \ test_audioBufferSourceNodeLoopStartEnd.html \ test_audioBufferSourceNodeLoopStartEndSame.html \ - test_audioBufferSourceNodeNeutered.html \ - test_audioBufferSourceNodeNoStart.html \ test_audioBufferSourceNodeNullBuffer.html \ test_badConnect.html \ test_biquadFilterNode.html \ diff --git a/content/media/webaudio/test/audioBufferSourceNodeNeutered_worker.js b/content/media/webaudio/test/audioBufferSourceNodeNeutered_worker.js deleted file mode 100644 index 2a5a4bff89f..00000000000 --- a/content/media/webaudio/test/audioBufferSourceNodeNeutered_worker.js +++ /dev/null @@ -1,3 +0,0 @@ -onmessage = function (event) { - postMessage("Pong"); -}; diff --git a/content/media/webaudio/test/test_audioBufferSourceNodeNeutered.html b/content/media/webaudio/test/test_audioBufferSourceNodeNeutered.html deleted file mode 100644 index da967dd8f01..00000000000 --- a/content/media/webaudio/test/test_audioBufferSourceNodeNeutered.html +++ /dev/null @@ -1,58 +0,0 @@ - - - - Test AudioBufferSourceNode when an AudioBuffer's getChanneData array is neutered - - - - - -
-
-
- - diff --git a/content/media/webaudio/test/test_audioBufferSourceNodeNoStart.html b/content/media/webaudio/test/test_audioBufferSourceNodeNoStart.html deleted file mode 100644 index 89340ade8b3..00000000000 --- a/content/media/webaudio/test/test_audioBufferSourceNodeNoStart.html +++ /dev/null @@ -1,33 +0,0 @@ - - - - Test AudioBufferSourceNode when start() is not called - - - - - -
-
-
- -