RESOLVED FIXED 214990
Added AudioBuffer Constructor
https://bugs.webkit.org/show_bug.cgi?id=214990
Summary Added AudioBuffer Constructor
Clark Wang
Reported 2020-07-30 15:11:10 PDT
Added AudioBuffer constructor according to: https://www.w3.org/TR/webaudio/#AudioBuffer-constructors. Added in AudioBufferOptions files as well.
Attachments
Patch (57.91 KB, patch)
2020-07-30 15:19 PDT, Clark Wang
no flags
Patch (57.13 KB, patch)
2020-07-30 16:41 PDT, Clark Wang
no flags
Patch (58.21 KB, patch)
2020-07-31 07:29 PDT, Clark Wang
no flags
Patch (58.21 KB, patch)
2020-07-31 07:41 PDT, Clark Wang
no flags
Patch (58.11 KB, patch)
2020-07-31 09:21 PDT, Clark Wang
no flags
Patch (58.12 KB, patch)
2020-07-31 10:28 PDT, Clark Wang
no flags
Patch (57.48 KB, patch)
2020-08-03 08:56 PDT, Clark Wang
no flags
Patch (57.38 KB, patch)
2020-08-03 10:05 PDT, Clark Wang
no flags
Clark Wang
Comment 1 2020-07-30 15:19:35 PDT
Chris Dumez
Comment 2 2020-07-30 15:28:53 PDT
Comment on attachment 405628 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=405628&action=review > Source/WebCore/Modules/webaudio/AudioBuffer.cpp:55 > +ExceptionOr<Ref<AudioBuffer>> AudioBuffer::create(const AudioBufferOptions&& options) no const. > Source/WebCore/Modules/webaudio/AudioBuffer.cpp:67 > + if (!buffer->m_length) I'd rather we use the length() getter. > Source/WebCore/Modules/webaudio/AudioBuffer.h:45 > + static ExceptionOr<Ref<AudioBuffer>> create(const AudioBufferOptions&& = { }); no const > Source/WebCore/Modules/webaudio/AudioBufferOptions.h:33 > + unsigned numberOfChannels; Please provide default values for these. Otherwise, when you used AudioBufferOptions { } earlier in your patch as default parameter value, it constructed a struct with uninitialized members. > Source/WebCore/Modules/webaudio/AudioBufferOptions.h:34 > + size_t length; unsigned > Source/WebCore/Modules/webaudio/OfflineAudioContextOptions.idl:25 > + Unnecessary change. > LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audiobuffersourcenode-interface/audiobuffersource-channels-expected.txt:9 > +FAIL X source.buffer = new buffer did not throw an exception. assert_true: expected true got false This seems bad? > LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audiobuffersourcenode-interface/audiobuffersource-channels-expected.txt:11 > +FAIL X source.buffer = buffer again did not throw an exception. assert_true: expected true got false how about this?
Clark Wang
Comment 3 2020-07-30 16:19:18 PDT
(In reply to Chris Dumez from comment #2) > Comment on attachment 405628 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=405628&action=review > > > Source/WebCore/Modules/webaudio/AudioBuffer.cpp:55 > > +ExceptionOr<Ref<AudioBuffer>> AudioBuffer::create(const AudioBufferOptions&& options) > > no const. > > > Source/WebCore/Modules/webaudio/AudioBuffer.cpp:67 > > + if (!buffer->m_length) > > I'd rather we use the length() getter. > > > Source/WebCore/Modules/webaudio/AudioBuffer.h:45 > > + static ExceptionOr<Ref<AudioBuffer>> create(const AudioBufferOptions&& = { }); > > no const > > > Source/WebCore/Modules/webaudio/AudioBufferOptions.h:33 > > + unsigned numberOfChannels; > > Please provide default values for these. Otherwise, when you used > AudioBufferOptions { } earlier in your patch as default parameter value, it > constructed a struct with uninitialized members. > > > Source/WebCore/Modules/webaudio/AudioBufferOptions.h:34 > > + size_t length; > > unsigned > > > Source/WebCore/Modules/webaudio/OfflineAudioContextOptions.idl:25 > > + > > Unnecessary change. > > > LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audiobuffersourcenode-interface/audiobuffersource-channels-expected.txt:9 > > +FAIL X source.buffer = new buffer did not throw an exception. assert_true: expected true got false > > This seems bad? I think this is testing AudioBufferSourceNode::setBuffer() method, which will be fixed in a future patch. > > > LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audiobuffersourcenode-interface/audiobuffersource-channels-expected.txt:11 > > +FAIL X source.buffer = buffer again did not throw an exception. assert_true: expected true got false > > how about this? Ditto above
Clark Wang
Comment 4 2020-07-30 16:41:23 PDT
youenn fablet
Comment 5 2020-07-31 03:10:38 PDT
Comment on attachment 405635 [details] Patch LGTM but some related tests are failing in EWS. View in context: https://bugs.webkit.org/attachment.cgi?id=405635&action=review > Source/WebCore/Modules/webaudio/AudioBuffer.idl:36 > readonly attribute long length; // in sample-frames Seems strange that we pass an unsigned long length in AudioBufferOptions but (probably) add a getter for the same value as long. Probably we want it to be unsigned long as well given its name. > Source/WebCore/Modules/webaudio/AudioBufferOptions.h:34 > + unsigned length; We are using unsigned here, as per WebIDL I believe, but size_t at some point for instance in AudioBuffer::create. This is probably fine for this patch but I wonder whether we should try to be more consistent in the type used for length. > Source/WebCore/Modules/webaudio/BaseAudioContext.cpp:395 > + return AudioBuffer::create(WTFMove(options)); No need to move options > LayoutTests/imported/w3c/ChangeLog:19 > + * web-platform-tests/webaudio/the-audio-api/the-oscillatornode-interface/osc-basic-waveform-expected.txt: Nice to see all these newly passing tests.
Clark Wang
Comment 6 2020-07-31 07:22:33 PDT
(In reply to youenn fablet from comment #5) > Comment on attachment 405635 [details] > Patch > > LGTM but some related tests are failing in EWS. > > View in context: > https://bugs.webkit.org/attachment.cgi?id=405635&action=review > > > Source/WebCore/Modules/webaudio/AudioBuffer.idl:36 > > readonly attribute long length; // in sample-frames > > Seems strange that we pass an unsigned long length in AudioBufferOptions but > (probably) add a getter for the same value as long. > Probably we want it to be unsigned long as well given its name. > Yup, and according to spec it should be unsigned long as well, doesn't hurt to add in this patch I guess. > > Source/WebCore/Modules/webaudio/AudioBufferOptions.h:34 > > + unsigned length; > > We are using unsigned here, as per WebIDL I believe, but size_t at some > point for instance in AudioBuffer::create. > This is probably fine for this patch but I wonder whether we should try to > be more consistent in the type used for length. > Right, should agree on something. > > Source/WebCore/Modules/webaudio/BaseAudioContext.cpp:395 > > + return AudioBuffer::create(WTFMove(options)); > > No need to move options Got it. > > > LayoutTests/imported/w3c/ChangeLog:19 > > + * web-platform-tests/webaudio/the-audio-api/the-oscillatornode-interface/osc-basic-waveform-expected.txt: > > Nice to see all these newly passing tests. Just from a simple constructor :)
Clark Wang
Comment 7 2020-07-31 07:29:47 PDT
Clark Wang
Comment 8 2020-07-31 07:41:11 PDT
Clark Wang
Comment 9 2020-07-31 07:42:02 PDT
Resubmitted because old patch accidentally capitalized imported in LayoutTests/TestExpectations
youenn fablet
Comment 10 2020-07-31 08:22:20 PDT
Comment on attachment 405693 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=405693&action=review > Source/WebCore/Modules/webaudio/AudioBuffer.cpp:55 > +ExceptionOr<Ref<AudioBuffer>> AudioBuffer::create(const AudioBufferOptions& options) We should try to remove the other AudioBuffer::create and just use this new one as a follow-up patch. That will remove some potentially duplicated code. > Source/WebCore/Modules/webaudio/BaseAudioContext.cpp:395 > + return AudioBuffer::create(options); This could probably be made as a one-liner.
Clark Wang
Comment 11 2020-07-31 09:21:19 PDT
Clark Wang
Comment 12 2020-07-31 09:22:27 PDT
(In reply to youenn fablet from comment #10) > Comment on attachment 405693 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=405693&action=review > > > Source/WebCore/Modules/webaudio/AudioBuffer.cpp:55 > > +ExceptionOr<Ref<AudioBuffer>> AudioBuffer::create(const AudioBufferOptions& options) > > We should try to remove the other AudioBuffer::create and just use this new > one as a follow-up patch. > That will remove some potentially duplicated code. Got it, there are some dependencies in files such as ScriptProcessorNode. > > > Source/WebCore/Modules/webaudio/BaseAudioContext.cpp:395 > > + return AudioBuffer::create(options); > > This could probably be made as a one-liner. Updated this, also changed length in AudioBufferOptions.h back to size_t to support this change.
Chris Dumez
Comment 13 2020-07-31 09:24:18 PDT
(In reply to Clark Wang from comment #12) > (In reply to youenn fablet from comment #10) > > Comment on attachment 405693 [details] > > Patch > > > > View in context: > > https://bugs.webkit.org/attachment.cgi?id=405693&action=review > > > > > Source/WebCore/Modules/webaudio/AudioBuffer.cpp:55 > > > +ExceptionOr<Ref<AudioBuffer>> AudioBuffer::create(const AudioBufferOptions& options) > > > > We should try to remove the other AudioBuffer::create and just use this new > > one as a follow-up patch. > > That will remove some potentially duplicated code. > > Got it, there are some dependencies in files such as ScriptProcessorNode. > > > > > > Source/WebCore/Modules/webaudio/BaseAudioContext.cpp:395 > > > + return AudioBuffer::create(options); > > > > This could probably be made as a one-liner. > > Updated this, also changed length in AudioBufferOptions.h back to size_t to > support this change. If you want to align one way, align to unsigned, not size_t.
Clark Wang
Comment 14 2020-07-31 10:28:12 PDT
Clark Wang
Comment 15 2020-07-31 10:28:58 PDT
(In reply to Chris Dumez from comment #13) > (In reply to Clark Wang from comment #12) > > (In reply to youenn fablet from comment #10) > > > Comment on attachment 405693 [details] > > > Patch > > > > > > View in context: > > > https://bugs.webkit.org/attachment.cgi?id=405693&action=review > > > > > > > Source/WebCore/Modules/webaudio/AudioBuffer.cpp:55 > > > > +ExceptionOr<Ref<AudioBuffer>> AudioBuffer::create(const AudioBufferOptions& options) > > > > > > We should try to remove the other AudioBuffer::create and just use this new > > > one as a follow-up patch. > > > That will remove some potentially duplicated code. > > > > Got it, there are some dependencies in files such as ScriptProcessorNode. > > > > > > > > > Source/WebCore/Modules/webaudio/BaseAudioContext.cpp:395 > > > > + return AudioBuffer::create(options); > > > > > > This could probably be made as a one-liner. > > > > Updated this, also changed length in AudioBufferOptions.h back to size_t to > > support this change. > > If you want to align one way, align to unsigned, not size_t. Modified the code to align to unsigned.
Chris Dumez
Comment 16 2020-07-31 13:36:52 PDT
Comment on attachment 405704 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=405704&action=review > Source/WebCore/Modules/webaudio/AudioBufferOptions.h:34 > + unsigned length; Needs an initializer > Source/WebCore/Modules/webaudio/AudioBufferOptions.h:35 > + float sampleRate; Needs an initializer
Clark Wang
Comment 17 2020-08-03 08:56:50 PDT
Clark Wang
Comment 18 2020-08-03 08:57:59 PDT
(In reply to Chris Dumez from comment #16) > Comment on attachment 405704 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=405704&action=review > > > Source/WebCore/Modules/webaudio/AudioBufferOptions.h:34 > > + unsigned length; > > Needs an initializer > > > Source/WebCore/Modules/webaudio/AudioBufferOptions.h:35 > > + float sampleRate; > > Needs an initializer Initialized these two members to the smallest values that are supported. Also made AudioBufferOptions a non-optional parameter in AudioBuffer to properly match spec.
Clark Wang
Comment 19 2020-08-03 10:05:00 PDT
Clark Wang
Comment 20 2020-08-03 10:05:39 PDT
(In reply to Clark Wang from comment #19) > Created attachment 405846 [details] > Patch Rebased, hopefully builds now.
EWS
Comment 21 2020-08-03 12:23:03 PDT
Committed r265210: <https://trac.webkit.org/changeset/265210> All reviewed patches have been landed. Closing bug and clearing flags on attachment 405846 [details].
Radar WebKit Bug Importer
Comment 22 2020-08-03 13:39:00 PDT
Note You need to log in before you can comment on or make changes to this bug.