Deafen now also mutes microphone
This commit is contained in:
parent
f774dbfe2e
commit
8bd9fe1fb0
1 changed files with 26 additions and 20 deletions
|
@ -1176,24 +1176,31 @@ impl Room {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
fn set_mute(
|
||||||
pub fn toggle_mute(&mut self, cx: &mut ModelContext<Self>) -> Result<Task<Result<()>>> {
|
live_kit: &mut LiveKitRoom,
|
||||||
if let Some(live_kit) = self.live_kit.as_mut() {
|
should_mute: bool,
|
||||||
match &mut live_kit.microphone_track {
|
cx: &mut ModelContext<Self>,
|
||||||
LocalTrack::None => Err(anyhow!("microphone was not shared")),
|
) -> Result<Task<Result<()>>> {
|
||||||
LocalTrack::Pending { muted, .. } => {
|
match &mut live_kit.microphone_track {
|
||||||
*muted = !*muted;
|
LocalTrack::None => Err(anyhow!("microphone was not shared")),
|
||||||
Ok(Task::Ready(Some(Ok(()))))
|
LocalTrack::Pending { muted, .. } => {
|
||||||
}
|
*muted = should_mute;
|
||||||
LocalTrack::Published {
|
Ok(Task::Ready(Some(Ok(()))))
|
||||||
track_publication,
|
|
||||||
muted,
|
|
||||||
} => {
|
|
||||||
*muted = !*muted;
|
|
||||||
|
|
||||||
Ok(cx.background().spawn(track_publication.set_mute(*muted)))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
LocalTrack::Published {
|
||||||
|
track_publication,
|
||||||
|
muted,
|
||||||
|
} => {
|
||||||
|
*muted = should_mute;
|
||||||
|
|
||||||
|
Ok(cx.background().spawn(track_publication.set_mute(*muted)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub fn toggle_mute(&mut self, cx: &mut ModelContext<Self>) -> Result<Task<Result<()>>> {
|
||||||
|
let should_mute = self.is_muted().unwrap_or(false);
|
||||||
|
if let Some(live_kit) = self.live_kit.as_mut() {
|
||||||
|
Self::set_mute(live_kit, !should_mute, cx)
|
||||||
} else {
|
} else {
|
||||||
Err(anyhow!("LiveKit not started"))
|
Err(anyhow!("LiveKit not started"))
|
||||||
}
|
}
|
||||||
|
@ -1204,9 +1211,9 @@ impl Room {
|
||||||
(*live_kit).deafened = !live_kit.deafened
|
(*live_kit).deafened = !live_kit.deafened
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(live_kit) = &self.live_kit {
|
if let Some(live_kit) = self.live_kit.as_mut() {
|
||||||
let mut tasks = Vec::with_capacity(self.remote_participants.len());
|
let mut tasks = Vec::with_capacity(self.remote_participants.len());
|
||||||
|
let _ = Self::set_mute(live_kit, live_kit.deafened, cx)?; // todo (osiewicz): we probably want to schedule it on fg/bg?
|
||||||
for participant in self.remote_participants.values() {
|
for participant in self.remote_participants.values() {
|
||||||
for track in live_kit
|
for track in live_kit
|
||||||
.room
|
.room
|
||||||
|
@ -1215,7 +1222,6 @@ impl Room {
|
||||||
tasks.push(cx.foreground().spawn(track.set_enabled(!live_kit.deafened)));
|
tasks.push(cx.foreground().spawn(track.set_enabled(!live_kit.deafened)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(cx.foreground().spawn(async move {
|
Ok(cx.foreground().spawn(async move {
|
||||||
for task in tasks {
|
for task in tasks {
|
||||||
task.await?;
|
task.await?;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue