mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
Previously, the LibWeb bindings generator would output multiple per interface files like Prototype/Constructor/Namespace/GlobalMixin depending on the contents of that IDL file. This complicates the build system as it means that it does not know what files will be generated without knowledge of the contents of that IDL file. Instead, for each IDL file only generate a single Bindings/<IDLFile>.h and Bindings/<IDLFile>.cpp.
64 lines
2.0 KiB
C++
64 lines
2.0 KiB
C++
/*
|
|
* Copyright (c) 2024, Shannon Booth <shannon@serenityos.org>
|
|
* Copyright (c) 2025, Ben Eidson <b.e.eidson@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibWeb/Bindings/OfflineAudioContext.h>
|
|
#include <LibWeb/HighResolutionTime/DOMHighResTimeStamp.h>
|
|
#include <LibWeb/WebAudio/BaseAudioContext.h>
|
|
#include <LibWeb/WebIDL/Types.h>
|
|
|
|
namespace Web::WebAudio {
|
|
|
|
// https://webaudio.github.io/web-audio-api/#OfflineAudioContextOptions
|
|
struct OfflineAudioContextOptions {
|
|
WebIDL::UnsignedLong number_of_channels { 1 };
|
|
WebIDL::UnsignedLong length {};
|
|
float sample_rate {};
|
|
};
|
|
|
|
// https://webaudio.github.io/web-audio-api/#OfflineAudioContext
|
|
class OfflineAudioContext final : public BaseAudioContext {
|
|
WEB_PLATFORM_OBJECT(OfflineAudioContext, BaseAudioContext);
|
|
GC_DECLARE_ALLOCATOR(OfflineAudioContext);
|
|
|
|
public:
|
|
static WebIDL::ExceptionOr<GC::Ref<OfflineAudioContext>> construct_impl(JS::Realm&, OfflineAudioContextOptions const&);
|
|
static WebIDL::ExceptionOr<GC::Ref<OfflineAudioContext>> construct_impl(
|
|
JS::Realm&,
|
|
WebIDL::UnsignedLong number_of_channels,
|
|
WebIDL::UnsignedLong length,
|
|
float sample_rate);
|
|
|
|
virtual ~OfflineAudioContext() override;
|
|
|
|
WebIDL::ExceptionOr<GC::Ref<WebIDL::Promise>> start_rendering();
|
|
WebIDL::ExceptionOr<GC::Ref<WebIDL::Promise>> resume();
|
|
WebIDL::ExceptionOr<GC::Ref<WebIDL::Promise>> suspend(double suspend_time);
|
|
|
|
WebIDL::UnsignedLong length() const;
|
|
|
|
GC::Ptr<WebIDL::CallbackType> oncomplete();
|
|
void set_oncomplete(GC::Ptr<WebIDL::CallbackType>);
|
|
|
|
private:
|
|
OfflineAudioContext(JS::Realm&, WebIDL::UnsignedLong number_of_channels, WebIDL::UnsignedLong length, float sample_rate);
|
|
|
|
virtual void initialize(JS::Realm&) override;
|
|
virtual void visit_edges(Cell::Visitor&) override;
|
|
|
|
WebIDL::UnsignedLong m_length {};
|
|
WebIDL::UnsignedLong m_number_of_channels {};
|
|
bool m_rendering_started { false };
|
|
|
|
GC::Ptr<AudioBuffer> m_rendered_buffer;
|
|
|
|
void begin_offline_rendering(GC::Ref<WebIDL::Promise> promise);
|
|
};
|
|
|
|
}
|