1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 07:37:35 +00:00

LibWeb: Start filling out BaseAudioContext/AudioContext interfaces

- Fills out both IDLs and implements some basic attributes/methods.
- No actual audio processing yet though :^)
This commit is contained in:
Daniel Adams 2023-06-27 13:34:51 -04:00 committed by Andreas Kling
parent 30e67721ae
commit 49e6414c58
8 changed files with 407 additions and 8 deletions

View file

@ -6,6 +6,7 @@
#pragma once
#include <LibWeb/Bindings/BaseAudioContextPrototype.h>
#include <LibWeb/DOM/EventTarget.h>
namespace Web::WebAudio {
@ -17,10 +18,28 @@ class BaseAudioContext : public DOM::EventTarget {
public:
virtual ~BaseAudioContext() override;
float sample_rate() const { return m_sample_rate; };
double current_time() const { return m_current_time; };
Bindings::AudioContextState state() const { return m_control_thread_state; };
void set_onstatechange(WebIDL::CallbackType*);
WebIDL::CallbackType* onstatechange();
void set_sample_rate(float sample_rate) { m_sample_rate = sample_rate; };
void set_control_state(Bindings::AudioContextState state) { m_control_thread_state = state; };
void set_rendering_state(Bindings::AudioContextState state) { m_rendering_thread_state = state; };
protected:
explicit BaseAudioContext(JS::Realm&);
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
private:
float m_sample_rate { 0 };
double m_current_time { 0 };
Bindings::AudioContextState m_control_thread_state = Bindings::AudioContextState::Suspended;
Bindings::AudioContextState m_rendering_thread_state = Bindings::AudioContextState::Suspended;
};
}