Pārlūkot izejas kodu

LibWeb: Pass through sample rate in OfflineAudioContext constructor

I can't actually spot in the spec where it explicitly says to pass this
through (unlike the AudioContext constructor) - but clearly this needs
to be passed through for an OfflineAudioContext to actually have a
sample rate!
Shannon Booth 1 gadu atpakaļ
vecāks
revīzija
5f57596520

+ 2 - 1
Userland/Libraries/LibWeb/WebAudio/BaseAudioContext.cpp

@@ -13,8 +13,9 @@
 
 namespace Web::WebAudio {
 
-BaseAudioContext::BaseAudioContext(JS::Realm& realm)
+BaseAudioContext::BaseAudioContext(JS::Realm& realm, float sample_rate)
     : DOM::EventTarget(realm)
+    , m_sample_rate(sample_rate)
 {
 }
 

+ 1 - 1
Userland/Libraries/LibWeb/WebAudio/BaseAudioContext.h

@@ -50,7 +50,7 @@ public:
     WebIDL::ExceptionOr<JS::NonnullGCPtr<OscillatorNode>> create_oscillator();
 
 protected:
-    explicit BaseAudioContext(JS::Realm&);
+    explicit BaseAudioContext(JS::Realm&, float m_sample_rate = 0);
 
     virtual void initialize(JS::Realm&) override;
 

+ 1 - 2
Userland/Libraries/LibWeb/WebAudio/OfflineAudioContext.cpp

@@ -73,11 +73,10 @@ OfflineAudioContext::OfflineAudioContext(JS::Realm& realm, OfflineAudioContextOp
 }
 
 OfflineAudioContext::OfflineAudioContext(JS::Realm& realm, WebIDL::UnsignedLong number_of_channels, WebIDL::UnsignedLong length, float sample_rate)
-    : BaseAudioContext(realm)
+    : BaseAudioContext(realm, sample_rate)
     , m_length(length)
 {
     (void)number_of_channels;
-    (void)sample_rate;
 }
 
 void OfflineAudioContext::initialize(JS::Realm& realm)