Skip to content

Commit

Permalink
Fix talking collision not colliding properly
Browse files Browse the repository at this point in the history
The code was only entering the blocked state if the user was speaking,
which often won't be the case when another person starts speaking because
we'll have pressed the button but not got the ack back from the server
yet. Add the transmitblocked flag instead so we don't enter that state
again if we've already decided we've been blocked.

We were also starting with blocked = false and so resetting it when it
shouldn't have been reset.

Also requires matrix-org/matrix-js-sdk#2502
  • Loading branch information
dbkr committed Jul 7, 2022
1 parent 4dcec50 commit 2b92bf3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/room/usePTT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export const usePTT = (
const onMuteStateChanged = useCallback(() => {
const activeSpeakerFeed = getActiveSpeakerFeed(userMediaFeeds, groupCall);

let blocked = false;
let blocked = transmitBlocked;
if (activeSpeakerUserId === null && activeSpeakerFeed !== null) {
if (activeSpeakerFeed.userId === client.getUserId()) {
playClip(PTTClipID.START_TALKING_LOCAL);
Expand All @@ -141,8 +141,8 @@ export const usePTT = (
playClip(PTTClipID.END_TALKING);
} else if (
pttButtonHeld &&
activeSpeakerUserId === client.getUserId() &&
activeSpeakerFeed?.userId !== client.getUserId()
activeSpeakerFeed?.userId !== client.getUserId() &&
!transmitBlocked
) {
// We were talking but we've been cut off: mute our own mic
// (this is the easier way of cutting other speakers off if an
Expand All @@ -167,6 +167,7 @@ export const usePTT = (
client,
userMediaFeeds,
setMicMuteWrapper,
transmitBlocked,
]);

useEffect(() => {
Expand Down

0 comments on commit 2b92bf3

Please sign in to comment.