Title: [265352] trunk
Revision
265352
Author
cdu...@apple.com
Date
2020-08-06 16:39:31 -0700 (Thu, 06 Aug 2020)

Log Message

BaseAudioContext.decodeAudioData() should return a Promise
https://bugs.webkit.org/show_bug.cgi?id=215242

Reviewed by Eric Carlson.

LayoutTests/imported/w3c:

Rebaseline tests that are now passing.

* web-platform-tests/webaudio/idlharness.https.window-expected.txt:
* web-platform-tests/webaudio/the-audio-api/the-audiobuffersourcenode-interface/audiobuffersource-multi-channels-expected.txt:
* web-platform-tests/webaudio/the-audio-api/the-audiocontext-interface/audiocontext-detached-execution-context.tentative-expected.txt:

Source/WebCore:

BaseAudioContext.decodeAudioData() should return a Promise as per:
- https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-decodeaudiodata

Behavior is unchanged for prefixed WebKitAudioContext.decodeAudioData() to ensure
backward compatibility.

No new tests, rebaselined existing tests.

* Modules/webaudio/AsyncAudioDecoder.cpp:
(WebCore::AsyncAudioDecoder::decodeAsync):
(WebCore::AsyncAudioDecoder::DecodingTask::DecodingTask):
(WebCore::AsyncAudioDecoder::DecodingTask::notifyComplete):
* Modules/webaudio/AsyncAudioDecoder.h:
* Modules/webaudio/BaseAudioContext.cpp:
(WebCore::BaseAudioContext::decodeAudioData):
* Modules/webaudio/BaseAudioContext.h:
* Modules/webaudio/BaseAudioContext.idl:
* Modules/webaudio/WebKitAudioContext.idl:

LayoutTests:

Unskip test that is no longer timing out.

* TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (265351 => 265352)


--- trunk/LayoutTests/ChangeLog	2020-08-06 23:24:39 UTC (rev 265351)
+++ trunk/LayoutTests/ChangeLog	2020-08-06 23:39:31 UTC (rev 265352)
@@ -1,3 +1,14 @@
+2020-08-06  Chris Dumez  <cdu...@apple.com>
+
+        BaseAudioContext.decodeAudioData() should return a Promise
+        https://bugs.webkit.org/show_bug.cgi?id=215242
+
+        Reviewed by Eric Carlson.
+
+        Unskip test that is no longer timing out.
+
+        * TestExpectations:
+
 2020-08-06  Hector Lopez  <hector_i_lo...@apple.com>
 
         [ macOS wk 2 Release ] imported/w3c/web-platform-tests/content-security-policy/worker-src/service-worker-src-child-fallback.https.sub.html  is a flaky failure

Modified: trunk/LayoutTests/TestExpectations (265351 => 265352)


--- trunk/LayoutTests/TestExpectations	2020-08-06 23:24:39 UTC (rev 265351)
+++ trunk/LayoutTests/TestExpectations	2020-08-06 23:39:31 UTC (rev 265352)
@@ -307,7 +307,6 @@
 
 # Skip WPT webaudio tests that are timing out.
 imported/w3c/web-platform-tests/webaudio/the-audio-api/the-analysernode-interface/test-analyser-output.html [ Skip ]
-imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audiobuffersourcenode-interface/audiobuffersource-multi-channels.html [ Skip ]
 imported/w3c/web-platform-tests/webaudio/the-audio-api/the-mediastreamaudiosourcenode-interface/mediastreamaudiosourcenode-routing.html [ Skip ]
 
 # Test prints out sample rate, which appears to be hardware-specific.

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (265351 => 265352)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2020-08-06 23:24:39 UTC (rev 265351)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2020-08-06 23:39:31 UTC (rev 265352)
@@ -1,5 +1,18 @@
 2020-08-06  Chris Dumez  <cdu...@apple.com>
 
