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 {
|
impl Signal {
|
||||||
fn reset_connection(&self) -> Result<(), Error> {
|
fn reset_connection(&self) -> Result<(), Error> {
|
||||||
if let Some(connection_signal) = self.connection_stop_sender.read().unwrap().as_ref() {
|
let connection_stop_sender = self.connection_stop_sender.write().unwrap().take();
|
||||||
if !connection_signal.is_closed() {
|
match connection_stop_sender {
|
||||||
let mut connection_stop_sender = self.connection_stop_sender.write().unwrap();
|
Some(connection_stop_sender) => {
|
||||||
connection_stop_sender
|
connection_stop_sender.send(true).unwrap();
|
||||||
.take()
|
|
||||||
.expect("Never")
|
|
||||||
.send(true)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
*connection_stop_sender = None;
|
Ok(())
|
||||||
drop(connection_stop_sender);
|
|
||||||
return 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.send_audio_task.abort();
|
||||||
connect_return.receive_audio_task.abort();
|
connect_return.receive_audio_task.abort();
|
||||||
|
|
||||||
|
println!("Disconnected");
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn send_audio_data(
|
async fn send_audio_data(
|
||||||
|
|
|
@ -90,7 +90,7 @@ pub async fn play(
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
*sample = 0.0;
|
*sample = 0.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,6 +16,7 @@ pub enum Error {
|
||||||
Signal(String),
|
Signal(String),
|
||||||
Record(String),
|
Record(String),
|
||||||
Play(String),
|
Play(String),
|
||||||
|
NotSupposeTo(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::error::Error for Error {
|
impl std::error::Error for Error {
|
||||||
|
@ -34,6 +35,7 @@ impl Display for Error {
|
||||||
Error::Signal(inner) => write!(f, "Signal | {}", inner),
|
Error::Signal(inner) => write!(f, "Signal | {}", inner),
|
||||||
Error::Record(inner) => write!(f, "Record | {}", inner),
|
Error::Record(inner) => write!(f, "Record | {}", inner),
|
||||||
Error::Play(inner) => write!(f, "Play | {}", 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