Title: [264342] trunk
Revision
264342
Author
commit-qu...@webkit.org
Date
2020-07-14 08:51:18 -0700 (Tue, 14 Jul 2020)

Log Message

Updated AudioContext constructor according to spec
https://bugs.webkit.org/show_bug.cgi?id=214267

Patch by Clark Wang <clark_w...@apple.com> on 2020-07-14
Reviewed by Chris Dumez.

LayoutTests/imported/w3c:

Re-baselined existing tests. One new test case passes, and one fails due to current accepted range for sampleRate.

* web-platform-tests/webaudio/the-audio-api/the-audionode-interface/audionode-expected.txt:
* web-platform-tests/webaudio/the-audio-api/the-convolvernode-interface/realtime-conv-expected.txt:

Source/WebCore:

Updated AudioContext constructor according to spec: https://www.w3.org/TR/webaudio/#AudioContext-constructors.
Added in files accordingly to support AudioContextOptions.

Re-baselined existing tests. One new test case passes, and one fails due to current accepted range for sampleRate.

* CMakeLists.txt:
* DerivedSources-input.xcfilelist:
* DerivedSources-output.xcfilelist:
* DerivedSources.make:
* Modules/webaudio/AudioContext.cpp:
(WebCore::AudioContext::create):
(WebCore::AudioContext::AudioContext):
* Modules/webaudio/AudioContext.h:
(WebCore::AudioContext::create):
* Modules/webaudio/AudioContext.idl:
* Modules/webaudio/AudioContextLatencyCategory.h: Added.
* Modules/webaudio/AudioContextLatencyCategory.idl: Added.
* Modules/webaudio/AudioContextOptions.h: Added.
* Modules/webaudio/AudioContextOptions.idl: Added.
* Modules/webaudio/BaseAudioContext.cpp:
(WebCore::BaseAudioContext::BaseAudioContext):
* Modules/webaudio/BaseAudioContext.h:
* Modules/webaudio/DefaultAudioDestinationNode.cpp:
(WebCore::DefaultAudioDestinationNode::DefaultAudioDestinationNode):
* Modules/webaudio/DefaultAudioDestinationNode.h:
* Modules/webaudio/PannerNode.cpp:
(WebCore::PannerNode::PannerNode):
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (264341 => 264342)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2020-07-14 15:49:42 UTC (rev 264341)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2020-07-14 15:51:18 UTC (rev 264342)
@@ -1,3 +1,15 @@
+2020-07-14  Clark Wang  <clark_w...@apple.com>
+
+        Updated AudioContext constructor according to spec
+        https://bugs.webkit.org/show_bug.cgi?id=214267
+
+        Reviewed by Chris Dumez.
+
+        Re-baselined existing tests. One new test case passes, and one fails due to current accepted range for sampleRate.
+
+        * web-platform-tests/webaudio/the-audio-api/the-audionode-interface/audionode-expected.txt:
+        * web-platform-tests/webaudio/the-audio-api/the-convolvernode-interface/realtime-conv-expected.txt:
+
 2020-07-14  Carlos Alberto Lopez Perez  <clo...@igalia.com>
 
         Update WPT tests for css-ui

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audionode-interface/audionode-expected.txt (264341 => 264342)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audionode-interface/audionode-expected.txt	2020-07-14 15:49:42 UTC (rev 264341)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audionode-interface/audionode-expected.txt	2020-07-14 15:51:18 UTC (rev 264342)
@@ -13,8 +13,8 @@
 PASS   audioNode.connect(context.destination, 0, 5) threw IndexSizeError: "The index is not in the allowed range.". 
 PASS   audioNode.connect(context.destination, 0, 0) did not throw an exception. 
 PASS   Connecting a node to a different context threw SyntaxError: "The string did not match the expected pattern.". 
-FAIL X context3 = new AudioContext(1, 44100, 44100) did not throw an exception. assert_true: expected true got false
+PASS   context3 = new AudioContext(1, 44100, 44100) threw TypeError: "Type error". 
 PASS   AudioNode is an EventTarget is true. 
