livekit-client 1.6.4 → 1.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/room/Room.ts CHANGED
@@ -355,12 +355,16 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
355
355
  } catch (err) {
356
356
  this.recreateEngine();
357
357
  this.handleDisconnect(this.options.stopLocalTrackOnUnpublish);
358
- let errorMessage = '';
358
+ const resultingError = new ConnectionError(`could not establish signal connection`);
359
359
  if (err instanceof Error) {
360
- errorMessage = err.message;
361
- log.debug(`error trying to establish signal connection`, { error: err });
360
+ resultingError.message = `${resultingError.message}: ${err.message}`;
362
361
  }
363
- reject(new ConnectionError(`could not establish signal connection: ${errorMessage}`));
362
+ if (err instanceof ConnectionError) {
363
+ resultingError.reason = err.reason;
364
+ resultingError.status = err.status;
365
+ }
366
+ log.debug(`error trying to establish signal connection`, { error: err });
367
+ reject(resultingError);
364
368
  return;
365
369
  }
366
370
 
@@ -999,7 +999,9 @@ export default class LocalParticipant extends Participant {
999
999
  // detect granted change after permissions were denied to try and resume then
1000
1000
  currentPermissions.onchange = () => {
1001
1001
  if (currentPermissions.state !== 'denied') {
1002
- track.restartTrack();
1002
+ if (!track.isMuted) {
1003
+ track.restartTrack();
1004
+ }
1003
1005
  currentPermissions.onchange = null;
1004
1006
  }
1005
1007
  };
@@ -1009,8 +1011,10 @@ export default class LocalParticipant extends Participant {
1009
1011
  // permissions query fails for firefox, we continue and try to restart the track
1010
1012
  }
1011
1013
  }
1012
- log.debug('track ended, attempting to use a different device');
1013
- await track.restartTrack();
1014
+ if (!track.isMuted) {
1015
+ log.debug('track ended, attempting to use a different device');
1016
+ await track.restartTrack();
1017
+ }
1014
1018
  } catch (e) {
1015
1019
  log.warn(`could not restart track, muting instead`);
1016
1020
  await track.mute();
@@ -53,7 +53,11 @@ export default class LocalAudioTrack extends LocalTrack {
53
53
 
54
54
  async unmute(): Promise<LocalAudioTrack> {
55
55
  await this.muteQueue.run(async () => {
56
- if (this.source === Track.Source.Microphone && this.stopOnMute && !this.isUserProvided) {
56
+ if (
57
+ this.source === Track.Source.Microphone &&
58
+ (this.stopOnMute || this._mediaStreamTrack.readyState === 'ended') &&
59
+ !this.isUserProvided
60
+ ) {
57
61
  log.debug('reacquiring mic track');
58
62
  await this.restartTrack();
59
63
  }