diff --git a/voxygen/src/audio/channel.rs b/voxygen/src/audio/channel.rs index dd29aa4b85..65e1d79099 100644 --- a/voxygen/src/audio/channel.rs +++ b/voxygen/src/audio/channel.rs @@ -193,6 +193,8 @@ impl AmbientChannel { 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 get_volume(&mut self) -> f32 { self.sink.volume() } diff --git a/voxygen/src/audio/mod.rs b/voxygen/src/audio/mod.rs index bc2690ee14..b1fd2ea4b2 100644 --- a/voxygen/src/audio/mod.rs +++ b/voxygen/src/audio/mod.rs @@ -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 //// TODO: figure out how badly this will break things when it is called //pub fn set_device(&mut self, name: String) { diff --git a/voxygen/src/session/mod.rs b/voxygen/src/session/mod.rs index a5ef5a2df7..4fd1dbe383 100644 --- a/voxygen/src/session/mod.rs +++ b/voxygen/src/session/mod.rs @@ -920,6 +920,7 @@ impl PlayState for SessionState { }, HudEvent::Logout => { self.client.borrow_mut().logout(); + global_state.audio.stop_ambient_sounds(); return PlayStateResult::Pop; }, HudEvent::Quit => {