File tree Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -354,7 +354,7 @@ impl Graph {
354
354
}
355
355
356
356
/// Render a single audio quantum by traversing the node list
357
- pub fn render ( & mut self , scope : & RenderScope ) -> AudioRenderQuantum {
357
+ pub fn render ( & mut self , scope : & RenderScope ) -> & AudioRenderQuantum {
358
358
// if the audio graph was changed, determine the new ordering
359
359
if self . ordered . is_empty ( ) {
360
360
self . order_nodes ( ) ;
@@ -460,12 +460,12 @@ impl Graph {
460
460
}
461
461
462
462
// Return the output buffer of destination node
463
- self . nodes
463
+ & self
464
+ . nodes
464
465
. get_mut ( & AudioNodeId ( 0 ) )
465
466
. unwrap ( )
466
467
. get_mut ( )
467
468
. outputs [ 0 ]
468
- . clone ( )
469
469
}
470
470
}
471
471
Original file line number Diff line number Diff line change 1
1
//! Communicates with the control thread and ships audio samples to the hardware
2
2
3
+ use std:: borrow:: Cow ;
3
4
use std:: cell:: Cell ;
4
5
use std:: sync:: atomic:: { AtomicU64 , Ordering } ;
5
6
use std:: sync:: Arc ;
@@ -257,12 +258,14 @@ impl RenderThread {
257
258
node_id : Cell :: new ( AudioNodeId ( 0 ) ) , // placeholder value
258
259
} ;
259
260
260
- // render audio graph
261
- let mut rendered = self . graph . as_mut ( ) . unwrap ( ) . render ( & scope) ;
261
+ // render audio graph, and use a Cow in case we need to mutate/store the value later
262
+ let mut rendered = Cow :: Borrowed ( self . graph . as_mut ( ) . unwrap ( ) . render ( & scope) ) ;
262
263
263
264
// online AudioContext allows channel count to be less than no of hardware channels
264
265
if rendered. number_of_channels ( ) != self . number_of_channels {
265
- rendered. mix ( self . number_of_channels , ChannelInterpretation :: Discrete ) ;
266
+ rendered
267
+ . to_mut ( )
268
+ . mix ( self . number_of_channels , ChannelInterpretation :: Discrete ) ;
266
269
}
267
270
268
271
// copy rendered audio into output slice
@@ -279,7 +282,7 @@ impl RenderThread {
279
282
// this is the last chunk, and it contained less than RENDER_QUANTUM_SIZE samples
280
283
let channel_offset = data. len ( ) / self . number_of_channels ;
281
284
debug_assert ! ( channel_offset < RENDER_QUANTUM_SIZE ) ;
282
- self . buffer_offset = Some ( ( channel_offset, rendered) ) ;
285
+ self . buffer_offset = Some ( ( channel_offset, rendered. into_owned ( ) ) ) ;
283
286
}
284
287
285
288
// handle addition/removal of nodes/edges
You can’t perform that action at this time.
0 commit comments