Bug 156769

Summary: AudioBufferSourceNode.buffer should be nullable
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: BindingsAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: darin, eric.carlson, jer.noble
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
URL: https://webaudio.github.io/web-audio-api/#AudioBufferSourceNode
Attachments:
Description Flags
Patch
none
Patch darin: review+

Chris Dumez
Reported 2016-04-19 16:30:21 PDT
Get rid of custom bindings for AudioBufferSourceNode.buffer's setter. They are not needed.
Attachments
Patch (20.60 KB, patch)
2016-04-19 16:42 PDT, Chris Dumez
no flags
Patch (21.50 KB, patch)
2016-04-19 17:06 PDT, Chris Dumez
darin: review+
Chris Dumez
Comment 1 2016-04-19 16:42:52 PDT
Chris Dumez
Comment 2 2016-04-19 16:44:57 PDT
Comment on attachment 276775 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=276775&action=review > Source/WebCore/bindings/js/JSAudioBufferSourceNodeCustom.cpp:-45 > - if (!buffer) { This was emulating [StrictTypeChecking] but also wrongly throwing a TypeError when setting to null. We now use [StrictTypeChecking] in the IDL and mark the attribute as nullable to get the correct behavior. > Source/WebCore/bindings/js/JSAudioBufferSourceNodeCustom.cpp:-51 > - state.vm().throwException(&state, createTypeError(&state, "AudioBuffer unsupported number of channels")); We now use [SetterRaisesExceptionWithMessage] in the IDL and moved the exception code/message setting to the implementation.
Chris Dumez
Comment 3 2016-04-19 16:49:37 PDT
Comment on attachment 276775 [details] Patch Will clean up a little bit further.
Chris Dumez
Comment 4 2016-04-19 17:06:16 PDT
Darin Adler
Comment 5 2016-04-19 17:10:18 PDT
Comment on attachment 276778 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=276778&action=review > Source/WebCore/Modules/webaudio/AudioBufferSourceNode.cpp:424 > - if (numberOfChannels > AudioContext::maxNumberOfChannels()) > - return false; > + ASSERT(numberOfChannels <= AudioContext::maxNumberOfChannels()); The test seems to cover this, but I was wondering where the guarantee of this comes from. > Source/WebCore/Modules/webaudio/AudioContext.h:208 > static unsigned maxNumberOfChannels() { return MaxNumberOfChannels;} Missing space before the "}" here.
Chris Dumez
Comment 6 2016-04-19 17:17:31 PDT
Comment on attachment 276778 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=276778&action=review >> Source/WebCore/Modules/webaudio/AudioBufferSourceNode.cpp:424 >> + ASSERT(numberOfChannels <= AudioContext::maxNumberOfChannels()); > > The test seems to cover this, but I was wondering where the guarantee of this comes from. There are 2 factories for AudioBuffer, the first one explicitly checks the number of channels: RefPtr<AudioBuffer> AudioBuffer::create(unsigned numberOfChannels, size_t numberOfFrames, float sampleRate) { if (sampleRate < 22050 || sampleRate > 96000 || numberOfChannels > AudioContext::maxNumberOfChannels() || !numberOfFrames) return nullptr; The second one looks like so: RefPtr<AudioBuffer> AudioBuffer::createFromAudioFileData(const void* data, size_t dataSize, bool mixToMono, float sampleRate). It creates an AudioBus then creates an AudioBuffer from that AudioBus. AudioFileReader::createBus() can set channelSize to 1 (mono) or 2 (stereo).
Chris Dumez
Comment 7 2016-04-19 18:29:55 PDT
Note You need to log in before you can comment on or make changes to this bug.