-FAIL < [test] 1 out of 12 assertions were failed. assert_true: expected true got false
-FAIL # AUDIT TASK RUNNER FINISHED: 1 out of 1 tasks were failed. assert_true: expected true got false
+PASS < [test] All assertions passed. (total 12 assertions) 
+PASS # AUDIT TASK RUNNER FINISHED: 1 tasks ran successfully. 
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-convolvernode-interface/realtime-conv-expected.txt (264341 => 264342)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-convolvernode-interface/realtime-conv-expected.txt	2020-07-14 15:49:42 UTC (rev 264341)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-convolvernode-interface/realtime-conv-expected.txt	2020-07-14 15:51:18 UTC (rev 264342)
@@ -1,7 +1,6 @@
 
 PASS # AUDIT TASK RUNNER STARTED. 
-FAIL Executing "test" promise_test: Unhandled rejection with value: object "TypeError: function is not a constructor (evaluating 'new AudioBuffer(
-                {length: pulseLength, sampleRate: context.sampleRate})')"
+FAIL Executing "test" promise_test: Unhandled rejection with value: object "SyntaxError: sampleRate is not in range"
 PASS Audit report 
 PASS > [test] Test convolver with real-time context 
 PASS # AUDIT TASK RUNNER FINISHED: 1 tasks ran successfully. 

Modified: trunk/Source/WebCore/CMakeLists.txt (264341 => 264342)


--- trunk/Source/WebCore/CMakeLists.txt	2020-07-14 15:49:42 UTC (rev 264341)
+++ trunk/Source/WebCore/CMakeLists.txt	2020-07-14 15:51:18 UTC (rev 264342)
@@ -450,6 +450,8 @@
     Modules/webaudio/AudioBufferCallback.idl
     Modules/webaudio/AudioBufferSourceNode.idl
     Modules/webaudio/AudioContext.idl
+    Modules/webaudio/AudioContextLatencyCategory.idl
+    Modules/webaudio/AudioContextOptions.idl
     Modules/webaudio/AudioContextState.idl
     Modules/webaudio/AudioDestinationNode.idl
     Modules/webaudio/AudioListener.idl

Modified: trunk/Source/WebCore/ChangeLog (264341 => 264342)


--- trunk/Source/WebCore/ChangeLog	2020-07-14 15:49:42 UTC (rev 264341)
+++ trunk/Source/WebCore/ChangeLog	2020-07-14 15:51:18 UTC (rev 264342)
@@ -1,3 +1,40 @@
+2020-07-14  Clark Wang  <clark_w...@apple.com>
+
+        Updated AudioContext constructor according to spec
+        https://bugs.webkit.org/show_bug.cgi?id=214267
+
+        Reviewed by Chris Dumez.
+
+        Updated AudioContext constructor according to spec: https://www.w3.org/TR/webaudio/#AudioContext-constructors.
+        Added in files accordingly to support AudioContextOptions.
+
+        Re-baselined existing tests. One new test case passes, and one fails due to current accepted range for sampleRate.
+
+        * CMakeLists.txt:
+        * DerivedSources-input.xcfilelist:
+        * DerivedSources-output.xcfilelist:
+        * DerivedSources.make:
+        * Modules/webaudio/AudioContext.cpp:
+        (WebCore::AudioContext::create):
+        (WebCore::AudioContext::AudioContext):
+        * Modules/webaudio/AudioContext.h:
+        (WebCore::AudioContext::create):
+        * Modules/webaudio/AudioContext.idl:
+        * Modules/webaudio/AudioContextLatencyCategory.h: Added.
+        * Modules/webaudio/AudioContextLatencyCategory.idl: Added.
+        * Modules/webaudio/AudioContextOptions.h: Added.
+        * Modules/webaudio/AudioContextOptions.idl: Added.
+        * Modules/webaudio/BaseAudioContext.cpp:
+        (WebCore::BaseAudioContext::BaseAudioContext):
+        * Modules/webaudio/BaseAudioContext.h:
+        * Modules/webaudio/DefaultAudioDestinationNode.cpp:
+        (WebCore::DefaultAudioDestinationNode::DefaultAudioDestinationNode):
+        * Modules/webaudio/DefaultAudioDestinationNode.h:
+        * Modules/webaudio/PannerNode.cpp:
+        (WebCore::PannerNode::PannerNode):
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+
 2020-07-14  Justin Fan  <justin_...@apple.com>
 
         [WebGL] REGRESSION (r262366): Google search photos do not render, black images

