fix: ⚡ deadlock while leaving room
This commit is contained in:
parent
7bbae2b0be
commit
b0bb6c6a90
4 changed files with 15 additions and 13 deletions
|
@ -26,21 +26,17 @@ struct Signal {
|
|||
|
||||
impl Signal {
|
||||
fn reset_connection(&self) -> Result<(), Error> {
|
||||
if let Some(connection_signal) = self.connection_stop_sender.read().unwrap().as_ref() {
|
||||
if !connection_signal.is_closed() {
|
||||
let mut connection_stop_sender = self.connection_stop_sender.write().unwrap();
|
||||
connection_stop_sender
|
||||
.take()
|
||||
.expect("Never")
|
||||
.send(true)
|
||||
.unwrap();
|
||||
let connection_stop_sender = self.connection_stop_sender.write().unwrap().take();
|
||||
match connection_stop_sender {
|
||||
Some(connection_stop_sender) => {
|
||||
connection_stop_sender.send(true).unwrap();
|
||||
|
||||
*connection_stop_sender = None;
|
||||
drop(connection_stop_sender);
|
||||
return Ok(());
|
||||
Ok(())
|
||||
}
|
||||
None => Err(Error::NotSupposeTo(
|
||||
"Connection Stop Sender is None".to_string(),
|
||||
))?,
|
||||
}
|
||||
Err(Error::Signal("Reset".to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -79,8 +79,12 @@ pub async fn disconnect_watcher(
|
|||
);
|
||||
}
|
||||
|
||||
println!("Going to Disconnect");
|
||||
|
||||
connect_return.send_audio_task.abort();
|
||||
connect_return.receive_audio_task.abort();
|
||||
|
||||
println!("Disconnected");
|
||||
}
|
||||
|
||||
async fn send_audio_data(
|
||||
|
|
|
@ -90,7 +90,7 @@ pub async fn play(
|
|||
},
|
||||
}
|
||||
} else {
|
||||
*sample = 0.0;
|
||||
*sample = 0.0
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -16,6 +16,7 @@ pub enum Error {
|
|||
Signal(String),
|
||||
Record(String),
|
||||
Play(String),
|
||||
NotSupposeTo(String),
|
||||
}
|
||||
|
||||
impl std::error::Error for Error {
|
||||
|
@ -34,6 +35,7 @@ impl Display for Error {
|
|||
Error::Signal(inner) => write!(f, "Signal | {}", inner),
|
||||
Error::Record(inner) => write!(f, "Record | {}", inner),
|
||||
Error::Play(inner) => write!(f, "Play | {}", inner),
|
||||
Error::NotSupposeTo(inner) => write!(f, "Not Suppose To | {}", inner),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue