Merge branch 'capucho/stop-ambient' into 'master'

Stop ambient sounds on logout

See merge request veloren/veloren!2151
This commit is contained in:
Samuel Keiffer 2021-04-18 23:38:10 +00:00
commit 12cc4cb29f
3 changed files with 9 additions and 0 deletions

View File

@ -193,6 +193,8 @@ impl AmbientChannel {
self.sink.append(source); self.sink.append(source);
} }
pub fn stop(&mut self) { self.sink.stop(); }
pub fn set_volume(&mut self, volume: f32) { self.sink.set_volume(volume); } pub fn set_volume(&mut self, volume: f32) { self.sink.set_volume(volume); }
pub fn get_volume(&mut self) -> f32 { self.sink.volume() } pub fn get_volume(&mut self) -> f32 { self.sink.volume() }

View File

@ -422,6 +422,12 @@ impl AudioFrontend {
} }
} }
pub fn stop_ambient_sounds(&mut self) {
for channel in self.ambient_channels.iter_mut() {
channel.stop()
}
}
// The following is for the disabled device switcher // The following is for the disabled device switcher
//// TODO: figure out how badly this will break things when it is called //// TODO: figure out how badly this will break things when it is called
//pub fn set_device(&mut self, name: String) { //pub fn set_device(&mut self, name: String) {

View File

@ -920,6 +920,7 @@ impl PlayState for SessionState {
}, },
HudEvent::Logout => { HudEvent::Logout => {
self.client.borrow_mut().logout(); self.client.borrow_mut().logout();
global_state.audio.stop_ambient_sounds();
return PlayStateResult::Pop; return PlayStateResult::Pop;
}, },
HudEvent::Quit => { HudEvent::Quit => {