File tree Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -64,10 +64,10 @@ pub struct AudioBufferOptions {
64
64
///
65
65
/// - `cargo run --release --example audio_buffer`
66
66
///
67
- #[ derive( Clone , Debug , Default ) ]
67
+ #[ derive( Clone , Debug ) ]
68
68
pub struct AudioBuffer {
69
- channels : Vec < ChannelData > ,
70
- sample_rate : f32 ,
69
+ pub ( crate ) channels : Vec < ChannelData > ,
70
+ pub ( crate ) sample_rate : f32 ,
71
71
}
72
72
73
73
impl AudioBuffer {
Original file line number Diff line number Diff line change @@ -781,8 +781,12 @@ impl AudioProcessor for AudioBufferSourceRenderer {
781
781
// Avoid deallocation in the render thread by swapping the buffers.
782
782
std:: mem:: swap ( current_buffer, buffer) ;
783
783
} else {
784
- // The default buffer is empty and does not cause allocations.
785
- self . buffer = Some ( std:: mem:: take ( buffer) ) ;
784
+ // Creating the tombstone buffer does not cause allocations.
785
+ let tombstone_buffer = AudioBuffer {
786
+ channels : Default :: default ( ) ,
787
+ sample_rate : Default :: default ( ) ,
788
+ } ;
789
+ self . buffer = Some ( std:: mem:: replace ( buffer, tombstone_buffer) ) ;
786
790
}
787
791
return ;
788
792
} ;
You can’t perform that action at this time.
0 commit comments