mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-11 02:13:56 +09:00
WebAudio: Add stub for AudioDestinationNode.destination
This is called by https://athenacrisis.com/ and passed through to AudioNode.connect, which expects an AudioNode. Implement this function enough so that we return an AudioNode so that AudioNode.connect does not throw a TypeError.
This commit is contained in:
parent
5eb80b8697
commit
a51095f705
Notes:
github-actions[bot]
2024-07-24 09:15:48 +00:00
Author: https://github.com/shannonbooth
Commit: a51095f705
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/800
3 changed files with 26 additions and 1 deletions
|
@ -10,6 +10,7 @@
|
||||||
#include <LibWeb/HTML/EventNames.h>
|
#include <LibWeb/HTML/EventNames.h>
|
||||||
#include <LibWeb/WebAudio/AudioBuffer.h>
|
#include <LibWeb/WebAudio/AudioBuffer.h>
|
||||||
#include <LibWeb/WebAudio/AudioBufferSourceNode.h>
|
#include <LibWeb/WebAudio/AudioBufferSourceNode.h>
|
||||||
|
#include <LibWeb/WebAudio/AudioDestinationNode.h>
|
||||||
#include <LibWeb/WebAudio/BaseAudioContext.h>
|
#include <LibWeb/WebAudio/BaseAudioContext.h>
|
||||||
#include <LibWeb/WebAudio/BiquadFilterNode.h>
|
#include <LibWeb/WebAudio/BiquadFilterNode.h>
|
||||||
#include <LibWeb/WebAudio/DynamicsCompressorNode.h>
|
#include <LibWeb/WebAudio/DynamicsCompressorNode.h>
|
||||||
|
@ -32,6 +33,24 @@ void BaseAudioContext::initialize(JS::Realm& realm)
|
||||||
WEB_SET_PROTOTYPE_FOR_INTERFACE(BaseAudioContext);
|
WEB_SET_PROTOTYPE_FOR_INTERFACE(BaseAudioContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BaseAudioContext::visit_edges(Cell::Visitor& visitor)
|
||||||
|
{
|
||||||
|
Base::visit_edges(visitor);
|
||||||
|
visitor.visit(m_destination);
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-destination
|
||||||
|
JS::NonnullGCPtr<AudioDestinationNode> BaseAudioContext::destination()
|
||||||
|
{
|
||||||
|
auto& realm = this->realm();
|
||||||
|
|
||||||
|
dbgln("FIXME: Properly implement BaseAudioContext::destination");
|
||||||
|
|
||||||
|
if (!m_destination)
|
||||||
|
m_destination = realm.heap().allocate<AudioDestinationNode>(realm, realm, *this);
|
||||||
|
return *m_destination;
|
||||||
|
}
|
||||||
|
|
||||||
void BaseAudioContext::set_onstatechange(WebIDL::CallbackType* event_handler)
|
void BaseAudioContext::set_onstatechange(WebIDL::CallbackType* event_handler)
|
||||||
{
|
{
|
||||||
set_event_handler_attribute(HTML::EventNames::statechange, event_handler);
|
set_event_handler_attribute(HTML::EventNames::statechange, event_handler);
|
||||||
|
|
|
@ -55,17 +55,22 @@ public:
|
||||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<DynamicsCompressorNode>> create_dynamics_compressor();
|
WebIDL::ExceptionOr<JS::NonnullGCPtr<DynamicsCompressorNode>> create_dynamics_compressor();
|
||||||
JS::NonnullGCPtr<GainNode> create_gain();
|
JS::NonnullGCPtr<GainNode> create_gain();
|
||||||
|
|
||||||
|
JS::NonnullGCPtr<AudioDestinationNode> destination();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit BaseAudioContext(JS::Realm&, float m_sample_rate = 0);
|
explicit BaseAudioContext(JS::Realm&, float m_sample_rate = 0);
|
||||||
|
|
||||||
virtual void initialize(JS::Realm&) override;
|
virtual void initialize(JS::Realm&) override;
|
||||||
|
|
||||||
|
virtual void visit_edges(Cell::Visitor& visitor) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float m_sample_rate { 0 };
|
float m_sample_rate { 0 };
|
||||||
double m_current_time { 0 };
|
double m_current_time { 0 };
|
||||||
|
|
||||||
Bindings::AudioContextState m_control_thread_state = Bindings::AudioContextState::Suspended;
|
Bindings::AudioContextState m_control_thread_state = Bindings::AudioContextState::Suspended;
|
||||||
Bindings::AudioContextState m_rendering_thread_state = Bindings::AudioContextState::Suspended;
|
Bindings::AudioContextState m_rendering_thread_state = Bindings::AudioContextState::Suspended;
|
||||||
|
JS::GCPtr<AudioDestinationNode> m_destination;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#import <DOM/EventHandler.idl>
|
#import <DOM/EventHandler.idl>
|
||||||
#import <WebAudio/AudioBuffer.idl>
|
#import <WebAudio/AudioBuffer.idl>
|
||||||
#import <WebAudio/AudioBufferSourceNode.idl>
|
#import <WebAudio/AudioBufferSourceNode.idl>
|
||||||
|
#import <WebAudio/AudioDestinationNode.idl>
|
||||||
#import <WebAudio/DynamicsCompressorNode.idl>
|
#import <WebAudio/DynamicsCompressorNode.idl>
|
||||||
#import <WebAudio/GainNode.idl>
|
#import <WebAudio/GainNode.idl>
|
||||||
#import <WebAudio/OscillatorNode.idl>
|
#import <WebAudio/OscillatorNode.idl>
|
||||||
|
@ -16,7 +17,7 @@ enum AudioContextState { "suspended", "running", "closed" };
|
||||||
// https://webaudio.github.io/web-audio-api/#BaseAudioContext
|
// https://webaudio.github.io/web-audio-api/#BaseAudioContext
|
||||||
[Exposed=Window]
|
[Exposed=Window]
|
||||||
interface BaseAudioContext : EventTarget {
|
interface BaseAudioContext : EventTarget {
|
||||||
[FIXME] readonly attribute AudioDestinationNode destination;
|
readonly attribute AudioDestinationNode destination;
|
||||||
readonly attribute float sampleRate;
|
readonly attribute float sampleRate;
|
||||||
readonly attribute double currentTime;
|
readonly attribute double currentTime;
|
||||||
[FIXME] readonly attribute AudioListener listener;
|
[FIXME] readonly attribute AudioListener listener;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue