Driver: Fix crash on .leave() (#63)

Leaving (rather than removing) a call would cause the driver to crash as it would try to use a non-existent connection immediately after it had been invalidated.

This has been tested using a modified `examples/serenity/voice_storage`, felyne, and via `cargo make ready`.
This commit is contained in:
Kyle Simpson
2021-04-10 22:44:17 +01:00
committed by GitHub
parent 22214a0f89
commit 24d8da69c0

View File

@@ -132,11 +132,14 @@ impl Mixer {
}; };
} }
if let Err(e) = self.cycle().and_then(|_| self.audio_commands_events()) { // The above action may have invalidated the connection; need to re-check!
events_failure |= e.should_trigger_interconnect_rebuild(); if self.conn_active.is_some() {
conn_failure |= e.should_trigger_connect(); if let Err(e) = self.cycle().and_then(|_| self.audio_commands_events()) {
events_failure |= e.should_trigger_interconnect_rebuild();
conn_failure |= e.should_trigger_connect();
debug!("Mixer thread cycle: {:?}", e); debug!("Mixer thread cycle: {:?}", e);
}
} }
} else { } else {
match self.mix_rx.recv() { match self.mix_rx.recv() {