| 
									
										
										
										
											2024-04-27 07:45:57 +12:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2024, Shannon Booth <shannon@serenityos.org> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <LibWeb/Bindings/OfflineAudioContextPrototype.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); | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |     GC_DECLARE_ALLOCATOR(OfflineAudioContext); | 
					
						
							| 
									
										
										
										
											2024-04-27 07:45:57 +12:00
										 |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |     static WebIDL::ExceptionOr<GC::Ref<OfflineAudioContext>> construct_impl(JS::Realm&, OfflineAudioContextOptions const&); | 
					
						
							|  |  |  |     static WebIDL::ExceptionOr<GC::Ref<OfflineAudioContext>> construct_impl(JS::Realm&, | 
					
						
							| 
									
										
										
										
											2024-04-27 07:45:57 +12:00
										 |  |  |         WebIDL::UnsignedLong number_of_channels, WebIDL::UnsignedLong length, float sample_rate); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     virtual ~OfflineAudioContext() override; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |     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); | 
					
						
							| 
									
										
										
										
											2024-04-27 07:45:57 +12:00
										 |  |  | 
 | 
					
						
							|  |  |  |     WebIDL::UnsignedLong length() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |     GC::Ptr<WebIDL::CallbackType> oncomplete(); | 
					
						
							|  |  |  |     void set_oncomplete(GC::Ptr<WebIDL::CallbackType>); | 
					
						
							| 
									
										
										
										
											2024-04-27 07:45:57 +12:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2025-01-07 23:24:10 +00:00
										 |  |  |     OfflineAudioContext(JS::Realm&, WebIDL::UnsignedLong length, float sample_rate); | 
					
						
							| 
									
										
										
										
											2024-04-27 07:45:57 +12:00
										 |  |  | 
 | 
					
						
							|  |  |  |     virtual void initialize(JS::Realm&) override; | 
					
						
							|  |  |  |     virtual void visit_edges(Cell::Visitor&) override; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     WebIDL::UnsignedLong m_length {}; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |