/* * Copyright (c) 2024, Shannon Booth * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include 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> construct_impl(JS::Realm&, OfflineAudioContextOptions const&); static WebIDL::ExceptionOr> construct_impl(JS::Realm&, WebIDL::UnsignedLong number_of_channels, WebIDL::UnsignedLong length, float sample_rate); virtual ~OfflineAudioContext() override; WebIDL::ExceptionOr> start_rendering(); WebIDL::ExceptionOr> resume(); WebIDL::ExceptionOr> suspend(double suspend_time); WebIDL::UnsignedLong length() const; GC::Ptr oncomplete(); void set_oncomplete(GC::Ptr); private: OfflineAudioContext(JS::Realm&, WebIDL::UnsignedLong length, float sample_rate); virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; WebIDL::UnsignedLong m_length {}; }; }