Bug 1542931 Add AudioWorkletProcessorConstructor r=bzbarsky

https://github.com/WebAudio/web-audio-api/issues/1839

Depends on D34476

Differential Revision: https://phabricator.services.mozilla.com/D34477

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Karl Tomlinson 2019-06-11 15:45:45 +00:00
parent f94d893bf3
commit 0d0c740557
3 changed files with 11 additions and 7 deletions

View File

@ -39,10 +39,9 @@ bool AudioWorkletGlobalScope::WrapGlobalObject(
aReflector); aReflector);
} }
void AudioWorkletGlobalScope::RegisterProcessor(JSContext* aCx, void AudioWorkletGlobalScope::RegisterProcessor(
const nsAString& aName, JSContext* aCx, const nsAString& aName,
VoidFunction& aProcessorCtor, AudioWorkletProcessorConstructor& aProcessorCtor, ErrorResult& aRv) {
ErrorResult& aRv) {
JS::Rooted<JSObject*> processorConstructor(aCx, JS::Rooted<JSObject*> processorConstructor(aCx,
aProcessorCtor.CallableOrNull()); aProcessorCtor.CallableOrNull());

View File

@ -18,6 +18,8 @@ class AudioWorkletImpl;
namespace dom { namespace dom {
class AudioWorkletProcessorConstructor;
class AudioWorkletGlobalScope final : public WorkletGlobalScope { class AudioWorkletGlobalScope final : public WorkletGlobalScope {
public: public:
NS_DECL_ISUPPORTS_INHERITED NS_DECL_ISUPPORTS_INHERITED
@ -30,7 +32,8 @@ class AudioWorkletGlobalScope final : public WorkletGlobalScope {
JS::MutableHandle<JSObject*> aReflector) override; JS::MutableHandle<JSObject*> aReflector) override;
void RegisterProcessor(JSContext* aCx, const nsAString& aName, void RegisterProcessor(JSContext* aCx, const nsAString& aName,
VoidFunction& aProcessorCtor, ErrorResult& aRv); AudioWorkletProcessorConstructor& aProcessorCtor,
ErrorResult& aRv);
WorkletImpl* Impl() const override; WorkletImpl* Impl() const override;
@ -56,7 +59,7 @@ class AudioWorkletGlobalScope final : public WorkletGlobalScope {
double mCurrentTime; double mCurrentTime;
float mSampleRate; float mSampleRate;
typedef nsRefPtrHashtable<nsStringHashKey, VoidFunction> typedef nsRefPtrHashtable<nsStringHashKey, AudioWorkletProcessorConstructor>
NodeNameToProcessorDefinitionMap; NodeNameToProcessorDefinitionMap;
NodeNameToProcessorDefinitionMap mNameToProcessorMap; NodeNameToProcessorDefinitionMap mNameToProcessorMap;
}; };

View File

@ -7,10 +7,12 @@
* https://webaudio.github.io/web-audio-api/#audioworkletglobalscope * https://webaudio.github.io/web-audio-api/#audioworkletglobalscope
*/ */
callback constructor AudioWorkletProcessorConstructor = AudioWorkletProcessor (object options);
[Global=(Worklet,AudioWorklet),Exposed=AudioWorklet] [Global=(Worklet,AudioWorklet),Exposed=AudioWorklet]
interface AudioWorkletGlobalScope : WorkletGlobalScope { interface AudioWorkletGlobalScope : WorkletGlobalScope {
[Throws] [Throws]
void registerProcessor (DOMString name, VoidFunction processorCtor); void registerProcessor (DOMString name, AudioWorkletProcessorConstructor processorCtor);
readonly attribute unsigned long long currentFrame; readonly attribute unsigned long long currentFrame;
readonly attribute double currentTime; readonly attribute double currentTime;
readonly attribute float sampleRate; readonly attribute float sampleRate;