@@ -109,11 +109,6 @@ pub struct AudioBufferSourceNode {
109
109
playback_rate : AudioParam , // has constraints, no a-rate
110
110
buffer_time : Arc < AtomicF64 > ,
111
111
buffer : Option < AudioBuffer > ,
112
- inner_state : InnerState ,
113
- }
114
-
115
- #[ derive( Debug , Clone ) ]
116
- struct InnerState {
117
112
loop_state : LoopState ,
118
113
source_started : bool ,
119
114
}
@@ -153,7 +148,7 @@ impl AudioScheduledSourceNode for AudioBufferSourceNode {
153
148
154
149
fn stop_at ( & mut self , when : f64 ) {
155
150
assert ! (
156
- self . inner_state . source_started,
151
+ self . source_started,
157
152
"InvalidStateError cannot stop before start"
158
153
) ;
159
154
@@ -217,18 +212,15 @@ impl AudioBufferSourceNode {
217
212
ended_triggered : false ,
218
213
} ;
219
214
220
- let inner_state = InnerState {
221
- loop_state,
222
- source_started : false ,
223
- } ;
224
215
let mut node = Self {
225
216
registration,
226
217
channel_config : ChannelConfig :: default ( ) ,
227
218
detune : d_param,
228
219
playback_rate : pr_param,
229
220
buffer_time : Arc :: clone ( & renderer. render_state . buffer_time ) ,
230
221
buffer : None ,
231
- inner_state,
222
+ loop_state,
223
+ source_started : false ,
232
224
} ;
233
225
234
226
if let Some ( buf) = buffer {
@@ -255,10 +247,10 @@ impl AudioBufferSourceNode {
255
247
/// Panics if the source was already started
256
248
pub fn start_at_with_offset_and_duration ( & mut self , start : f64 , offset : f64 , duration : f64 ) {
257
249
assert ! (
258
- !self . inner_state . source_started,
250
+ !self . source_started,
259
251
"InvalidStateError: Cannot call `start` twice"
260
252
) ;
261
- self . inner_state . source_started = true ;
253
+ self . source_started = true ;
262
254
263
255
let control = ControlMessage :: StartWithOffsetAndDuration ( start, offset, duration) ;
264
256
self . registration . post_message ( control) ;
@@ -317,32 +309,32 @@ impl AudioBufferSourceNode {
317
309
/// Defines if the playback the [`AudioBuffer`] should be looped
318
310
#[ allow( clippy:: missing_panics_doc) ]
319
311
pub fn loop_ ( & self ) -> bool {
320
- self . inner_state . loop_state . is_looping
312
+ self . loop_state . is_looping
321
313
}
322
314
323
315
pub fn set_loop ( & mut self , value : bool ) {
324
- self . inner_state . loop_state . is_looping = value;
316
+ self . loop_state . is_looping = value;
325
317
self . registration . post_message ( ControlMessage :: Loop ( value) ) ;
326
318
}
327
319
328
320
/// Defines the loop start point, in the time reference of the [`AudioBuffer`]
329
321
pub fn loop_start ( & self ) -> f64 {
330
- self . inner_state . loop_state . start
322
+ self . loop_state . start
331
323
}
332
324
333
325
pub fn set_loop_start ( & mut self , value : f64 ) {
334
- self . inner_state . loop_state . start = value;
326
+ self . loop_state . start = value;
335
327
self . registration
336
328
. post_message ( ControlMessage :: LoopStart ( value) ) ;
337
329
}
338
330
339
331
/// Defines the loop end point, in the time reference of the [`AudioBuffer`]
340
332
pub fn loop_end ( & self ) -> f64 {
341
- self . inner_state . loop_state . end
333
+ self . loop_state . end
342
334
}
343
335
344
336
pub fn set_loop_end ( & mut self , value : f64 ) {
345
- self . inner_state . loop_state . end = value;
337
+ self . loop_state . end = value;
346
338
self . registration
347
339
. post_message ( ControlMessage :: LoopEnd ( value) ) ;
348
340
}
0 commit comments