From bb504827e9cf090675ac4700c54a9877ce40c6ae Mon Sep 17 00:00:00 2001 From: Marcin Wojtczak Date: Fri, 20 Dec 2024 15:16:03 +0000 Subject: [PATCH] Revert "fix(audio-mute): fix sometimes out-of-sync remote audio mute (#3797)" This reverts commit d354100b91c0f9dbf84b2ba65f8e762c05648b63. --- .../src/locus-info/selfUtils.ts | 5 ++ .../plugin-meetings/src/meeting/muteState.ts | 7 +-- .../test/unit/spec/locus-info/selfUtils.js | 48 +++++++++---------- .../test/unit/spec/meeting/muteState.js | 24 ---------- 4 files changed, 29 insertions(+), 55 deletions(-) diff --git a/packages/@webex/plugin-meetings/src/locus-info/selfUtils.ts b/packages/@webex/plugin-meetings/src/locus-info/selfUtils.ts index 0ba3e4d8178..27079d8221b 100644 --- a/packages/@webex/plugin-meetings/src/locus-info/selfUtils.ts +++ b/packages/@webex/plugin-meetings/src/locus-info/selfUtils.ts @@ -428,6 +428,11 @@ SelfUtils.mutedByOthersChanged = (oldSelf, changedSelf) => { return false; } + // there is no need to trigger user update if no one muted user + if (changedSelf.selfIdentity === changedSelf.modifiedBy) { + return false; + } + return ( changedSelf.remoteMuted !== null && (oldSelf.remoteMuted !== changedSelf.remoteMuted || diff --git a/packages/@webex/plugin-meetings/src/meeting/muteState.ts b/packages/@webex/plugin-meetings/src/meeting/muteState.ts index 2adbd562887..43f72fcd501 100644 --- a/packages/@webex/plugin-meetings/src/meeting/muteState.ts +++ b/packages/@webex/plugin-meetings/src/meeting/muteState.ts @@ -379,12 +379,7 @@ export class MuteState { } if (muted !== undefined) { this.state.server.remoteMute = muted; - - // We never want to unmute the local stream from a server remote mute update. - // Moderated unmute is handled by a different function. - if (muted) { - this.muteLocalStream(meeting, muted, 'remotelyMuted'); - } + this.muteLocalStream(meeting, muted, 'remotelyMuted'); } } diff --git a/packages/@webex/plugin-meetings/test/unit/spec/locus-info/selfUtils.js b/packages/@webex/plugin-meetings/test/unit/spec/locus-info/selfUtils.js index 9ad22a69acb..c0656946711 100644 --- a/packages/@webex/plugin-meetings/test/unit/spec/locus-info/selfUtils.js +++ b/packages/@webex/plugin-meetings/test/unit/spec/locus-info/selfUtils.js @@ -345,39 +345,37 @@ describe('plugin-meetings', () => { }); describe('mutedByOthersChanged', () => { - it('throws an error if changedSelf is not provided', function () { - assert.throws( - () => SelfUtils.mutedByOthersChanged({}, null), - 'New self must be defined to determine if self was muted by others.' - ); + it('throws an error if changedSelf is not provided', function() { + assert.throws(() => SelfUtils.mutedByOthersChanged({}, null), 'New self must be defined to determine if self was muted by others.'); }); - it('return false when oldSelf is not defined', function () { - assert.equal(SelfUtils.mutedByOthersChanged(null, {remoteMuted: false}), false); + it('return false when oldSelf is not defined', function() { + assert.equal(SelfUtils.mutedByOthersChanged(null, { remoteMuted: false }), false); }); - it('should return true when remoteMuted is true on entry', function () { - assert.equal(SelfUtils.mutedByOthersChanged(null, {remoteMuted: true}), true); + it('should return true when remoteMuted is true on entry', function() { + assert.equal(SelfUtils.mutedByOthersChanged(null, { remoteMuted: true }), true); }); - it('should return true when remoteMuted values are different', function () { - assert.equal( - SelfUtils.mutedByOthersChanged( - {remoteMuted: false}, - {remoteMuted: true, selfIdentity: 'user1', modifiedBy: 'user2'} - ), - true - ); + it('should return false when selfIdentity and modifiedBy are the same', function() { + assert.equal(SelfUtils.mutedByOthersChanged( + { remoteMuted: false }, + { remoteMuted: true, selfIdentity: 'user1', modifiedBy: 'user1' } + ), false); }); - it('should return true when remoteMuted is true and unmuteAllowed has changed', function () { - assert.equal( - SelfUtils.mutedByOthersChanged( - {remoteMuted: true, unmuteAllowed: false}, - {remoteMuted: true, unmuteAllowed: true, selfIdentity: 'user1', modifiedBy: 'user2'} - ), - true - ); + it('should return true when remoteMuted values are different', function() { + assert.equal(SelfUtils.mutedByOthersChanged( + { remoteMuted: false }, + { remoteMuted: true, selfIdentity: 'user1', modifiedBy: 'user2' } + ), true); + }); + + it('should return true when remoteMuted is true and unmuteAllowed has changed', function() { + assert.equal(SelfUtils.mutedByOthersChanged( + { remoteMuted: true, unmuteAllowed: false }, + { remoteMuted: true, unmuteAllowed: true, selfIdentity: 'user1', modifiedBy: 'user2' } + ), true); }); }); diff --git a/packages/@webex/plugin-meetings/test/unit/spec/meeting/muteState.js b/packages/@webex/plugin-meetings/test/unit/spec/meeting/muteState.js index c89e591ff06..976f1eb8b32 100644 --- a/packages/@webex/plugin-meetings/test/unit/spec/meeting/muteState.js +++ b/packages/@webex/plugin-meetings/test/unit/spec/meeting/muteState.js @@ -113,30 +113,6 @@ describe('plugin-meetings', () => { assert.isTrue(audio.isRemotelyMuted()); }); - it('does not locally unmute on a server unmute', async () => { - const setServerMutedSpy = meeting.mediaProperties.audioStream.setServerMuted; - - // simulate remote mute - audio.handleServerRemoteMuteUpdate(meeting, true, true); - - assert.isTrue(audio.isRemotelyMuted()); - assert.isTrue(audio.isLocallyMuted()); - - // mutes local - assert.calledOnceWithExactly(setServerMutedSpy, true, 'remotelyMuted'); - - setServerMutedSpy.resetHistory(); - - // simulate remote unmute - audio.handleServerRemoteMuteUpdate(meeting, false, true); - - assert.isFalse(audio.isRemotelyMuted()); - assert.isTrue(audio.isLocallyMuted()); - - // does not unmute local - assert.notCalled(setServerMutedSpy); - }); - it('does local audio unmute if localAudioUnmuteRequired is received', async () => { // first we need to have the local stream user muted meeting.mediaProperties.audioStream.userMuted = true;