Modified: trunk/Source/WebCore/DerivedSources-input.xcfilelist (264341 => 264342)


--- trunk/Source/WebCore/DerivedSources-input.xcfilelist	2020-07-14 15:49:42 UTC (rev 264341)
+++ trunk/Source/WebCore/DerivedSources-input.xcfilelist	2020-07-14 15:51:18 UTC (rev 264342)
@@ -299,6 +299,8 @@
 $(PROJECT_DIR)/Modules/webaudio/AudioBufferCallback.idl
 $(PROJECT_DIR)/Modules/webaudio/AudioBufferSourceNode.idl
 $(PROJECT_DIR)/Modules/webaudio/AudioContext.idl
+$(PROJECT_DIR)/Modules/webaudio/AudioContextLatencyCategory.idl
+$(PROJECT_DIR)/Modules/webaudio/AudioContextOptions.idl
 $(PROJECT_DIR)/Modules/webaudio/AudioContextState.idl
 $(PROJECT_DIR)/Modules/webaudio/AudioDestinationNode.idl
 $(PROJECT_DIR)/Modules/webaudio/AudioListener.idl

Modified: trunk/Source/WebCore/DerivedSources-output.xcfilelist (264341 => 264342)


--- trunk/Source/WebCore/DerivedSources-output.xcfilelist	2020-07-14 15:49:42 UTC (rev 264341)
+++ trunk/Source/WebCore/DerivedSources-output.xcfilelist	2020-07-14 15:51:18 UTC (rev 264342)
@@ -155,6 +155,10 @@
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAudioConfiguration.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAudioContext.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAudioContext.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAudioContextLatencyCategory.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAudioContextLatencyCategory.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAudioContextOptions.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAudioContextOptions.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAudioContextState.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAudioContextState.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAudioDestinationNode.cpp

Modified: trunk/Source/WebCore/DerivedSources.make (264341 => 264342)


--- trunk/Source/WebCore/DerivedSources.make	2020-07-14 15:49:42 UTC (rev 264341)
+++ trunk/Source/WebCore/DerivedSources.make	2020-07-14 15:51:18 UTC (rev 264342)
@@ -382,6 +382,8 @@
     $(WebCore)/Modules/webaudio/AudioBufferCallback.idl \
     $(WebCore)/Modules/webaudio/AudioBufferSourceNode.idl \
     $(WebCore)/Modules/webaudio/AudioContext.idl \
+    $(WebCore)/Modules/webaudio/AudioContextLatencyCategory.idl \
+    $(WebCore)/Modules/webaudio/AudioContextOptions.idl \
     $(WebCore)/Modules/webaudio/AudioContextState.idl \
     $(WebCore)/Modules/webaudio/AudioDestinationNode.idl \
     $(WebCore)/Modules/webaudio/AudioListener.idl \

Modified: trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp (264341 => 264342)


--- trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp	2020-07-14 15:49:42 UTC (rev 264341)
+++ trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp	2020-07-14 15:51:18 UTC (rev 264342)
@@ -51,8 +51,8 @@
 #endif
 
 WTF_MAKE_ISO_ALLOCATED_IMPL(AudioContext);
-    
-ExceptionOr<Ref<AudioContext>> AudioContext::create(Document& document)
+
+ExceptionOr<Ref<AudioContext>> AudioContext::create(Document& document, const AudioContextOptions& contextOptions)
 {
     ASSERT(isMainThread());
 #if OS(WINDOWS)
@@ -59,15 +59,23 @@
     if (s_hardwareContextCount >= maxHardwareContexts)
         return Exception { QuotaExceededError };
 #endif
+    
+    if (!document.isFullyActive())
+        return Exception { InvalidStateError, "Document is not fully active"_s };
+    
+    // FIXME: Figure out where latencyHint should go.
 
-    auto audioContext = adoptRef(*new AudioContext(document));
+    if (contextOptions.sampleRate.hasValue() && !isSampleRateRangeGood(contextOptions.sampleRate.value()))
+        return Exception { SyntaxError, "sampleRate is not in range"_s };
+    
+    auto audioContext = adoptRef(*new AudioContext(document, contextOptions));
     audioContext->suspendIfNeeded();
     return audioContext;
 }
 
 // Constructor for rendering to the audio hardware.
