Skip to content

Commit

Permalink
Emit MediaDeviceError only when acquiring tracks fails
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasIO committed Jan 8, 2025
1 parent 5abc169 commit 4294261
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/room/participant/LocalParticipant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,16 @@ export default class LocalParticipant extends Participant {
default:
throw new TrackInvalidError(source);
}
} catch (e: unknown) {
localTracks?.forEach((tr) => {
tr.stop();
});
if (e instanceof Error) {
this.emit(ParticipantEvent.MediaDevicesError, e);
}
throw e;
}
try {
const publishPromises: Array<Promise<LocalTrackPublication>> = [];
for (const localTrack of localTracks) {
this.log.info('publishing track', {
Expand All @@ -502,9 +512,6 @@ export default class LocalParticipant extends Participant {
localTracks?.forEach((tr) => {
tr.stop();
});
if (e instanceof Error && !(e instanceof TrackInvalidError)) {
this.emit(ParticipantEvent.MediaDevicesError, e);
}
throw e;
} finally {
this.pendingPublishing.delete(source);
Expand Down

0 comments on commit 4294261

Please sign in to comment.