2024-04-28 13:17:44 +12:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								/*
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  Copyright  ( c )  2024 ,  Shannon  Booth  < shannon @ serenityos . org > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  SPDX - License - Identifier :  BSD - 2 - Clause 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  <LibWeb/Bindings/AudioScheduledSourceNodePrototype.h> 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  <LibWeb/Bindings/Intrinsics.h> 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  <LibWeb/HTML/EventNames.h> 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  <LibWeb/WebAudio/AudioScheduledSourceNode.h> 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								namespace  Web : : WebAudio  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								GC_DEFINE_ALLOCATOR ( AudioScheduledSourceNode ) ;  
						 
					
						
							
								
									
										
										
										
											2024-04-28 13:17:44 +12:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								AudioScheduledSourceNode : : AudioScheduledSourceNode ( JS : : Realm &  realm ,  GC : : Ref < BaseAudioContext >  context )  
						 
					
						
							
								
									
										
										
										
											2024-04-29 20:03:15 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    :  AudioNode ( realm ,  context ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-04-28 13:17:44 +12:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								AudioScheduledSourceNode : : ~ AudioScheduledSourceNode ( )  =  default ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// https://webaudio.github.io/web-audio-api/#dom-audioscheduledsourcenode-onended
  
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								GC : : Ptr < WebIDL : : CallbackType >  AudioScheduledSourceNode : : onended ( )  
						 
					
						
							
								
									
										
										
										
											2024-04-28 13:17:44 +12:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  event_handler_attribute ( HTML : : EventNames : : ended ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// https://webaudio.github.io/web-audio-api/#dom-audioscheduledsourcenode-onended
  
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  AudioScheduledSourceNode : : set_onended ( GC : : Ptr < WebIDL : : CallbackType >  value )  
						 
					
						
							
								
									
										
										
										
											2024-04-28 13:17:44 +12:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    set_event_handler_attribute ( HTML : : EventNames : : ended ,  value ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// https://webaudio.github.io/web-audio-api/#dom-audioscheduledsourcenode-start
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								WebIDL : : ExceptionOr < void >  AudioScheduledSourceNode : : start ( double  when )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2025-01-09 23:47:30 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    // 1. If this AudioScheduledSourceNode internal slot [[source started]] is true, an InvalidStateError exception MUST be thrown.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( source_started ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 19:31:52 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  WebIDL : : InvalidStateError : : create ( realm ( ) ,  " AudioScheduledSourceNode source has already started " _utf16 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-09 23:47:30 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 2. Check for any errors that must be thrown due to parameter constraints described below. If any exception is thrown during this step, abort those steps.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // A RangeError exception MUST be thrown if when is negative.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( when  <  0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  WebIDL : : SimpleException  {  WebIDL : : SimpleExceptionType : : RangeError ,  " when must not be negative " sv  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 3. Set the internal slot [[source started]] on this AudioScheduledSourceNode to true.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    set_source_started ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // FIXME: 4. Queue a control message to start the AudioScheduledSourceNode, including the parameter values in the message.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // FIXME: 5. Send a control message to the associated AudioContext to start running its rendering thread only when all the following conditions are met:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-05-26 14:28:37 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    dbgln ( " FIXME: Implement AudioScheduledSourceNode::start " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-28 13:17:44 +12:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// https://webaudio.github.io/web-audio-api/#dom-audioscheduledsourcenode-stop
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								WebIDL : : ExceptionOr < void >  AudioScheduledSourceNode : : stop ( double  when )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2025-01-09 23:47:30 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    // 1. If this AudioScheduledSourceNode internal slot [[source started]] is not true, an InvalidStateError exception MUST be thrown.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( ! m_source_started ) 
							 
						 
					
						
							
								
									
										
										
										
											2025-08-07 19:31:52 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  WebIDL : : InvalidStateError : : create ( realm ( ) ,  " AudioScheduledSourceNode source has not been started " _utf16 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-09 23:47:30 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 2. Check for any errors that must be thrown due to parameter constraints described below.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // A RangeError exception MUST be thrown if when is negative.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( when  <  0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  WebIDL : : SimpleException  {  WebIDL : : SimpleExceptionType : : RangeError ,  " when must not be negative " sv  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // FIXME: 3. Queue a control message to stop the AudioScheduledSourceNode, including the parameter values in the message.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-05-26 14:28:37 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    dbgln ( " FIXME: Implement AudioScheduledSourceNode::stop " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-28 13:17:44 +12:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  AudioScheduledSourceNode : : initialize ( JS : : Realm &  realm )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    WEB_SET_PROTOTYPE_FOR_INTERFACE ( AudioScheduledSourceNode ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-20 16:22:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    Base : : initialize ( realm ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-28 13:17:44 +12:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  AudioScheduledSourceNode : : visit_edges ( Cell : : Visitor &  visitor )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    Base : : visit_edges ( visitor ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}