pub(crate) fn handle_events(&mut self) {
        if let Ok(message) = self.receiver.try_recv() {
            match message {
                AudioEvent::SystemReady => self.system_is_ready = true,
                AudioEvent::AddSound { sound_id, data } => {
                    self.sounds.insert(sound_id, data);
                }
                AudioEvent::PlaySound { sound_id, config } => {
                    if self.currently_played_sounds.contains_key(&sound_id)
                        && !config.restart_on_conflict
                    {
                        return;
                    }
                    self.currently_played_sounds
                        .insert(sound_id, SoundState { config, sample_cursor: 0 });
                }
                AudioEvent::StopSound { sound_id } => {
                    self.currently_played_sounds.remove(&sound_id);
                }
                AudioEvent::StopAllSounds => {
                    self.currently_played_sounds.clear();
                }
            }
        }
    }
/// Handles events from the AudioMessage queue
Handles events from the AudioMessage queue
Handles events from the AudioMessage queue
pub(crate) fn handle_events(&mut self) {
        if let Ok(message) = self.receiver.try_recv() {
            match message {
                AudioEvent::SystemReady => self.system_is_ready = true,
                AudioEvent::AddSound { sound_id, data } => {
                    self.sounds.insert(sound_id, data);
                }
                AudioEvent::PlaySound { sound_id, config } => {
                    if self.currently_played_sounds.contains_key(&sound_id)
                        && !config.restart_on_conflict
                    {
                        return;
                    }
                    self.currently_played_sounds
                        .insert(sound_id, SoundState { config, sample_cursor: 0 });
                }
                AudioEvent::StopSound { sound_id } => {
                    self.currently_played_sounds.remove(&sound_id);
                }
                AudioEvent::StopAllSounds => {
                    self.currently_played_sounds.clear();
                }
            }
        }
    }
pub ( crate ) fn handle_events ( & mut self ) { if let Ok ( message ) = self . receiver . try_recv ( ) { match message { AudioEvent :: SystemReady => self . system_is_ready = true , AudioEvent :: AddSound { sound_id , data } => { self . sounds . insert ( sound_id , data ) ; } AudioEvent :: PlaySound { sound_id , config } => { if self . currently_played_sounds . contains_key ( & sound_id ) && ! config . restart_on_conflict { return ; } self . currently_played_sounds . insert ( sound_id , SoundState { config , sample_cursor : 0 } ) ; } AudioEvent :: StopSound { sound_id } => { self . currently_played_sounds . remove ( & sound_id ) ; } AudioEvent :: StopAllSounds => { self . currently_played_sounds . clear ( ) ; } } } }
Handles events from the AudioMessage queue
Handles events from the AudioMessage queue
&mut self
&mut self