+        BaseAudioContext.decodeAudioData() should return a Promise
+        https://bugs.webkit.org/show_bug.cgi?id=215242
+
+        Reviewed by Eric Carlson.
+
+        Rebaseline tests that are now passing.
+
+        * web-platform-tests/webaudio/idlharness.https.window-expected.txt:
+        * web-platform-tests/webaudio/the-audio-api/the-audiobuffersourcenode-interface/audiobuffersource-multi-channels-expected.txt:
+        * web-platform-tests/webaudio/the-audio-api/the-audiocontext-interface/audiocontext-detached-execution-context.tentative-expected.txt:
+
+2020-08-06  Chris Dumez  <cdu...@apple.com>
+
         Drop non-standard createBuffer(ArrayBuffer, boolean) overload from AudioContext
         https://bugs.webkit.org/show_bug.cgi?id=215238
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/idlharness.https.window-expected.txt (265351 => 265352)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/idlharness.https.window-expected.txt	2020-08-06 23:24:39 UTC (rev 265351)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/idlharness.https.window-expected.txt	2020-08-06 23:39:31 UTC (rev 265352)
@@ -40,7 +40,7 @@
 PASS BaseAudioContext interface: operation createScriptProcessor(optional unsigned long, optional unsigned long, optional unsigned long) 
 FAIL BaseAudioContext interface: operation createStereoPanner() assert_own_property: interface prototype object missing non-static operation expected property "createStereoPanner" missing
 PASS BaseAudioContext interface: operation createWaveShaper() 
-FAIL BaseAudioContext interface: operation decodeAudioData(ArrayBuffer, optional DecodeSuccessCallback?, optional DecodeErrorCallback?) assert_equals: property has wrong .length expected 1 but got 2
+PASS BaseAudioContext interface: operation decodeAudioData(ArrayBuffer, optional DecodeSuccessCallback?, optional DecodeErrorCallback?) 
 PASS AudioContext interface: existence and properties of interface object 
 PASS AudioContext interface object length 
 PASS AudioContext interface object name 
@@ -105,7 +105,7 @@
 FAIL BaseAudioContext interface: context must inherit property "createStereoPanner()" with the proper type assert_inherits: property "createStereoPanner" not found in prototype chain
 PASS BaseAudioContext interface: context must inherit property "createWaveShaper()" with the proper type 
 PASS BaseAudioContext interface: context must inherit property "decodeAudioData(ArrayBuffer, optional DecodeSuccessCallback?, optional DecodeErrorCallback?)" with the proper type 
-FAIL BaseAudioContext interface: calling decodeAudioData(ArrayBuffer, optional DecodeSuccessCallback?, optional DecodeErrorCallback?) on context with too few arguments must throw TypeError assert_unreached: Throws "TypeError: Not enough arguments" instead of rejecting promise Reached unreachable code
+PASS BaseAudioContext interface: calling decodeAudioData(ArrayBuffer, optional DecodeSuccessCallback?, optional DecodeErrorCallback?) on context with too few arguments must throw TypeError 
 PASS OfflineAudioContext interface: existence and properties of interface object 
 PASS OfflineAudioContext interface object length 
 PASS OfflineAudioContext interface object name 
@@ -158,7 +158,7 @@
 FAIL BaseAudioContext interface: new OfflineAudioContext(1, 1, sample_rate) must inherit property "createStereoPanner()" with the proper type assert_inherits: property "createStereoPanner" not found in prototype chain
 PASS BaseAudioContext interface: new OfflineAudioContext(1, 1, sample_rate) must inherit property "createWaveShaper()" with the proper type 
 PASS BaseAudioContext interface: new OfflineAudioContext(1, 1, sample_rate) must inherit property "decodeAudioData(ArrayBuffer, optional DecodeSuccessCallback?, optional DecodeErrorCallback?)" with the proper type 
