Diff
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (265226 => 265227)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2020-08-03 22:34:10 UTC (rev 265226)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2020-08-03 22:41:32 UTC (rev 265227)
@@ -1,5 +1,18 @@
2020-08-03 Chris Dumez <cdu...@apple.com>
+ Add constructor for GainNode
+ https://bugs.webkit.org/show_bug.cgi?id=215093
+
+ Reviewed by Eric Carlson.
+
+ Rebaseline WPT tests now that more checks are passing.
+
+ * web-platform-tests/webaudio/idlharness.https.window-expected.txt:
+ * web-platform-tests/webaudio/the-audio-api/processing-model/cycle-without-delay-expected.txt:
+ * web-platform-tests/webaudio/the-audio-api/the-gainnode-interface/ctor-gain-expected.txt:
+
+2020-08-03 Chris Dumez <cdu...@apple.com>
+
Add constructor to DelayNode
https://bugs.webkit.org/show_bug.cgi?id=215083
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/idlharness.https.window-expected.txt (265226 => 265227)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/idlharness.https.window-expected.txt 2020-08-03 22:34:10 UTC (rev 265226)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/idlharness.https.window-expected.txt 2020-08-03 22:41:32 UTC (rev 265227)
@@ -722,38 +722,38 @@
FAIL AudioNode interface: new DynamicsCompressorNode(context) must inherit property "channelCountMode" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new DynamicsCompressorNode(context)')"
FAIL AudioNode interface: new DynamicsCompressorNode(context) must inherit property "channelInterpretation" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new DynamicsCompressorNode(context)')"
PASS GainNode interface: existence and properties of interface object
-FAIL GainNode interface object length assert_equals: wrong value for GainNode.length expected 1 but got 0
+PASS GainNode interface object length
PASS GainNode interface object name
PASS GainNode interface: existence and properties of interface prototype object
PASS GainNode interface: existence and properties of interface prototype object's "constructor" property
PASS GainNode interface: existence and properties of interface prototype object's @@unscopables property
PASS GainNode interface: attribute gain
-FAIL GainNode must be primary interface of new GainNode(context) assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new GainNode(context)')"
-FAIL Stringification of new GainNode(context) assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new GainNode(context)')"
-FAIL GainNode interface: new GainNode(context) must inherit property "gain" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new GainNode(context)')"
-FAIL AudioNode interface: new GainNode(context) must inherit property "connect(AudioNode, optional unsigned long, optional unsigned long)" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new GainNode(context)')"
-FAIL AudioNode interface: calling connect(AudioNode, optional unsigned long, optional unsigned long) on new GainNode(context) with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new GainNode(context)')"
-FAIL AudioNode interface: new GainNode(context) must inherit property "connect(AudioParam, optional unsigned long)" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new GainNode(context)')"
-FAIL AudioNode interface: calling connect(AudioParam, optional unsigned long) on new GainNode(context) with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new GainNode(context)')"
-FAIL AudioNode interface: new GainNode(context) must inherit property "disconnect()" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new GainNode(context)')"
-FAIL AudioNode interface: new GainNode(context) must inherit property "disconnect(unsigned long)" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new GainNode(context)')"
-FAIL AudioNode interface: calling disconnect(unsigned long) on new GainNode(context) with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new GainNode(context)')"
-FAIL AudioNode interface: new GainNode(context) must inherit property "disconnect(AudioNode)" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new GainNode(context)')"
-FAIL AudioNode interface: calling disconnect(AudioNode) on new GainNode(context) with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new GainNode(context)')"
-FAIL AudioNode interface: new GainNode(context) must inherit property "disconnect(AudioNode, unsigned long)" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new GainNode(context)')"
-FAIL AudioNode interface: calling disconnect(AudioNode, unsigned long) on new GainNode(context) with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new GainNode(context)')"
-FAIL AudioNode interface: new GainNode(context) must inherit property "disconnect(AudioNode, unsigned long, unsigned long)" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new GainNode(context)')"
-FAIL AudioNode interface: calling disconnect(AudioNode, unsigned long, unsigned long) on new GainNode(context) with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new GainNode(context)')"
-FAIL AudioNode interface: new GainNode(context) must inherit property "disconnect(AudioParam)" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new GainNode(context)')"
-FAIL AudioNode interface: calling disconnect(AudioParam) on new GainNode(context) with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new GainNode(context)')"
-FAIL AudioNode interface: new GainNode(context) must inherit property "disconnect(AudioParam, unsigned long)" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new GainNode(context)')"
-FAIL AudioNode interface: calling disconnect(AudioParam, unsigned long) on new GainNode(context) with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new GainNode(context)')"
-FAIL AudioNode interface: new GainNode(context) must inherit property "context" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new GainNode(context)')"
-FAIL AudioNode interface: new GainNode(context) must inherit property "numberOfInputs" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new GainNode(context)')"
-FAIL AudioNode interface: new GainNode(context) must inherit property "numberOfOutputs" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new GainNode(context)')"
-FAIL AudioNode interface: new GainNode(context) must inherit property "channelCount" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new GainNode(context)')"
-FAIL AudioNode interface: new GainNode(context) must inherit property "channelCountMode" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new GainNode(context)')"
-FAIL AudioNode interface: new GainNode(context) must inherit property "channelInterpretation" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new GainNode(context)')"
+PASS GainNode must be primary interface of new GainNode(context)
+PASS Stringification of new GainNode(context)
+PASS GainNode interface: new GainNode(context) must inherit property "gain" with the proper type
+PASS AudioNode interface: new GainNode(context) must inherit property "connect(AudioNode, optional unsigned long, optional unsigned long)" with the proper type
+PASS AudioNode interface: calling connect(AudioNode, optional unsigned long, optional unsigned long) on new GainNode(context) with too few arguments must throw TypeError
+PASS AudioNode interface: new GainNode(context) must inherit property "connect(AudioParam, optional unsigned long)" with the proper type
+PASS AudioNode interface: calling connect(AudioParam, optional unsigned long) on new GainNode(context) with too few arguments must throw TypeError
+PASS AudioNode interface: new GainNode(context) must inherit property "disconnect()" with the proper type
+PASS AudioNode interface: new GainNode(context) must inherit property "disconnect(unsigned long)" with the proper type
+PASS AudioNode interface: calling disconnect(unsigned long) on new GainNode(context) with too few arguments must throw TypeError
+PASS AudioNode interface: new GainNode(context) must inherit property "disconnect(AudioNode)" with the proper type
+PASS AudioNode interface: calling disconnect(AudioNode) on new GainNode(context) with too few arguments must throw TypeError
+PASS AudioNode interface: new GainNode(context) must inherit property "disconnect(AudioNode, unsigned long)" with the proper type
+PASS AudioNode interface: calling disconnect(AudioNode, unsigned long) on new GainNode(context) with too few arguments must throw TypeError
+PASS AudioNode interface: new GainNode(context) must inherit property "disconnect(AudioNode, unsigned long, unsigned long)" with the proper type
+PASS AudioNode interface: calling disconnect(AudioNode, unsigned long, unsigned long) on new GainNode(context) with too few arguments must throw TypeError
+PASS AudioNode interface: new GainNode(context) must inherit property "disconnect(AudioParam)" with the proper type
+PASS AudioNode interface: calling disconnect(AudioParam) on new GainNode(context) with too few arguments must throw TypeError
+PASS AudioNode interface: new GainNode(context) must inherit property "disconnect(AudioParam, unsigned long)" with the proper type
+PASS AudioNode interface: calling disconnect(AudioParam, unsigned long) on new GainNode(context) with too few arguments must throw TypeError
+PASS AudioNode interface: new GainNode(context) must inherit property "context" with the proper type
+PASS AudioNode interface: new GainNode(context) must inherit property "numberOfInputs" with the proper type
+PASS AudioNode interface: new GainNode(context) must inherit property "numberOfOutputs" with the proper type
+PASS AudioNode interface: new GainNode(context) must inherit property "channelCount" with the proper type
+PASS AudioNode interface: new GainNode(context) must inherit property "channelCountMode" with the proper type
+PASS AudioNode interface: new GainNode(context) must inherit property "channelInterpretation" with the proper type
FAIL IIRFilterNode interface: existence and properties of interface object assert_own_property: self does not have own property "IIRFilterNode" expected property "IIRFilterNode" missing
FAIL IIRFilterNode interface object length assert_own_property: self does not have own property "IIRFilterNode" expected property "IIRFilterNode" missing
FAIL IIRFilterNode interface object name assert_own_property: self does not have own property "IIRFilterNode" expected property "IIRFilterNode" missing
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/processing-model/cycle-without-delay-expected.txt (265226 => 265227)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/processing-model/cycle-without-delay-expected.txt 2020-08-03 22:34:10 UTC (rev 265226)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/processing-model/cycle-without-delay-expected.txt 2020-08-03 22:41:32 UTC (rev 265227)
@@ -1,3 +1,3 @@
-FAIL Test that cycles that don't contain a DelayNode are muted function is not a constructor (evaluating 'new GainNode(off)')
+FAIL Test that cycles that don't contain a DelayNode are muted assert_true: expected true got false
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-gainnode-interface/ctor-gain-expected.txt (265226 => 265227)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-gainnode-interface/ctor-gain-expected.txt 2020-08-03 22:34:10 UTC (rev 265226)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-gainnode-interface/ctor-gain-expected.txt 2020-08-03 22:41:32 UTC (rev 265227)
@@ -2,25 +2,57 @@
PASS # AUDIT TASK RUNNER STARTED.
PASS Executing "initialize"
PASS Executing "invalid constructor"
-FAIL Executing "default constructor" promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'node.numberOfInputs')"
-FAIL Executing "test AudioNodeOptions" promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'node.channelCount')"
-FAIL Executing "constructor with options" promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'node.gain')"
+PASS Executing "default constructor"
+PASS Executing "test AudioNodeOptions"
+PASS Executing "constructor with options"
PASS Audit report
PASS > [initialize]
PASS context = new OfflineAudioContext(...) did not throw an exception.
PASS < [initialize] All assertions passed. (total 1 assertions)
PASS > [invalid constructor]
-PASS new GainNode() threw TypeError: "function is not a constructor (evaluating 'new window[name]()')".
-PASS new GainNode(1) threw TypeError: "function is not a constructor (evaluating 'new window[name](1)')".
-PASS new GainNode(context, 42) threw TypeError: "function is not a constructor (evaluating 'new window[name](context, 42)')".
+PASS new GainNode() threw TypeError: "Not enough arguments".
+PASS new GainNode(1) threw TypeError: "Argument 1 ('context') to the GainNode constructor must be an instance of BaseAudioContext".
+PASS new GainNode(context, 42) threw TypeError: "Type error".
PASS < [invalid constructor] All assertions passed. (total 3 assertions)
PASS > [default constructor]
-FAIL X node0 = new GainNode(context) incorrectly threw TypeError: "function is not a constructor (evaluating 'new window[name](context, options.constructorOptions)')". assert_true: expected true got false
-FAIL X node0 instanceof GainNode is not equal to true. Got false. assert_true: expected true got false
+PASS node0 = new GainNode(context) did not throw an exception.
+PASS node0 instanceof GainNode is equal to true.
+PASS node0.numberOfInputs is equal to 1.
+PASS node0.numberOfOutputs is equal to 1.
+PASS node0.channelCount is equal to 2.
+PASS node0.channelCountMode is equal to max.
+PASS node0.channelInterpretation is equal to speakers.
+PASS node0.gain.value is equal to 1.
+PASS < [default constructor] All assertions passed. (total 8 assertions)
PASS > [test AudioNodeOptions]
-FAIL X new GainNode(c, {channelCount: 17}) incorrectly threw TypeError: "function is not a constructor (evaluating 'new window[nodeName]')". assert_true: expected true got false
+PASS new GainNode(c, {channelCount: 17}) did not throw an exception.
+PASS node.channelCount is equal to 17.
+PASS new GainNode(c, {channelCount: 0}) threw InvalidStateError: "The object is in an invalid state.".
+PASS new GainNode(c, {channelCount: 99}) threw InvalidStateError: "The object is in an invalid state.".
+PASS new GainNode(c, {channelCountMode: "max"} did not throw an exception.
+PASS node.channelCountMode is equal to max.
+PASS new GainNode(c, {channelCountMode: "max"}) did not throw an exception.
+PASS node.channelCountMode after valid setter is equal to max.
+PASS new GainNode(c, {channelCountMode: "clamped-max"}) did not throw an exception.
+PASS node.channelCountMode after valid setter is equal to clamped-max.
+PASS new GainNode(c, {channelCountMode: "explicit"}) did not throw an exception.
+PASS node.channelCountMode after valid setter is equal to explicit.
+PASS new GainNode(c, {channelCountMode: "foobar"} threw TypeError: "Type error".
+PASS node.channelCountMode after invalid setter is equal to explicit.
+PASS new GainNode(c, {channelInterpretation: "speakers"}) did not throw an exception.
+PASS node.channelInterpretation is equal to speakers.
+PASS new GainNode(c, {channelInterpretation: "discrete"}) did not throw an exception.
+PASS node.channelInterpretation is equal to discrete.
+PASS new GainNode(c, {channelInterpretation: "foobar"}) threw TypeError: "Type error".
+PASS node.channelInterpretation after invalid setter is equal to discrete.
+PASS < [test AudioNodeOptions] All assertions passed. (total 20 assertions)
PASS > [constructor with options]
-FAIL X node1 = new GainNode(c, {"gain":-2}) incorrectly threw TypeError: "function is not a constructor (evaluating 'new GainNode(context, options)')". assert_true: expected true got false
-FAIL X node1 instanceof GainNode is not equal to true. Got false. assert_true: expected true got false
-FAIL # AUDIT TASK RUNNER FINISHED: 3 out of 5 tasks were failed. assert_true: expected true got false
+PASS node1 = new GainNode(c, {"gain":-2}) did not throw an exception.
+PASS node1 instanceof GainNode is equal to true.
+PASS node1.gain.value is equal to -2.
+PASS node1.channelCount is equal to 2.
+PASS node1.channelCountMode is equal to max.
+PASS node1.channelInterpretation is equal to speakers.
+PASS < [constructor with options] All assertions passed. (total 6 assertions)
+PASS # AUDIT TASK RUNNER FINISHED: 5 tasks ran successfully.
Modified: trunk/Source/WebCore/CMakeLists.txt (265226 => 265227)
--- trunk/Source/WebCore/CMakeLists.txt 2020-08-03 22:34:10 UTC (rev 265226)
+++ trunk/Source/WebCore/CMakeLists.txt 2020-08-03 22:41:32 UTC (rev 265227)
@@ -476,6 +476,7 @@
Modules/webaudio/DistanceModelType.idl
Modules/webaudio/DynamicsCompressorNode.idl
Modules/webaudio/GainNode.idl
+ Modules/webaudio/GainOptions.idl
Modules/webaudio/MediaElementAudioSourceNode.idl
Modules/webaudio/MediaStreamAudioDestinationNode.idl
Modules/webaudio/MediaStreamAudioSourceNode.idl
Modified: trunk/Source/WebCore/ChangeLog (265226 => 265227)
--- trunk/Source/WebCore/ChangeLog 2020-08-03 22:34:10 UTC (rev 265226)
+++ trunk/Source/WebCore/ChangeLog 2020-08-03 22:41:32 UTC (rev 265227)
@@ -1,5 +1,35 @@
2020-08-03 Chris Dumez <cdu...@apple.com>
+ Add constructor for GainNode
+ https://bugs.webkit.org/show_bug.cgi?id=215093
+
+ Reviewed by Eric Carlson.
+
+ Add constructor for GainNode as per:
+ - https://www.w3.org/TR/webaudio/#gainnode
+
+ No new tests, rebaselined existing tests.
+
+ * CMakeLists.txt:
+ * DerivedSources-input.xcfilelist:
+ * DerivedSources-output.xcfilelist:
+ * DerivedSources.make:
+ * Modules/webaudio/BaseAudioContext.cpp:
+ (WebCore::BaseAudioContext::createGain):
+ * Modules/webaudio/GainNode.cpp:
+ (WebCore::GainNode::create):
+ (WebCore::GainNode::GainNode):
+ (WebCore::GainNode::process):
+ (WebCore::GainNode::reset):
+ * Modules/webaudio/GainNode.h:
+ * Modules/webaudio/GainNode.idl:
+ * Modules/webaudio/GainOptions.h: Copied from Source/WebCore/Modules/webaudio/GainNode.idl.
+ * Modules/webaudio/GainOptions.idl: Copied from Source/WebCore/Modules/webaudio/GainNode.idl.
+ * Sources.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+
+2020-08-03 Chris Dumez <cdu...@apple.com>
+
Add constructor to DelayNode
https://bugs.webkit.org/show_bug.cgi?id=215083
Modified: trunk/Source/WebCore/DerivedSources-input.xcfilelist (265226 => 265227)
--- trunk/Source/WebCore/DerivedSources-input.xcfilelist 2020-08-03 22:34:10 UTC (rev 265226)
+++ trunk/Source/WebCore/DerivedSources-input.xcfilelist 2020-08-03 22:41:32 UTC (rev 265227)
@@ -325,6 +325,7 @@
$(PROJECT_DIR)/Modules/webaudio/DistanceModelType.idl
$(PROJECT_DIR)/Modules/webaudio/DynamicsCompressorNode.idl
$(PROJECT_DIR)/Modules/webaudio/GainNode.idl
+$(PROJECT_DIR)/Modules/webaudio/GainOptions.idl
$(PROJECT_DIR)/Modules/webaudio/MediaElementAudioSourceNode.idl
$(PROJECT_DIR)/Modules/webaudio/MediaStreamAudioDestinationNode.idl
$(PROJECT_DIR)/Modules/webaudio/MediaStreamAudioSourceNode.idl
Modified: trunk/Source/WebCore/DerivedSources-output.xcfilelist (265226 => 265227)
--- trunk/Source/WebCore/DerivedSources-output.xcfilelist 2020-08-03 22:34:10 UTC (rev 265226)
+++ trunk/Source/WebCore/DerivedSources-output.xcfilelist 2020-08-03 22:41:32 UTC (rev 265227)
@@ -720,6 +720,8 @@
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUVertexInputDescriptor.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGainNode.cpp
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGainNode.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGainOptions.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGainOptions.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGamepad.cpp
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGamepad.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGamepadButton.cpp
Modified: trunk/Source/WebCore/DerivedSources.make (265226 => 265227)
--- trunk/Source/WebCore/DerivedSources.make 2020-08-03 22:34:10 UTC (rev 265226)
+++ trunk/Source/WebCore/DerivedSources.make 2020-08-03 22:41:32 UTC (rev 265227)
@@ -408,6 +408,7 @@
$(WebCore)/Modules/webaudio/DistanceModelType.idl \
$(WebCore)/Modules/webaudio/DynamicsCompressorNode.idl \
$(WebCore)/Modules/webaudio/GainNode.idl \
+ $(WebCore)/Modules/webaudio/GainOptions.idl \
$(WebCore)/Modules/webaudio/MediaElementAudioSourceNode.idl \
$(WebCore)/Modules/webaudio/MediaStreamAudioDestinationNode.idl \
$(WebCore)/Modules/webaudio/MediaStreamAudioSourceNode.idl \
Modified: trunk/Source/WebCore/Modules/webaudio/BaseAudioContext.cpp (265226 => 265227)
--- trunk/Source/WebCore/Modules/webaudio/BaseAudioContext.cpp 2020-08-03 22:34:10 UTC (rev 265226)
+++ trunk/Source/WebCore/Modules/webaudio/BaseAudioContext.cpp 2020-08-03 22:41:32 UTC (rev 265227)
@@ -556,11 +556,7 @@
ALWAYS_LOG(LOGIDENTIFIER);
ASSERT(isMainThread());
- if (m_isStopScheduled)
- return Exception { InvalidStateError };
-
- lazyInitialize();
- return GainNode::create(*this, sampleRate());
+ return GainNode::create(*this);
}
ExceptionOr<Ref<DelayNode>> BaseAudioContext::createDelay(double maxDelayTime)
Modified: trunk/Source/WebCore/Modules/webaudio/GainNode.cpp (265226 => 265227)
--- trunk/Source/WebCore/Modules/webaudio/GainNode.cpp 2020-08-03 22:34:10 UTC (rev 265226)
+++ trunk/Source/WebCore/Modules/webaudio/GainNode.cpp 2020-08-03 22:41:32 UTC (rev 265227)
@@ -37,15 +37,39 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(GainNode);
-GainNode::GainNode(BaseAudioContext& context, float sampleRate)
- : AudioNode(context, sampleRate)
- , m_lastGain(1.0)
+ExceptionOr<Ref<GainNode>> GainNode::create(BaseAudioContext& context, const GainOptions& options)
+{
+ if (context.isStopped())
+ return Exception { InvalidStateError };
+
+ context.lazyInitialize();
+
+ auto gainNode = adoptRef(*new GainNode(context));
+
+ auto result = gainNode->setChannelCount(options.channelCount.valueOr(2));
+ if (result.hasException())
+ return result.releaseException();
+
+ result = gainNode->setChannelCountMode(options.channelCountMode.valueOr(ChannelCountMode::Max));
+ if (result.hasException())
+ return result.releaseException();
+
+ result = gainNode->setChannelInterpretation(options.channelInterpretation.valueOr(ChannelInterpretation::Speakers));
+ if (result.hasException())
+ return result.releaseException();
+
+ gainNode->gain().setValue(options.gain);
+
+ return gainNode;
+}
+
+GainNode::GainNode(BaseAudioContext& context)
+ : AudioNode(context, context.sampleRate())
, m_sampleAccurateGainValues(AudioNode::ProcessingSizeInFrames) // FIXME: can probably share temp buffer in context
+ , m_gain(AudioParam::create(context, "gain"_s, 1.0, -FLT_MAX, FLT_MAX))
{
setNodeType(NodeTypeGain);
- m_gain = AudioParam::create(context, "gain", 1.0, 0.0, 1.0);
-
addInput(makeUnique<AudioNodeInput>(this));
addOutput(makeUnique<AudioNodeOutput>(this, 1));
@@ -66,12 +90,12 @@
else {
AudioBus* inputBus = input(0)->bus();
- if (gain()->hasSampleAccurateValues()) {
+ if (gain().hasSampleAccurateValues()) {
// Apply sample-accurate gain scaling for precise envelopes, grain windows, etc.
ASSERT(framesToProcess <= m_sampleAccurateGainValues.size());
if (framesToProcess <= m_sampleAccurateGainValues.size()) {
float* gainValues = m_sampleAccurateGainValues.data();
- gain()->calculateSampleAccurateValues(gainValues, framesToProcess);
+ gain().calculateSampleAccurateValues(gainValues, framesToProcess);
outputBus->copyWithSampleAccurateGainValuesFrom(*inputBus, gainValues, framesToProcess);
}
} else {
@@ -81,7 +105,7 @@
// the silence hint.
outputBus->zero();
} else
- outputBus->copyWithGainFrom(*inputBus, &m_lastGain, gain()->value());
+ outputBus->copyWithGainFrom(*inputBus, &m_lastGain, gain().value());
}
}
}
@@ -89,7 +113,7 @@
void GainNode::reset()
{
// Snap directly to desired gain.
- m_lastGain = gain()->value();
+ m_lastGain = gain().value();
}
// FIXME: this can go away when we do mixing with gain directly in summing junction of AudioNodeInput
Modified: trunk/Source/WebCore/Modules/webaudio/GainNode.h (265226 => 265227)
--- trunk/Source/WebCore/Modules/webaudio/GainNode.h 2020-08-03 22:34:10 UTC (rev 265226)
+++ trunk/Source/WebCore/Modules/webaudio/GainNode.h 2020-08-03 22:41:32 UTC (rev 265227)
@@ -26,6 +26,7 @@
#include "AudioNode.h"
#include "AudioParam.h"
+#include "GainOptions.h"
#include <wtf/Threading.h>
namespace WebCore {
@@ -38,10 +39,7 @@
class GainNode final : public AudioNode {
WTF_MAKE_ISO_ALLOCATED(GainNode);
public:
- static Ref<GainNode> create(BaseAudioContext& context, float sampleRate)
- {
- return adoptRef(*new GainNode(context, sampleRate));
- }
+ static ExceptionOr<Ref<GainNode>> create(BaseAudioContext& context, const GainOptions& = { });
// AudioNode
void process(size_t framesToProcess) override;
@@ -51,18 +49,17 @@
void checkNumberOfChannelsForInput(AudioNodeInput*) override;
// _javascript_ interface
- AudioParam* gain() { return m_gain.get(); }
+ AudioParam& gain() { return m_gain.get(); }
private:
double tailTime() const override { return 0; }
double latencyTime() const override { return 0; }
- GainNode(BaseAudioContext&, float sampleRate);
+ explicit GainNode(BaseAudioContext&);
- float m_lastGain; // for de-zippering
- RefPtr<AudioParam> m_gain;
-
+ float m_lastGain { 1.0 }; // for de-zippering
AudioFloatArray m_sampleAccurateGainValues;
+ Ref<AudioParam> m_gain;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/Modules/webaudio/GainNode.idl (265226 => 265227)
--- trunk/Source/WebCore/Modules/webaudio/GainNode.idl 2020-08-03 22:34:10 UTC (rev 265226)
+++ trunk/Source/WebCore/Modules/webaudio/GainNode.idl 2020-08-03 22:41:32 UTC (rev 265227)
@@ -26,6 +26,7 @@
Conditional=WEB_AUDIO,
JSGenerateToJSObject
] interface GainNode : AudioNode {
- // FIXME: eventually it will be interesting to remove the readonly restriction, but need to properly deal with thread safety here.
+ [MayThrowException, EnabledBySetting=ModernUnprefixedWebAudio] constructor (BaseAudioContext context, optional GainOptions options);
+
readonly attribute AudioParam gain;
};
Copied: trunk/Source/WebCore/Modules/webaudio/GainOptions.h (from rev 265226, trunk/Source/WebCore/Modules/webaudio/GainNode.idl) (0 => 265227)
--- trunk/Source/WebCore/Modules/webaudio/GainOptions.h (rev 0)
+++ trunk/Source/WebCore/Modules/webaudio/GainOptions.h 2020-08-03 22:41:32 UTC (rev 265227)
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2020, Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(WEB_AUDIO)
+
+#include "AudioNodeOptions.h"
+
+namespace WebCore {
+
+struct GainOptions : AudioNodeOptions {
+ float gain { 1.0 };
+};
+
+}
+
+#endif // ENABLE(WEB_AUDIO)
Copied: trunk/Source/WebCore/Modules/webaudio/GainOptions.idl (from rev 265226, trunk/Source/WebCore/Modules/webaudio/GainNode.idl) (0 => 265227)
--- trunk/Source/WebCore/Modules/webaudio/GainOptions.idl (rev 0)
+++ trunk/Source/WebCore/Modules/webaudio/GainOptions.idl 2020-08-03 22:41:32 UTC (rev 265227)
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2020, Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+ Conditional=WEB_AUDIO
+] dictionary GainOptions : AudioNodeOptions {
+ float gain = 1.0;
+};
Modified: trunk/Source/WebCore/Sources.txt (265226 => 265227)
--- trunk/Source/WebCore/Sources.txt 2020-08-03 22:34:10 UTC (rev 265226)
+++ trunk/Source/WebCore/Sources.txt 2020-08-03 22:41:32 UTC (rev 265227)
@@ -2901,6 +2901,7 @@
JSGPUVertexBufferDescriptor.cpp
JSGPUVertexInputDescriptor.cpp
JSGainNode.cpp
+JSGainOptions.cpp
JSGamepad.cpp
JSGamepadButton.cpp
JSGamepadEvent.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (265226 => 265227)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2020-08-03 22:34:10 UTC (rev 265226)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2020-08-03 22:41:32 UTC (rev 265227)
@@ -2478,6 +2478,7 @@
837056901F50915C00D93425 /* JSFileSystemEntryCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 837056891F50915000D93425 /* JSFileSystemEntryCallback.h */; };
8371AC3B1F509BE400FBF284 /* ErrorCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 8371AC391F509BDD00FBF284 /* ErrorCallback.h */; };
8372DB311A6780A800C697C5 /* DiagnosticLoggingResultType.h in Headers */ = {isa = PBXBuildFile; fileRef = 8372DB301A6780A800C697C5 /* DiagnosticLoggingResultType.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 83745D0224D899D300FBDCC4 /* GainOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 83745CFF24D899C200FBDCC4 /* GainOptions.h */; };
83765F951DAC522F00C06537 /* MouseEventInit.h in Headers */ = {isa = PBXBuildFile; fileRef = 83765F941DAC521800C06537 /* MouseEventInit.h */; settings = {ATTRIBUTES = (Private, ); }; };
8379363F1FBBB0B400C8023C /* ServiceWorkerClientData.h in Headers */ = {isa = PBXBuildFile; fileRef = 8379363E1FBBB0A500C8023C /* ServiceWorkerClientData.h */; settings = {ATTRIBUTES = (Private, ); }; };
837964CF1F8DB69D00218EA0 /* GeolocationPositionDataIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 837964CE1F8DB69A00218EA0 /* GeolocationPositionDataIOS.mm */; };
@@ -10528,6 +10529,8 @@
8371AC381F509BDD00FBF284 /* FileCallback.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = FileCallback.idl; sourceTree = "<group>"; };
8371AC391F509BDD00FBF284 /* ErrorCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ErrorCallback.h; sourceTree = "<group>"; };
8372DB301A6780A800C697C5 /* DiagnosticLoggingResultType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DiagnosticLoggingResultType.h; sourceTree = "<group>"; };
+ 83745CFF24D899C200FBDCC4 /* GainOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GainOptions.h; sourceTree = "<group>"; };
+ 83745D0124D899C200FBDCC4 /* GainOptions.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = GainOptions.idl; sourceTree = "<group>"; };
837609C81F54CC13000C122D /* ErrorCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ErrorCallback.cpp; sourceTree = "<group>"; };
83765F931DAC521800C06537 /* MouseEventInit.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MouseEventInit.idl; sourceTree = "<group>"; };
83765F941DAC521800C06537 /* MouseEventInit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MouseEventInit.h; sourceTree = "<group>"; };
@@ -29581,6 +29584,8 @@
FD315FC212B0267500C1A359 /* GainNode.cpp */,
FD315FC312B0267500C1A359 /* GainNode.h */,
FD315FC412B0267500C1A359 /* GainNode.idl */,
+ 83745CFF24D899C200FBDCC4 /* GainOptions.h */,
+ 83745D0124D899C200FBDCC4 /* GainOptions.idl */,
FD6F252913F5EF0E0065165F /* MediaElementAudioSourceNode.cpp */,
FD6F252A13F5EF0E0065165F /* MediaElementAudioSourceNode.h */,
FD6F252B13F5EF0E0065165F /* MediaElementAudioSourceNode.idl */,
@@ -31031,6 +31036,7 @@
CD92F5182261038200F87BB3 /* FullscreenManager.h in Headers */,
26B999931803B9D900D01121 /* FunctionCall.h in Headers */,
FD31600D12B0267600C1A359 /* GainNode.h in Headers */,
+ 83745D0224D899D300FBDCC4 /* GainOptions.h in Headers */,
51E399001D6E4750009C8831 /* GameControllerGamepad.h in Headers */,
51E399021D6E4750009C8831 /* GameControllerGamepadProvider.h in Headers */,
510A91FD24D3C16200BFD89C /* GamepadConstants.h in Headers */,