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);
}
void AudioWorkletGlobalScope::RegisterProcessor(JSContext* aCx,
const nsAString& aName,
VoidFunction& aProcessorCtor,
ErrorResult& aRv) {
void AudioWorkletGlobalScope::RegisterProcessor(
JSContext* aCx, const nsAString& aName,
AudioWorkletProcessorConstructor& aProcessorCtor, ErrorResult& aRv) {
JS::Rooted<JSObject*> processorConstructor(aCx,
aProcessorCtor.CallableOrNull());

View File

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

View File

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