-FAIL BaseAudioContext interface: calling decodeAudioData(ArrayBuffer, optional DecodeSuccessCallback?, optional DecodeErrorCallback?) on new OfflineAudioContext(1, 1, sample_rate) with too few arguments must throw TypeError assert_unreached: Throws "TypeError: Not enough arguments" instead of rejecting promise Reached unreachable code
+PASS BaseAudioContext interface: calling decodeAudioData(ArrayBuffer, optional DecodeSuccessCallback?, optional DecodeErrorCallback?) on new OfflineAudioContext(1, 1, sample_rate) with too few arguments must throw TypeError 
 PASS OfflineAudioCompletionEvent interface: existence and properties of interface object 
 PASS OfflineAudioCompletionEvent interface object length 
 PASS OfflineAudioCompletionEvent interface object name 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audiobuffersourcenode-interface/audiobuffersource-multi-channels-expected.txt (265351 => 265352)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audiobuffersourcenode-interface/audiobuffersource-multi-channels-expected.txt	2020-08-06 23:24:39 UTC (rev 265351)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audiobuffersourcenode-interface/audiobuffersource-multi-channels-expected.txt	2020-08-06 23:39:31 UTC (rev 265352)
@@ -1,11 +1,19 @@
 
-Harness Error (TIMEOUT), message = null
-
 PASS # AUDIT TASK RUNNER STARTED. 
-TIMEOUT Executing "initialize" Test timed out
-NOTRUN Executing "test" 
-NOTRUN Audit report 
+PASS Executing "initialize" 
+PASS Executing "test" 
+PASS Audit report 
 PASS > [initialize]  
 PASS   Creating context for testing did not throw an exception. 
-FAIL X Fetching expected audio rejected incorrectly with TypeError: Not enough arguments. Got Promise. assert_true: expected true got false
+PASS   Fetching expected audio resolved correctly. 
+PASS < [initialize] All assertions passed. (total 2 assertions) 
+PASS > [test] AudioBufferSource with 5.1 buffer 
+PASS   Rendered audio for channel 0 equals [0,0.0626220703125,0.125030517578125,0.18695068359375,0.24810791015625,0.308319091796875,0.3673095703125,0.42486572265625,0.480743408203125,0.53472900390625,0.58660888671875,0.636199951171875,0.68328857421875,0.727691650390625,0.76922607421875,0.8077392578125...] with an element-wise tolerance of {"absoluteThreshold":0.000030517578125,"relativeThreshold":0}. 
+PASS   Rendered audio for channel 1 equals [0,0.125030517578125,0.24810791015625,0.3673095703125,0.480743408203125,0.58660888671875,0.68328857421875,0.76922607421875,0.84307861328125,0.903717041015625,0.950164794921875,0.981689453125,0.997802734375,0.99822998046875,0.983001708984375,0.952362060546875...] with an element-wise tolerance of {"absoluteThreshold":0.000030517578125,"relativeThreshold":0}. 
+PASS   Rendered audio for channel 2 equals [0,0.18695068359375,0.3673095703125,0.53472900390625,0.68328857421875,0.8077392578125,0.903717041015625,0.96783447265625,0.997802734375,0.992584228515625,0.952362060546875,0.8785400390625,0.77374267578125,0.641693115234375,0.486968994140625,0.315093994140625...] with an element-wise tolerance of {"absoluteThreshold":0.000030517578125,"relativeThreshold":0}. 
+PASS   Rendered audio for channel 3 equals [0,0.24810791015625,0.480743408203125,0.68328857421875,0.84307861328125,0.950164794921875,0.997802734375,0.983001708984375,0.90673828125,0.77374267578125,0.592376708984375,0.373931884765625,0.132110595703125,-0.11798095703125,-0.3607177734375,-0.58087158203125...] with an element-wise tolerance of {"absoluteThreshold":0.000030517578125,"relativeThreshold":0}. 
+PASS   Rendered audio for channel 4 equals [0,0.308319091796875,0.58660888671875,0.8077392578125,0.950164794921875,0.999969482421875,0.952362060546875,0.811920166015625,0.592376708984375,0.315093994140625,0.007110595703125,-0.30157470703125,-0.58087158203125,-0.803558349609375,-0.94793701171875,-0.999969482421875...] with an element-wise tolerance of {"absoluteThreshold":0.000030517578125,"relativeThreshold":0}. 
+PASS   Rendered audio for channel 5 equals [0,0.3673095703125,0.68328857421875,0.903717041015625,0.997802734375,0.952362060546875,0.77374267578125,0.486968994140625,0.132110595703125,-0.241241455078125,-0.58087158203125,-0.839263916015625,-0.980316162109375,-0.98431396484375,-0.8507080078125,-0.598114013671875...] with an element-wise tolerance of {"absoluteThreshold":0.000030517578125,"relativeThreshold":0}. 
+PASS < [test] All assertions passed. (total 6 assertions) 
+PASS # AUDIT TASK RUNNER FINISHED: 2 tasks ran successfully. 
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audiocontext-interface/audiocontext-detached-execution-context.tentative-expected.txt (265351 => 265352)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audiocontext-interface/audiocontext-detached-execution-context.tentative-expected.txt	2020-08-06 23:24:39 UTC (rev 265351)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audiocontext-interface/audiocontext-detached-execution-context.tentative-expected.txt	2020-08-06 23:39:31 UTC (rev 265352)
@@ -1,7 +1,9 @@
 
 PASS # AUDIT TASK RUNNER STARTED. 
