Skip to content

Commit

Permalink
Revert "fix(audio-mute): fix sometimes out-of-sync remote audio mute (#…
Browse files Browse the repository at this point in the history
…3797)"

This reverts commit d354100.
  • Loading branch information
marcin-bazyl committed Dec 20, 2024
1 parent 31f2bf3 commit bb50482
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 55 deletions.
5 changes: 5 additions & 0 deletions packages/@webex/plugin-meetings/src/locus-info/selfUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand Down
7 changes: 1 addition & 6 deletions packages/@webex/plugin-meetings/src/meeting/muteState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit bb50482

Please sign in to comment.