https://bugs.webkit.org/show_bug.cgi?id=81748
Patch by Xingnan Wang <xingnan.wang@intel.com> on 2012-03-22
Reviewed by Chris Rogers.
Source/WebCore:
* Modules/webaudio/RealtimeAnalyser.cpp:
(WebCore::RealtimeAnalyser::setFftSize):
* Modules/webaudio/RealtimeAnalyser.h:
(RealtimeAnalyser):
* Modules/webaudio/RealtimeAnalyserNode.cpp:
(WebCore::RealtimeAnalyserNode::setFftSize):
(WebCore):
* Modules/webaudio/RealtimeAnalyserNode.h:
(RealtimeAnalyserNode):
* Modules/webaudio/RealtimeAnalyserNode.idl:
LayoutTests:
* webaudio/realtimeanalyser-fft-sizing-expected.txt:
* webaudio/realtimeanalyser-fft-sizing.html:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@111821
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2012-03-22 Xingnan Wang <xingnan.wang@intel.com>
+
+ Add exception for the setter of "fftSize" in RealtimeAnalyserNode
+ https://bugs.webkit.org/show_bug.cgi?id=81748
+
+ Reviewed by Chris Rogers.
+
+ * webaudio/realtimeanalyser-fft-sizing-expected.txt:
+ * webaudio/realtimeanalyser-fft-sizing.html:
+
2012-03-22 Emil A Eklund <eae@chromium.org>
Unreviewed rebaseline of chrome-win table tests post r111742.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+PASS Exception thrown for illegal fftSize -1.
+PASS Exception thrown for illegal fftSize 0.
+PASS Exception thrown for illegal fftSize 1.
+PASS Exception thrown for illegal fftSize 2.
+PASS Exception thrown for illegal fftSize 3.
+PASS Exception thrown for illegal fftSize 4.
+PASS Exception thrown for illegal fftSize 5.
+PASS Exception thrown for illegal fftSize 8.
+PASS Exception thrown for illegal fftSize 9.
+PASS Exception thrown for illegal fftSize 16.
+PASS Exception thrown for illegal fftSize 17.
+PASS Exception thrown for illegal fftSize 32.
+PASS Exception thrown for illegal fftSize 33.
+PASS Exception thrown for illegal fftSize 64.
+PASS Exception thrown for illegal fftSize 65.
+PASS Successfully set legal fftSize 128.
+PASS Exception thrown for illegal fftSize 129.
+PASS Successfully set legal fftSize 256.
+PASS Exception thrown for illegal fftSize 257.
+PASS Successfully set legal fftSize 512.
+PASS Exception thrown for illegal fftSize 513.
+PASS Successfully set legal fftSize 1024.
+PASS Exception thrown for illegal fftSize 1025.
+PASS Successfully set legal fftSize 2048.
+PASS Exception thrown for illegal fftSize 2049.
+PASS Exception thrown for illegal fftSize 4096.
+PASS Exception thrown for illegal fftSize 4097.
+PASS Exception thrown for illegal fftSize 8192.
+PASS Exception thrown for illegal fftSize 8193.
+PASS Exception thrown for illegal fftSize 16384.
+PASS Exception thrown for illegal fftSize 16385.
+PASS Exception thrown for illegal fftSize 32768.
+PASS Exception thrown for illegal fftSize 32769.
+PASS Exception thrown for illegal fftSize 65536.
+PASS Exception thrown for illegal fftSize 65537.
+PASS Exception thrown for illegal fftSize 131072.
+PASS Exception thrown for illegal fftSize 131073.
PASS webkitAudioContext survived multiple invalid FFT array resizings.
PASS successfullyParsed is true
layoutTestController.waitUntilDone();
}
-var doTest = function(fftSize) {
+var doTest = function(fftSize, illegal) {
var c = new webkitAudioContext(1, 1000, 44100);
var a = c.createAnalyser();
- a.fftSize = fftSize;
+ try {
+ a.fftSize = fftSize;
+ if (illegal)
+ testFailed("No exception thrown for illegal fftSize " + fftSize + ".");
+ else
+ testPassed("Successfully set legal fftSize " + fftSize + ".");
+ } catch(e) {
+ testPassed("Exception thrown for illegal fftSize " + fftSize + ".");
+ }
// This arbitrary size does not affect the correctness of the test.
var arr = new Float32Array(100);
a.getFloatFrequencyData(arr);
}
-doTest(-1);
-doTest(0);
-doTest(1);
+doTest(-1, true);
+doTest(0, true);
+doTest(1, true);
for (var i = 2; i <= 0x20000; i *= 2) {
- doTest(i);
- doTest(i + 1);
+ if (i >= 128 && i <= 2048)
+ doTest(i, false);
+ else
+ doTest(i, true);
+ doTest(i + 1, true);
}
if (window.layoutTestController)
+2012-03-22 Xingnan Wang <xingnan.wang@intel.com>
+
+ Add exception for the setter of "fftSize" in RealtimeAnalyserNode
+ https://bugs.webkit.org/show_bug.cgi?id=81748
+
+ Reviewed by Chris Rogers.
+
+ * Modules/webaudio/RealtimeAnalyser.cpp:
+ (WebCore::RealtimeAnalyser::setFftSize):
+ * Modules/webaudio/RealtimeAnalyser.h:
+ (RealtimeAnalyser):
+ * Modules/webaudio/RealtimeAnalyserNode.cpp:
+ (WebCore::RealtimeAnalyserNode::setFftSize):
+ (WebCore):
+ * Modules/webaudio/RealtimeAnalyserNode.h:
+ (RealtimeAnalyserNode):
+ * Modules/webaudio/RealtimeAnalyserNode.idl:
+
2012-03-22 Leo Yang <leo.yang@torchmobile.com.cn>
[BlackBerry] Add HistoryItemViewState for BlackBerry port
m_magnitudeBuffer.zero();
}
-void RealtimeAnalyser::setFftSize(size_t size)
+bool RealtimeAnalyser::setFftSize(size_t size)
{
ASSERT(isMainThread());
unsigned log2size = static_cast<unsigned>(log2(size));
bool isPOT(1UL << log2size == size);
- if (!isPOT || size > MaxFFTSize || size < MinFFTSize) {
- // FIXME: It would be good to also set an exception.
- return;
- }
+ if (!isPOT || size > MaxFFTSize || size < MinFFTSize)
+ return false;
if (m_fftSize != size) {
m_analysisFrame = adoptPtr(new FFTFrame(size));
m_magnitudeBuffer.allocate(size / 2);
m_fftSize = size;
}
+
+ return true;
}
void RealtimeAnalyser::writeInput(AudioBus* bus, size_t framesToProcess)
void reset();
size_t fftSize() const { return m_fftSize; }
- void setFftSize(size_t size);
+ bool setFftSize(size_t);
unsigned frequencyBinCount() const { return m_fftSize / 2; }
#include "AudioNodeInput.h"
#include "AudioNodeOutput.h"
+#include "ExceptionCode.h"
namespace WebCore {
m_analyser.reset();
}
+void RealtimeAnalyserNode::setFftSize(unsigned int size, ExceptionCode& ec)
+{
+ if (!m_analyser.setFftSize(size))
+ ec = NOT_SUPPORTED_ERR;
+}
+
} // namespace WebCore
#endif // ENABLE(WEB_AUDIO)
// Javascript bindings
unsigned int fftSize() const { return m_analyser.fftSize(); }
- void setFftSize(unsigned int size) { m_analyser.setFftSize(size); }
+ void setFftSize(unsigned int size, ExceptionCode&);
unsigned frequencyBinCount() const { return m_analyser.frequencyBinCount(); }
Conditional=WEB_AUDIO,
JSGenerateToJSObject
] RealtimeAnalyserNode : AudioNode {
- attribute unsigned long fftSize;
+ attribute unsigned long fftSize
+ setter raises(DOMException);
readonly attribute unsigned long frequencyBinCount;
// minDecibels / maxDecibels represent the range to scale the FFT analysis data for conversion to unsigned byte values.