-AudioContext::AudioContext(Document& document)
-    : BaseAudioContext(document)
+AudioContext::AudioContext(Document& document, const AudioContextOptions& contextOptions)
+    : BaseAudioContext(document, contextOptions)
 {
 }
 

Modified: trunk/Source/WebCore/Modules/webaudio/AudioContext.h (264341 => 264342)


--- trunk/Source/WebCore/Modules/webaudio/AudioContext.h	2020-07-14 15:49:42 UTC (rev 264341)
+++ trunk/Source/WebCore/Modules/webaudio/AudioContext.h	2020-07-14 15:51:18 UTC (rev 264342)
@@ -25,6 +25,7 @@
 
 #pragma once
 
+#include "AudioContextOptions.h"
 #include "BaseAudioContext.h"
 
 namespace WebCore {
@@ -33,7 +34,7 @@
     WTF_MAKE_ISO_ALLOCATED(AudioContext);
 public:
     // Create an AudioContext for rendering to the audio hardware.
-    static ExceptionOr<Ref<AudioContext>> create(Document&);
+    static ExceptionOr<Ref<AudioContext>> create(Document&, const AudioContextOptions& = { });
 
     void close(DOMPromiseDeferred<void>&&);
 
@@ -46,7 +47,7 @@
 #endif
 
 private:
-    explicit AudioContext(Document&);
+    AudioContext(Document&, const AudioContextOptions&);
     AudioContext(Document&, AudioBuffer* renderTarget);
 };
 

Modified: trunk/Source/WebCore/Modules/webaudio/AudioContext.idl (264341 => 264342)


