Changeset 217919 in webkit
- Timestamp:
- Jun 7, 2017 9:31:31 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r217917 r217919 1 2017-06-07 Jer Noble <jer.noble@apple.com> 2 3 [Web Audio] createScriptProcessor throws IndexSizeError for valid arguments 4 https://bugs.webkit.org/show_bug.cgi?id=173022 5 6 Reviewed by Sam Weinig. 7 8 * webaudio/javascriptaudionode-expected.txt: 9 * webaudio/javascriptaudionode.html: 10 1 11 2017-06-07 Chris Dumez <cdumez@apple.com> 2 12 -
trunk/LayoutTests/webaudio/javascriptaudionode-expected.txt
r146040 r217919 9 9 PASS Successfully created ScriptProcessorNode with numberOfInputChannels = 0 and numberOfOutputChannels = 2. 10 10 PASS Exception was thrown for illegal bufferSize. 11 PASS Successfully created ScriptProcessorNode with bufferSize = 0. 11 12 PASS Successfully created ScriptProcessorNode with bufferSize = 256. 12 13 PASS Successfully created ScriptProcessorNode with bufferSize = 512. -
trunk/LayoutTests/webaudio/javascriptaudionode.html
r217243 r217919 124 124 } 125 125 126 doBufferSizeTest(0); 126 127 doBufferSizeTest(256); 127 128 doBufferSizeTest(512); -
trunk/Source/WebCore/ChangeLog
r217917 r217919 1 2017-06-07 Jer Noble <jer.noble@apple.com> 2 3 [Web Audio] createScriptProcessor throws IndexSizeError for valid arguments 4 https://bugs.webkit.org/show_bug.cgi?id=173022 5 6 Reviewed by Sam Weinig. 7 8 Updated test: webaudio/javascriptaudionode.html 9 10 The Web Audio spec (<https://webaudio.github.io/web-audio-api/>, 06 June 2017) defines a default behavior when 11 clients pass in a value of 0 for bufferSize to the createScriptProcessor() method. 12 13 * Modules/webaudio/AudioContext.cpp: 14 (WebCore::AudioContext::createScriptProcessor): 15 * Modules/webaudio/AudioContext.idl: 16 * Modules/webaudio/ScriptProcessorNode.cpp: 17 (WebCore::ScriptProcessorNode::create): 18 * Modules/webaudio/ScriptProcessorNode.h: 19 1 20 2017-06-07 Chris Dumez <cdumez@apple.com> 2 21 -
trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp
r216886 r217919 38 38 #include "AudioNodeInput.h" 39 39 #include "AudioNodeOutput.h" 40 #include "AudioSession.h" 40 41 #include "BiquadFilterNode.h" 41 42 #include "ChannelMergerNode.h" … … 489 490 ASSERT(isMainThread()); 490 491 lazyInitialize(); 492 493 // W3C Editor's Draft 06 June 2017 494 // https://webaudio.github.io/web-audio-api/#widl-BaseAudioContext-createScriptProcessor-ScriptProcessorNode-unsigned-long-bufferSize-unsigned-long-numberOfInputChannels-unsigned-long-numberOfOutputChannels 495 496 // The bufferSize parameter determines the buffer size in units of sample-frames. If it's not passed in, 497 // or if the value is 0, then the implementation will choose the best buffer size for the given environment, 498 // which will be constant power of 2 throughout the lifetime of the node. ... If the value of this parameter 499 // is not one of the allowed power-of-2 values listed above, an IndexSizeError must be thrown. 500 switch (bufferSize) { 501 case 0: 502 #if USE(AUDIO_SESSION) 503 // Pick a value between 256 (2^8) and 16384 (2^14), based on the buffer size of the current AudioSession: 504 bufferSize = 1 << std::max<size_t>(8, std::min<size_t>(14, std::log2(AudioSession::sharedSession().bufferSize()))); 505 #else 506 bufferSize = 2048; 507 #endif 508 break; 509 case 256: 510 case 512: 511 case 1024: 512 case 2048: 513 case 4096: 514 case 8192: 515 case 16384: 516 break; 517 default: 518 return Exception { INDEX_SIZE_ERR }; 519 } 520 521 // An IndexSizeError exception must be thrown if bufferSize or numberOfInputChannels or numberOfOutputChannels 522 // are outside the valid range. It is invalid for both numberOfInputChannels and numberOfOutputChannels to be zero. 523 // In this case an IndexSizeError must be thrown. 524 525 if (!numberOfInputChannels && !numberOfOutputChannels) 526 return Exception { NOT_SUPPORTED_ERR }; 527 528 // This parameter [numberOfInputChannels] determines the number of channels for this node's input. Values of 529 // up to 32 must be supported. A NotSupportedError must be thrown if the number of channels is not supported. 530 531 if (numberOfInputChannels > maxNumberOfChannels()) 532 return Exception { NOT_SUPPORTED_ERR }; 533 534 // This parameter [numberOfOutputChannels] determines the number of channels for this node's output. Values of 535 // up to 32 must be supported. A NotSupportedError must be thrown if the number of channels is not supported. 536 537 if (numberOfOutputChannels > maxNumberOfChannels()) 538 return Exception { NOT_SUPPORTED_ERR }; 539 491 540 auto node = ScriptProcessorNode::create(*this, m_destinationNode->sampleRate(), bufferSize, numberOfInputChannels, numberOfOutputChannels); 492 541 493 if (!node) 494 return Exception { INDEX_SIZE_ERR }; 495 496 refNode(*node); // context keeps reference until we stop making javascript rendering callbacks 497 return node.releaseNonNull(); 542 refNode(node); // context keeps reference until we stop making javascript rendering callbacks 543 return WTFMove(node); 498 544 } 499 545 -
trunk/Source/WebCore/Modules/webaudio/AudioContext.idl
r208474 r217919 86 86 DynamicsCompressorNode createDynamicsCompressor(); 87 87 AnalyserNode createAnalyser(); 88 [MayThrowException] ScriptProcessorNode createScriptProcessor( unsigned long bufferSize, optional unsigned long numberOfInputChannels = 2, optional unsigned long numberOfOutputChannels = 2);88 [MayThrowException] ScriptProcessorNode createScriptProcessor(optional unsigned long bufferSize = 0, optional unsigned long numberOfInputChannels = 2, optional unsigned long numberOfOutputChannels = 2); 89 89 OscillatorNode createOscillator(); 90 90 [MayThrowException] PeriodicWave createPeriodicWave(Float32Array real, Float32Array imag); -
trunk/Source/WebCore/Modules/webaudio/ScriptProcessorNode.cpp
r210621 r217919 42 42 namespace WebCore { 43 43 44 RefPtr<ScriptProcessorNode> ScriptProcessorNode::create(AudioContext& context, float sampleRate, size_t bufferSize, unsigned numberOfInputChannels, unsigned numberOfOutputChannels) 45 { 46 // Check for valid buffer size. 47 switch (bufferSize) { 48 case 256: 49 case 512: 50 case 1024: 51 case 2048: 52 case 4096: 53 case 8192: 54 case 16384: 55 break; 56 default: 57 return nullptr; 58 } 59 60 if (!numberOfInputChannels && !numberOfOutputChannels) 61 return nullptr; 62 63 if (numberOfInputChannels > AudioContext::maxNumberOfChannels()) 64 return nullptr; 65 66 if (numberOfOutputChannels > AudioContext::maxNumberOfChannels()) 67 return nullptr; 68 44 Ref<ScriptProcessorNode> ScriptProcessorNode::create(AudioContext& context, float sampleRate, size_t bufferSize, unsigned numberOfInputChannels, unsigned numberOfOutputChannels) 45 { 69 46 return adoptRef(*new ScriptProcessorNode(context, sampleRate, bufferSize, numberOfInputChannels, numberOfOutputChannels)); 70 47 } -
trunk/Source/WebCore/Modules/webaudio/ScriptProcessorNode.h
r208646 r217919 52 52 // Lower numbers for bufferSize will result in a lower (better) latency. Higher numbers will be necessary to avoid audio breakup and glitches. 53 53 // The value chosen must carefully balance between latency and audio quality. 54 static Ref Ptr<ScriptProcessorNode> create(AudioContext&, float sampleRate, size_t bufferSize, unsigned numberOfInputChannels, unsigned numberOfOutputChannels);54 static Ref<ScriptProcessorNode> create(AudioContext&, float sampleRate, size_t bufferSize, unsigned numberOfInputChannels, unsigned numberOfOutputChannels); 55 55 56 56 virtual ~ScriptProcessorNode();
Note: See TracChangeset
for help on using the changeset viewer.