-FAIL Executing "decoding-on-detached-iframe" promise_test: Unhandled rejection with value: object "TypeError: Not enough arguments"
+PASS Executing "decoding-on-detached-iframe" 
 PASS Audit report 
 PASS > [decoding-on-detached-iframe]  
+PASS   decodeAudioData() upon a detached iframe rejected correctly with NotAllowedError. 
+PASS < [decoding-on-detached-iframe] All assertions passed. (total 1 assertions) 
 PASS # AUDIT TASK RUNNER FINISHED: 1 tasks ran successfully. 
 

Modified: trunk/Source/WebCore/ChangeLog (265351 => 265352)


--- trunk/Source/WebCore/ChangeLog	2020-08-06 23:24:39 UTC (rev 265351)
+++ trunk/Source/WebCore/ChangeLog	2020-08-06 23:39:31 UTC (rev 265352)
@@ -1,5 +1,31 @@
 2020-08-06  Chris Dumez  <cdu...@apple.com>
 
+        BaseAudioContext.decodeAudioData() should return a Promise
+        https://bugs.webkit.org/show_bug.cgi?id=215242
+
+        Reviewed by Eric Carlson.
+
+        BaseAudioContext.decodeAudioData() should return a Promise as per:
+        - https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-decodeaudiodata
+
+        Behavior is unchanged for prefixed WebKitAudioContext.decodeAudioData() to ensure
+        backward compatibility.
+
+        No new tests, rebaselined existing tests.
+
+        * Modules/webaudio/AsyncAudioDecoder.cpp:
+        (WebCore::AsyncAudioDecoder::decodeAsync):
+        (WebCore::AsyncAudioDecoder::DecodingTask::DecodingTask):
+        (WebCore::AsyncAudioDecoder::DecodingTask::notifyComplete):
+        * Modules/webaudio/AsyncAudioDecoder.h:
+        * Modules/webaudio/BaseAudioContext.cpp:
+        (WebCore::BaseAudioContext::decodeAudioData):
+        * Modules/webaudio/BaseAudioContext.h:
+        * Modules/webaudio/BaseAudioContext.idl:
+        * Modules/webaudio/WebKitAudioContext.idl:
+
+2020-08-06  Chris Dumez  <cdu...@apple.com>
+
         Drop non-standard createBuffer(ArrayBuffer, boolean) overload from AudioContext
         https://bugs.webkit.org/show_bug.cgi?id=215238
 

Modified: trunk/Source/WebCore/Modules/webaudio/AsyncAudioDecoder.cpp (265351 => 265352)


