@@ -288,28 +288,112 @@ pub trait AudioNode {
288288 dest
289289 }
290290
291+ /// Disconnects all outgoing connections from the AudioNode.
292+ fn disconnect ( & self ) {
293+ self . context ( )
294+ . disconnect ( self . registration ( ) . id ( ) , None , None , None ) ;
295+ }
296+
291297 /// Disconnects all outputs of the AudioNode that go to a specific destination AudioNode.
292- fn disconnect_from < ' a > ( & self , dest : & ' a dyn AudioNode ) -> & ' a dyn AudioNode {
298+ ///
299+ /// # Panics
300+ ///
301+ /// This function will panic when
302+ /// - the AudioContext of the source and destination does not match
303+ /// - the source node was not connected to the destination node
304+ fn disconnect_dest ( & self , dest : & dyn AudioNode ) {
293305 assert ! (
294306 self . context( ) == dest. context( ) ,
295307 "InvalidAccessError - Attempting to disconnect nodes from different contexts"
296308 ) ;
297309
298- self . context ( )
299- . disconnect_from ( self . registration ( ) . id ( ) , dest. registration ( ) . id ( ) ) ;
310+ self . context ( ) . disconnect (
311+ self . registration ( ) . id ( ) ,
312+ None ,
313+ Some ( dest. registration ( ) . id ( ) ) ,
314+ None ,
315+ ) ;
316+ }
300317
301- dest
318+ /// Disconnects all outgoing connections at the given output port from the AudioNode.
319+ ///
320+ /// # Panics
321+ ///
322+ /// This function will panic when
323+ /// - if the output port is out of bounds for this node
324+ fn disconnect_output ( & self , output : usize ) {
325+ assert ! (
326+ self . number_of_outputs( ) > output,
327+ "IndexSizeError - output port {} is out of bounds" ,
328+ output
329+ ) ;
330+
331+ self . context ( )
332+ . disconnect ( self . registration ( ) . id ( ) , Some ( output) , None , None ) ;
302333 }
303334
304- /// Disconnects all outgoing connections from the AudioNode.
305- fn disconnect ( & self ) {
306- self . context ( ) . disconnect ( self . registration ( ) . id ( ) ) ;
335+ /// Disconnects a specific output of the AudioNode to a specific destination AudioNode
336+ ///
337+ /// # Panics
338+ ///
339+ /// This function will panic when
340+ /// - the AudioContext of the source and destination does not match
341+ /// - if the output port is out of bounds for the source node
342+ /// - the source node was not connected to the destination node
343+ fn disconnect_dest_output ( & self , dest : & dyn AudioNode , output : usize ) {
344+ assert ! (
345+ self . context( ) == dest. context( ) ,
346+ "InvalidAccessError - Attempting to disconnect nodes from different contexts"
347+ ) ;
348+
349+ assert ! (
350+ self . number_of_outputs( ) > output,
351+ "IndexSizeError - output port {} is out of bounds" ,
352+ output
353+ ) ;
354+
355+ self . context ( ) . disconnect (
356+ self . registration ( ) . id ( ) ,
357+ Some ( output) ,
358+ Some ( dest. registration ( ) . id ( ) ) ,
359+ None ,
360+ ) ;
307361 }
308362
309- /// Disconnects all outgoing connections at the given output port from the AudioNode.
310- fn disconnect_at ( & self , output : usize ) {
311- self . context ( )
312- . disconnect_at ( self . registration ( ) . id ( ) , output) ;
363+ /// Disconnects a specific output of the AudioNode to a specific input of some destination
364+ /// AudioNode
365+ ///
366+ /// # Panics
367+ ///
368+ /// This function will panic when
369+ /// - the AudioContext of the source and destination does not match
370+ /// - if the input port is out of bounds for the destination node
371+ /// - if the output port is out of bounds for the source node
372+ /// - the source node was not connected to the destination node
373+ fn disconnect_dest_output_input ( & self , dest : & dyn AudioNode , output : usize , input : usize ) {
374+ assert ! (
375+ self . context( ) == dest. context( ) ,
376+ "InvalidAccessError - Attempting to disconnect nodes from different contexts"
377+ ) ;
378+
379+ assert ! (
380+ self . number_of_outputs( ) > output,
381+ "IndexSizeError - output port {} is out of bounds" ,
382+ output
383+ ) ;
384+
385+ assert ! (
386+ dest. number_of_inputs( ) > input,
387+ "IndexSizeError - input port {} is out of bounds" ,
388+ input
389+ ) ;
390+
391+ self . context ( ) . disconnect (
392+ self . registration ( ) . id ( ) ,
393+ Some ( output) ,
394+ Some ( dest. registration ( ) . id ( ) ) ,
395+ Some ( input) ,
396+ ) ;
313397 }
314398
315399 /// The number of inputs feeding into the AudioNode. For source nodes, this will be 0.
0 commit comments