--- trunk/Source/WebCore/Modules/webaudio/AudioContext.idl	2020-07-14 15:49:42 UTC (rev 264341)
+++ trunk/Source/WebCore/Modules/webaudio/AudioContext.idl	2020-07-14 15:51:18 UTC (rev 264342)
@@ -29,7 +29,7 @@
     EnabledBySetting=WebAudio&ModernUnprefixedWebAudio,
     ExportMacro=WEBCORE_EXPORT,
 ] interface AudioContext : BaseAudioContext {
-    [CallWith=Document, MayThrowException] constructor();
+    [CallWith=Document, MayThrowException] constructor(optional AudioContextOptions contextOptions);
 
     // FIXME: Add support.
     // readonly attribute double baseLatency;

Added: trunk/Source/WebCore/Modules/webaudio/AudioContextLatencyCategory.h (0 => 264342)


--- trunk/Source/WebCore/Modules/webaudio/AudioContextLatencyCategory.h	                        (rev 0)
+++ trunk/Source/WebCore/Modules/webaudio/AudioContextLatencyCategory.h	2020-07-14 15:51:18 UTC (rev 264342)
@@ -0,0 +1,36 @@
+/*
+ * 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
+
+namespace WebCore {
+
+enum class AudioContextLatencyCategory {
+    Balanced,
+    Interactive,
+    Playback,
+};
+
+} // namespace WebCore

Added: trunk/Source/WebCore/Modules/webaudio/AudioContextLatencyCategory.idl (0 => 264342)


--- trunk/Source/WebCore/Modules/webaudio/AudioContextLatencyCategory.idl	                        (rev 0)
+++ trunk/Source/WebCore/Modules/webaudio/AudioContextLatencyCategory.idl	2020-07-14 15:51:18 UTC (rev 264342)
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+enum AudioContextLatencyCategory {
+    "balanced",
+    "interactive",
+    "playback"
+};

Added: trunk/Source/WebCore/Modules/webaudio/AudioContextOptions.h (0 => 264342)


--- trunk/Source/WebCore/Modules/webaudio/AudioContextOptions.h	                        (rev 0)
+++ trunk/Source/WebCore/Modules/webaudio/AudioContextOptions.h	2020-07-14 15:51:18 UTC (rev 264342)
@@ -0,0 +1,43 @@
+/*
+ * 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 "AudioContextLatencyCategory.h"
+#include <wtf/Optional.h>
+#include <wtf/Variant.h>
+
+namespace WebCore {
+
+struct AudioContextOptions {
+    Variant<AudioContextLatencyCategory, double> latencyHint = AudioContextLatencyCategory::Interactive;
+    Optional<float> sampleRate;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_AUDIO)

Added: trunk/Source/WebCore/Modules/webaudio/AudioContextOptions.idl (0 => 264342)


--- trunk/Source/WebCore/Modules/webaudio/AudioContextOptions.idl	                        (rev 0)
+++ trunk/Source/WebCore/Modules/webaudio/AudioContextOptions.idl	2020-07-14 15:51:18 UTC (rev 264342)
@@ -0,0 +1,30 @@
+/*
+ * 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 AudioContextOptions {
+    (AudioContextLatencyCategory or double) latencyHint = "interactive";
+    float sampleRate;
+};

Modified: trunk/Source/WebCore/Modules/webaudio/BaseAudioContext.cpp (264341 => 264342)


--- trunk/Source/WebCore/Modules/webaudio/BaseAudioContext.cpp	2020-07-14 15:49:42 UTC (rev 264341)
+++ trunk/Source/WebCore/Modules/webaudio/BaseAudioContext.cpp	2020-07-14 15:51:18 UTC (rev 264342)
@@ -109,7 +109,7 @@
 unsigned BaseAudioContext::s_hardwareContextCount = 0;
 
 // Constructor for rendering to the audio hardware.
-BaseAudioContext::BaseAudioContext(Document& document)
+BaseAudioContext::BaseAudioContext(Document& document, const AudioContextOptions& contextOptions)
     : ActiveDOMObject(document)
 #if !RELEASE_LOG_DISABLED
     , m_logger(document.logger())
@@ -124,7 +124,7 @@
 
     constructCommon();
 
-    m_destinationNode = DefaultAudioDestinationNode::create(*this);
+    m_destinationNode = DefaultAudioDestinationNode::create(*this, contextOptions.sampleRate);
 
     // Initialize the destination node's muted state to match the page's current muted state.
     pageMutedStateDidChange();

Modified: trunk/Source/WebCore/Modules/webaudio/BaseAudioContext.h (264341 => 264342)


--- trunk/Source/WebCore/Modules/webaudio/BaseAudioContext.h	2020-07-14 15:49:42 UTC (rev 264341)
+++ trunk/Source/WebCore/Modules/webaudio/BaseAudioContext.h	2020-07-14 15:51:18 UTC (rev 264342)
@@ -28,6 +28,7 @@
 #include "ActiveDOMObject.h"
 #include "AsyncAudioDecoder.h"
 #include "AudioBus.h"
+#include "AudioContextOptions.h"
 #include "AudioContextState.h"
 #include "AudioDestinationNode.h"
 #include "EventTarget.h"
@@ -284,7 +285,7 @@
     };
 
 protected:
-    explicit BaseAudioContext(Document&);
+    explicit BaseAudioContext(Document&, const AudioContextOptions& = { });
     BaseAudioContext(Document&, AudioBuffer* renderTarget);
     
     static bool isSampleRateRangeGood(float sampleRate);

Modified: trunk/Source/WebCore/Modules/webaudio/DefaultAudioDestinationNode.cpp (264341 => 264342)


--- trunk/Source/WebCore/Modules/webaudio/DefaultAudioDestinationNode.cpp	2020-07-14 15:49:42 UTC (rev 264341)
+++ trunk/Source/WebCore/Modules/webaudio/DefaultAudioDestinationNode.cpp	2020-07-14 15:51:18 UTC (rev 264342)
@@ -42,9 +42,9 @@
 namespace WebCore {
 
 WTF_MAKE_ISO_ALLOCATED_IMPL(DefaultAudioDestinationNode);
-    
-DefaultAudioDestinationNode::DefaultAudioDestinationNode(BaseAudioContext& context)
-    : AudioDestinationNode(context, AudioDestination::hardwareSampleRate())
+
+DefaultAudioDestinationNode::DefaultAudioDestinationNode(BaseAudioContext& context, Optional<float> sampleRate)
+    : AudioDestinationNode(context, sampleRate.valueOr(AudioDestination::hardwareSampleRate()))
 {
     // Node-specific default mixing rules.
     m_channelCount = 2;

Modified: trunk/Source/WebCore/Modules/webaudio/DefaultAudioDestinationNode.h (264341 => 264342)


--- trunk/Source/WebCore/Modules/webaudio/DefaultAudioDestinationNode.h	2020-07-14 15:49:42 UTC (rev 264341)
+++ trunk/Source/WebCore/Modules/webaudio/DefaultAudioDestinationNode.h	2020-07-14 15:51:18 UTC (rev 264342)
@@ -33,15 +33,15 @@
 class DefaultAudioDestinationNode final : public AudioDestinationNode {
     WTF_MAKE_ISO_ALLOCATED(DefaultAudioDestinationNode);
 public:
-    static Ref<DefaultAudioDestinationNode> create(BaseAudioContext& context)
+    static Ref<DefaultAudioDestinationNode> create(BaseAudioContext& context, Optional<float> sampleRate = WTF::nullopt)
     {
-        return adoptRef(*new DefaultAudioDestinationNode(context));     
+        return adoptRef(*new DefaultAudioDestinationNode(context, sampleRate));
     }
-
+    
     virtual ~DefaultAudioDestinationNode();
     
 private:
-    explicit DefaultAudioDestinationNode(BaseAudioContext&);
+    explicit DefaultAudioDestinationNode(BaseAudioContext&, Optional<float>);
     void createDestination();
 
     void initialize() final;

Modified: trunk/Source/WebCore/Modules/webaudio/PannerNode.cpp (264341 => 264342)


--- trunk/Source/WebCore/Modules/webaudio/PannerNode.cpp	2020-07-14 15:49:42 UTC (rev 264341)
+++ trunk/Source/WebCore/Modules/webaudio/PannerNode.cpp	2020-07-14 15:51:18 UTC (rev 264342)
@@ -147,8 +147,6 @@
     addInput(makeUnique<AudioNodeInput>(this));
     addOutput(makeUnique<AudioNodeOutput>(this, 2));
     
-    // FIXME: Set PannerNode specific channelCount, channelCountMode, channelInterpretation here.
-    
     initialize();
 }
 

Modified: trunk/Source/WebCore/Sources.txt (264341 => 264342)


--- trunk/Source/WebCore/Sources.txt	2020-07-14 15:49:42 UTC (rev 264341)
+++ trunk/Source/WebCore/Sources.txt	2020-07-14 15:51:18 UTC (rev 264342)
@@ -2627,6 +2627,8 @@
 JSAudioBufferSourceNode.cpp
 JSAudioConfiguration.cpp
 JSAudioContext.cpp
+JSAudioContextLatencyCategory.cpp
+JSAudioContextOptions.cpp
 JSAudioContextState.cpp
 JSAudioDestinationNode.cpp
 JSAudioListener.cpp

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (264341 => 264342)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-07-14 15:49:42 UTC (rev 264341)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-07-14 15:51:18 UTC (rev 264342)
@@ -5046,6 +5046,8 @@
 		E71467B624ABAF1D00FB2F50 /* PannerOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = E71467B524ABAF1D00FB2F50 /* PannerOptions.h */; };
 		E785D91524B4D1CA0014DB21 /* ChannelCountMode.h in Headers */ = {isa = PBXBuildFile; fileRef = E785D91124B4D1B10014DB21 /* ChannelCountMode.h */; };
 		E785D93424B636FF0014DB21 /* ChannelInterpretation.h in Headers */ = {isa = PBXBuildFile; fileRef = E785D93124B636FF0014DB21 /* ChannelInterpretation.h */; };