--- trunk/Source/WebCore/Modules/webaudio/AsyncAudioDecoder.cpp	2020-08-06 23:24:39 UTC (rev 265351)
+++ trunk/Source/WebCore/Modules/webaudio/AsyncAudioDecoder.cpp	2020-08-06 23:39:31 UTC (rev 265352)
@@ -52,11 +52,11 @@
     m_thread->waitForCompletion();
 }
 
-void AsyncAudioDecoder::decodeAsync(Ref<ArrayBuffer>&& audioData, float sampleRate, RefPtr<AudioBufferCallback>&& successCallback, RefPtr<AudioBufferCallback>&& errorCallback)
+void AsyncAudioDecoder::decodeAsync(Ref<ArrayBuffer>&& audioData, float sampleRate, Function<void(ExceptionOr<Ref<AudioBuffer>>&&)>&& callback)
 {
     ASSERT(isMainThread());
 
-    auto decodingTask = makeUnique<DecodingTask>(WTFMove(audioData), sampleRate, WTFMove(successCallback), WTFMove(errorCallback));
+    auto decodingTask = makeUnique<DecodingTask>(WTFMove(audioData), sampleRate, WTFMove(callback));
     m_queue.append(WTFMove(decodingTask)); // note that ownership of the task is effectively taken by the queue.
 }
 
@@ -77,11 +77,10 @@
     }
 }
 
-AsyncAudioDecoder::DecodingTask::DecodingTask(Ref<ArrayBuffer>&& audioData, float sampleRate, RefPtr<AudioBufferCallback>&& successCallback, RefPtr<AudioBufferCallback>&& errorCallback)
+AsyncAudioDecoder::DecodingTask::DecodingTask(Ref<ArrayBuffer>&& audioData, float sampleRate, Function<void(ExceptionOr<Ref<AudioBuffer>>&&)>&& callback)
     : m_audioData(WTFMove(audioData))
     , m_sampleRate(sampleRate)
-    , m_successCallback(WTFMove(successCallback))
-    , m_errorCallback(WTFMove(errorCallback))
+    , m_callback(WTFMove(callback))
 {
 }
 
