pub(crate) unsafe fn load_unload_sounds(&mut self) {
        self.sounds.drain().for_each(|(id, mut data)| {
            thread::spawn(move || {
                let channel = data.description().channel_count();
                let mut samples = data.samples::<f32>().map(|e| e.unwrap());
                match channel {
                    super::MONO => {
                        while let Some(sample) = samples.next() {
                            VEC.push((id, [sample, sample]));
                        }
                    }
                    super::STEREO => unsafe {
                        while let (Some(sample_left), Some(sample_right)) =
                            (samples.next(), samples.next())
                        {
                            VEC.push((id, [sample_left, sample_right]));
                        }
                    },
                    _ => {}
                }
            });
        });
        VEC.drain(0..).for_each(|(id, sample)| {
            self.loaded_sounds.entry(id).or_insert(Vec::new()).push(sample);
        });
    }
/// responsible to drain sounds that needs to be loaded and creates a thread
/// that will add to a static vec the data.
/// Then, drain the vec to add data to the loaded sounds
responsible to drain sounds that needs to be loaded and creates a thread
that will add to a static vec the data.
Then, drain the vec to add data to the loaded sounds
responsible to drain sounds that needs to be loaded and creates a thread that will add to a static vec the data . Then drain the vec to add data to the loaded sounds
pub(crate) unsafe fn load_unload_sounds(&mut self) {
        self.sounds.drain().for_each(|(id, mut data)| {
            thread::spawn(move || {
                let channel = data.description().channel_count();
                let mut samples = data.samples::<f32>().map(|e| e.unwrap());
                match channel {
                    super::MONO => {
                        while let Some(sample) = samples.next() {
                            VEC.push((id, [sample, sample]));
                        }
                    }
                    super::STEREO => unsafe {
                        while let (Some(sample_left), Some(sample_right)) =
                            (samples.next(), samples.next())
                        {
                            VEC.push((id, [sample_left, sample_right]));
                        }
                    },
                    _ => {}
                }
            });
        });
        VEC.drain(0..).for_each(|(id, sample)| {
            self.loaded_sounds.entry(id).or_insert(Vec::new()).push(sample);
        });
    }
pub ( crate ) unsafe fn load_unload_sounds ( & mut self ) { self . sounds . drain ( ) . for_each ( | ( id , mut data ) | { thread :: spawn ( move | | { let channel = data . description ( ) . channel_count ( ) ; let mut samples = data . samples :: < f32 > ( ) . map ( | e | e . unwrap ( ) ) ; match channel { super :: MONO => { while let Some ( sample ) = samples . next ( ) { VEC . push ( ( id , [ sample , sample ] ) ) ; } } super :: STEREO => unsafe { while let ( Some ( sample_left ) , Some ( sample_right ) ) = ( samples . next ( ) , samples . next ( ) ) { VEC . push ( ( id , [ sample_left , sample_right ] ) ) ; } } , _ => { } } } ) ; } ) ; VEC . drain ( 0 .. ) . for_each ( | ( id , sample ) | { self . loaded_sounds . entry ( id ) . or_insert ( Vec :: new ( ) ) . push ( sample ) ; } ) ; }
responsible to drain sounds that needs to be loaded and creates a thread
that will add to a static vec the data.
responsible to drain sounds that needs to be loaded and creates a thread that will add to a static vec the data .
&mut self
&mut self