+		E785D96124B7F7350014DB21 /* AudioContextOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = E785D95F24B7F7340014DB21 /* AudioContextOptions.h */; };
+		E785D96224B7F7350014DB21 /* AudioContextLatencyCategory.h in Headers */ = {isa = PBXBuildFile; fileRef = E785D96024B7F7340014DB21 /* AudioContextLatencyCategory.h */; };
 		EBE5B226245A26EF003A5A88 /* SQLiteStatementAutoResetScope.h in Headers */ = {isa = PBXBuildFile; fileRef = EBE5B224245A26EE003A5A88 /* SQLiteStatementAutoResetScope.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		EBF5121C1696496C0056BD25 /* JSTypeConversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EBF5121A1696496C0056BD25 /* JSTypeConversions.cpp */; };
 		EBF5121D1696496C0056BD25 /* JSTypeConversions.h in Headers */ = {isa = PBXBuildFile; fileRef = EBF5121B1696496C0056BD25 /* JSTypeConversions.h */; };
@@ -15794,6 +15796,10 @@
 		E785D91324B4D1B10014DB21 /* ChannelCountMode.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = ChannelCountMode.idl; sourceTree = "<group>"; };
 		E785D93124B636FF0014DB21 /* ChannelInterpretation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ChannelInterpretation.h; sourceTree = "<group>"; };
 		E785D93324B636FF0014DB21 /* ChannelInterpretation.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = ChannelInterpretation.idl; sourceTree = "<group>"; };
+		E785D95C24B7F7260014DB21 /* AudioContextOptions.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = AudioContextOptions.idl; sourceTree = "<group>"; };
+		E785D95E24B7F7270014DB21 /* AudioContextLatencyCategory.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = AudioContextLatencyCategory.idl; sourceTree = "<group>"; };
+		E785D95F24B7F7340014DB21 /* AudioContextOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioContextOptions.h; sourceTree = "<group>"; };
+		E785D96024B7F7340014DB21 /* AudioContextLatencyCategory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioContextLatencyCategory.h; sourceTree = "<group>"; };
 		EB081CD81696084400553730 /* TypeConversions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TypeConversions.h; sourceTree = "<group>"; };
 		EB081CD91696084400553730 /* TypeConversions.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = TypeConversions.idl; sourceTree = "<group>"; };
 		EBE5B224245A26EE003A5A88 /* SQLiteStatementAutoResetScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SQLiteStatementAutoResetScope.h; sourceTree = "<group>"; };
@@ -29334,6 +29340,10 @@
 				FD315FBA12B0267500C1A359 /* AudioContext.cpp */,
 				FD315FBB12B0267500C1A359 /* AudioContext.h */,
 				FD315FBC12B0267500C1A359 /* AudioContext.idl */,
