History

Undeafen: unmute if user was not muted prior to deafening

Piotr Osiewicz committed 3 years ago

Commit 2ddf0e11 parent 749f60b1 file · +14 −5Browse files

Unified · Split

crates/call/src/room.rs+14−5
@@ -163,6 +163,7 @@ impl Room { · 162 unmodified lines
163 screen_track: LocalTrack::None,163 screen_track: LocalTrack::None,
164 microphone_track: LocalTrack::None,164 microphone_track: LocalTrack::None,
165 next_publish_id: 0,165 next_publish_id: 0,
166 muted_by_user: false,
166 deafened: false,167 deafened: false,
167 speaking: false,168 speaking: false,
168 _maintain_room,169 _maintain_room,
@@ -1231,6 +1232,10 @@ impl Room { · 1062 unmodified lines
1231 should_mute: bool,1232 should_mute: bool,
1232 cx: &mut ModelContext<Self>,1233 cx: &mut ModelContext<Self>,
1233 ) -> Result<Task<Result<()>>> {1234 ) -> Result<Task<Result<()>>> {
1235 if !should_mute {
1236 // clear user muting state.
1237 live_kit.muted_by_user = false;
1238 }
1234 match &mut live_kit.microphone_track {1239 match &mut live_kit.microphone_track {
1235 LocalTrack::None => Err(anyhow!("microphone was not shared")),1240 LocalTrack::None => Err(anyhow!("microphone was not shared")),
1236 LocalTrack::Pending { muted, .. } => {1241 LocalTrack::Pending { muted, .. } => {
@@ -1249,9 +1254,11 @@ impl Room { · 12 unmodified lines
1249 }1254 }
1250 }1255 }
1251 pub fn toggle_mute(&mut self, cx: &mut ModelContext<Self>) -> Result<Task<Result<()>>> {1256 pub fn toggle_mute(&mut self, cx: &mut ModelContext<Self>) -> Result<Task<Result<()>>> {
1252 let should_mute = self.is_muted();1257 let should_mute = !self.is_muted();
1253 if let Some(live_kit) = self.live_kit.as_mut() {1258 if let Some(live_kit) = self.live_kit.as_mut() {
1254 Self::set_mute(live_kit, !should_mute, cx)1259 let ret = Self::set_mute(live_kit, should_mute, cx);
1260 live_kit.muted_by_user = should_mute;
1261 ret
1255 } else {1262 } else {
1256 Err(anyhow!("LiveKit not started"))1263 Err(anyhow!("LiveKit not started"))
1257 }1264 }
@@ -1264,9 +1271,9 @@ impl Room { · 6 unmodified lines
1264 let mut tasks = Vec::with_capacity(self.remote_participants.len());1271 let mut tasks = Vec::with_capacity(self.remote_participants.len());
1265 // Context notification is sent within set_mute itself.1272 // Context notification is sent within set_mute itself.
1266 let mut mute_task = None;1273 let mut mute_task = None;
1267 if live_kit.deafened {1274 // When deafening, mute user's mic as well.
1268 // Unmute microphone only if we're going from unmuted -> muted state.1275 // When undeafening, unmute user's mic unless it was manually muted prior to deafening.
1269 // We don't want to unmute user automatically.1276 if live_kit.deafened || !live_kit.muted_by_user {
1270 mute_task = Some(Self::set_mute(live_kit, live_kit.deafened, cx)?);1277 mute_task = Some(Self::set_mute(live_kit, live_kit.deafened, cx)?);
1271 };1278 };
1272 for participant in self.remote_participants.values() {1279 for participant in self.remote_participants.values() {
@@ -1331,6 +1338,8 @@ struct LiveKitRoom { · 58 unmodified lines
1331 room: Arc<live_kit_client::Room>,1338 room: Arc<live_kit_client::Room>,
1332 screen_track: LocalTrack,1339 screen_track: LocalTrack,
1333 microphone_track: LocalTrack,1340 microphone_track: LocalTrack,
1341 /// Tracks whether we're currently in a muted state due to auto-mute from deafening or manual mute performed by user.
1342 muted_by_user: bool,
1334 deafened: bool,1343 deafened: bool,
1335 speaking: bool,1344 speaking: bool,
1336 next_publish_id: usize,1345 next_publish_id: usize,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t