@@ -98,10 +97,10 @@
 
 void AsyncAudioDecoder::DecodingTask::notifyComplete()
 {
-    if (audioBuffer() && successCallback())
-        successCallback()->handleEvent(audioBuffer());
-    else if (errorCallback())
-        errorCallback()->handleEvent(audioBuffer());
+    if (auto* audioBuffer = this->audioBuffer())
+        callback()(makeRef(*audioBuffer));
+    else
+        callback()(Exception { EncodingError, "Decoding failed"_s });
 
     // Our ownership was given up in AsyncAudioDecoder::runLoop()
     // Make sure to clean up here.

Modified: trunk/Source/WebCore/Modules/webaudio/AsyncAudioDecoder.h (265351 => 265352)


--- trunk/Source/WebCore/Modules/webaudio/AsyncAudioDecoder.h	2020-08-06 23:24:39 UTC (rev 265351)
+++ trunk/Source/WebCore/Modules/webaudio/AsyncAudioDecoder.h	2020-08-06 23:39:31 UTC (rev 265352)
@@ -24,6 +24,7 @@
 
 #pragma once
 
+#include "ExceptionOr.h"
 #include <memory>
 #include <wtf/Forward.h>
 #include <wtf/MessageQueue.h>
@@ -50,7 +51,7 @@
     ~AsyncAudioDecoder();
 
     // Must be called on the main thread.
-    void decodeAsync(Ref<JSC::ArrayBuffer>&& audioData, float sampleRate, RefPtr<AudioBufferCallback>&& successCallback, RefPtr<AudioBufferCallback>&& errorCallback);
+    void decodeAsync(Ref<JSC::ArrayBuffer>&& audioData, float sampleRate, Function<void(ExceptionOr<Ref<AudioBuffer>>&&)>&&);
 
 private:
     class DecodingTask {
@@ -57,14 +58,13 @@
         WTF_MAKE_NONCOPYABLE(DecodingTask);
         WTF_MAKE_FAST_ALLOCATED;
     public:
-        DecodingTask(Ref<JSC::ArrayBuffer>&& audioData, float sampleRate, RefPtr<AudioBufferCallback>&& successCallback, RefPtr<AudioBufferCallback>&& errorCallback);
+        DecodingTask(Ref<JSC::ArrayBuffer>&& audioData, float sampleRate, Function<void(ExceptionOr<Ref<AudioBuffer>>&&)>&& callback);
         void decode();
         
     private:
         JSC::ArrayBuffer& audioData() { return m_audioData; }
         float sampleRate() const { return m_sampleRate; }
-        AudioBufferCallback* successCallback() { return m_successCallback.get(); }
-        AudioBufferCallback* errorCallback() { return m_errorCallback.get(); }
+        Function<void(ExceptionOr<Ref<AudioBuffer>>&&)>& callback() { return m_callback; }
         AudioBuffer* audioBuffer() { return m_audioBuffer.get(); }
 
         void notifyComplete();
@@ -71,8 +71,7 @@
 
         Ref<JSC::ArrayBuffer> m_audioData;
         float m_sampleRate;
-        RefPtr<AudioBufferCallback> m_successCallback;
-        RefPtr<AudioBufferCallback> m_errorCallback;
+        Function<void(ExceptionOr<Ref<AudioBuffer>>&&)> m_callback;
         RefPtr<AudioBuffer> m_audioBuffer;
     };
     

Modified: trunk/Source/WebCore/Modules/webaudio/BaseAudioContext.cpp (265351 => 265352)


--- trunk/Source/WebCore/Modules/webaudio/BaseAudioContext.cpp	2020-08-06 23:24:39 UTC (rev 265351)
+++ trunk/Source/WebCore/Modules/webaudio/BaseAudioContext.cpp	2020-08-06 23:39:31 UTC (rev 265352)
@@ -58,6 +58,7 @@
 #include "GenericEventQueue.h"
 #include "HRTFDatabaseLoader.h"
 #include "HRTFPanner.h"
+#include "JSAudioBuffer.h"
 #include "JSDOMPromiseDeferred.h"
 #include "Logging.h"
 #include "NetworkingContext.h"
@@ -391,11 +392,32 @@
     return AudioBuffer::create(AudioBufferOptions {numberOfChannels, length, sampleRate});
 }
 
-void BaseAudioContext::decodeAudioData(Ref<ArrayBuffer>&& audioData, RefPtr<AudioBufferCallback>&& successCallback, RefPtr<AudioBufferCallback>&& errorCallback)
+void BaseAudioContext::decodeAudioData(Ref<ArrayBuffer>&& audioData, RefPtr<AudioBufferCallback>&& successCallback, RefPtr<AudioBufferCallback>&& errorCallback, Optional<Ref<DeferredPromise>>&& promise)
 {
+    if (promise && (!document() || !document()->isFullyActive())) {
+        promise.value()->reject(Exception { NotAllowedError, "Document is not fully active"_s });
+        return;
+    }
+
     if (!m_audioDecoder)
         m_audioDecoder = makeUnique<AsyncAudioDecoder>();
-    m_audioDecoder->decodeAsync(WTFMove(audioData), sampleRate(), WTFMove(successCallback), WTFMove(errorCallback));
+
+    m_audioDecoder->decodeAsync(WTFMove(audioData), sampleRate(), [this, activity = ActiveDOMObject::makePendingActivity(*this), successCallback = WTFMove(successCallback), errorCallback = WTFMove(errorCallback), promise = WTFMove(promise)](ExceptionOr<Ref<AudioBuffer>>&& result) mutable {
+        queueTaskKeepingObjectAlive(*this, TaskSource::InternalAsyncTask, [successCallback = WTFMove(successCallback), errorCallback = WTFMove(errorCallback), promise = WTFMove(promise), result = WTFMove(result)]() mutable {
+            if (result.hasException()) {
+                if (promise)
+                    promise.value()->reject(result.releaseException());
+                if (errorCallback)
+                    errorCallback->handleEvent(nullptr);
+                return;
+            }
+            auto audioBuffer = result.releaseReturnValue();
+            if (promise)
+                promise.value()->resolve<IDLInterface<AudioBuffer>>(audioBuffer.get());
+            if (successCallback)
+                successCallback->handleEvent(audioBuffer.ptr());
+        });
+    });
 }
 
 AudioListener& WebCore::BaseAudioContext::listener()