+				E785D96024B7F7340014DB21 /* AudioContextLatencyCategory.h */,
+				E785D95E24B7F7270014DB21 /* AudioContextLatencyCategory.idl */,
+				E785D95F24B7F7340014DB21 /* AudioContextOptions.h */,
+				E785D95C24B7F7260014DB21 /* AudioContextOptions.idl */,
 				83BD3CED24998DF600BA3E67 /* AudioContextState.h */,
 				83BD3CEB24998CC500BA3E67 /* AudioContextState.idl */,
 				FD315FBD12B0267500C1A359 /* AudioDestinationNode.cpp */,
@@ -29854,6 +29864,8 @@
 				FD31607C12B026F700C1A359 /* AudioBus.h in Headers */,
 				FD31607E12B026F700C1A359 /* AudioChannel.h in Headers */,
 				FD31600512B0267600C1A359 /* AudioContext.h in Headers */,
+				E785D96224B7F7350014DB21 /* AudioContextLatencyCategory.h in Headers */,
+				E785D96124B7F7350014DB21 /* AudioContextOptions.h in Headers */,
 				83BD3CEE24998E0100BA3E67 /* AudioContextState.h in Headers */,
 				FD31607F12B026F700C1A359 /* AudioDestination.h in Headers */,
 				9B1229C423FE4BD2008CA751 /* AudioDestinationCocoa.h in Headers */,
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to