Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cool-peaches-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@livekit/rtc-node": patch
---

Hold lock on all ffi events
10 changes: 5 additions & 5 deletions packages/livekit-rtc/src/participant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,13 @@ export type DataPublishOptions = {
export class LocalParticipant extends Participant {
private rpcHandlers: Map<string, (data: RpcInvocationData) => Promise<string>> = new Map();

private roomEventLock: Mutex;
private ffiEventLock: Mutex;

trackPublications: Map<string, LocalTrackPublication> = new Map();

constructor(info: OwnedParticipant, roomEventLock: Mutex) {
constructor(info: OwnedParticipant, ffiEventLock: Mutex) {
super(info);
this.roomEventLock = roomEventLock;
this.ffiEventLock = ffiEventLock;
}

async publishData(data: Uint8Array, options: DataPublishOptions) {
Expand Down Expand Up @@ -662,7 +662,7 @@ export class LocalParticipant extends Participant {
options: options,
});

const unlock = await this.roomEventLock.lock();
const unlock = await this.ffiEventLock.lock();

const res = FfiClient.instance.request<PublishTrackResponse>({
message: { case: 'publishTrack', value: req },
Expand Down Expand Up @@ -690,7 +690,7 @@ export class LocalParticipant extends Participant {
}

async unpublishTrack(trackSid: string, stopOnUnpublish?: boolean) {
const unlock = await this.roomEventLock.lock();
const unlock = await this.ffiEventLock.lock();
try {
const req = new UnpublishTrackRequest({
localParticipantHandle: this.ffi_handle.handle,
Expand Down
Loading
Loading