Modified: trunk/Source/WebCore/Modules/webaudio/BaseAudioContext.h (265351 => 265352)


--- trunk/Source/WebCore/Modules/webaudio/BaseAudioContext.h	2020-08-06 23:24:39 UTC (rev 265351)
+++ trunk/Source/WebCore/Modules/webaudio/BaseAudioContext.h	2020-08-06 23:39:31 UTC (rev 265352)
@@ -32,6 +32,7 @@
 #include "AudioContextState.h"
 #include "AudioDestinationNode.h"
 #include "EventTarget.h"
+#include "JSDOMPromiseDeferred.h"
 #include "MediaCanStartListener.h"
 #include "MediaProducer.h"
 #include "PeriodicWaveConstraints.h"
@@ -125,7 +126,7 @@
     ExceptionOr<Ref<AudioBuffer>> createBuffer(unsigned numberOfChannels, unsigned length, float sampleRate);
 
     // Asynchronous audio file data decoding.
-    void decodeAudioData(Ref<ArrayBuffer>&&, RefPtr<AudioBufferCallback>&&, RefPtr<AudioBufferCallback>&&);
+    void decodeAudioData(Ref<ArrayBuffer>&&, RefPtr<AudioBufferCallback>&&, RefPtr<AudioBufferCallback>&&, Optional<Ref<DeferredPromise>>&& = WTF::nullopt);
 
     AudioListener& listener();
 

Modified: trunk/Source/WebCore/Modules/webaudio/BaseAudioContext.idl (265351 => 265352)


--- trunk/Source/WebCore/Modules/webaudio/BaseAudioContext.idl	2020-08-06 23:24:39 UTC (rev 265351)
+++ trunk/Source/WebCore/Modules/webaudio/BaseAudioContext.idl	2020-08-06 23:39:31 UTC (rev 265352)
@@ -47,8 +47,7 @@
     [MayThrowException] AudioBuffer createBuffer(unsigned long numberOfChannels, unsigned long numberOfFrames, float sampleRate);
 
     // Asynchronous audio file data decoding.
-    // FIXME: successCallback should be optional and the callbacks should not be nullable. This should also return a Promise.
-    void decodeAudioData(ArrayBuffer audioData, AudioBufferCallback? successCallback, optional AudioBufferCallback? errorCallback);
+    Promise<AudioBuffer> decodeAudioData(ArrayBuffer audioData, optional AudioBufferCallback? successCallback, optional AudioBufferCallback? errorCallback);
 
     // Sources
     [MayThrowException] AudioBufferSourceNode createBufferSource();

Modified: trunk/Source/WebCore/Modules/webaudio/WebKitAudioContext.idl (265351 => 265352)


--- trunk/Source/WebCore/Modules/webaudio/WebKitAudioContext.idl	2020-08-06 23:24:39 UTC (rev 265351)
+++ trunk/Source/WebCore/Modules/webaudio/WebKitAudioContext.idl	2020-08-06 23:39:31 UTC (rev 265352)
@@ -58,7 +58,6 @@
     [MayThrowException, ImplementedAs=createLegacyBuffer] AudioBuffer createBuffer(ArrayBuffer buffer, boolean mixToMono);
 
     // Asynchronous audio file data decoding.
-    // FIXME: successCallback should be optional and the callbacks should not be nullable. This should also return a Promise.
     void decodeAudioData(ArrayBuffer audioData, AudioBufferCallback? successCallback, optional AudioBufferCallback? errorCallback);
 
     // Sources
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to