Skip to content

Commit

Permalink
add close method to AudioSource and VideoSource
Browse files Browse the repository at this point in the history
ensures we can clean up allocated resources correctly
  • Loading branch information
davidzhao committed Dec 27, 2024
1 parent 12ca25c commit e9500e5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions examples/publish-wav/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ while (written < dataSize) {
written += frameSize;
}
await source.waitForPlayout();
// release resources allocated for audio publishing
source.close();

await room.disconnect();

// disposes all resources, only use if no more sessions are expected
await dispose();
4 changes: 4 additions & 0 deletions packages/livekit-rtc/src/audio_source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,8 @@ export class AudioSource {
throw new Error(cb.error);
}
}

close() {
this.ffiHandle.dispose();
}
}
4 changes: 4 additions & 0 deletions packages/livekit-rtc/src/video_source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,8 @@ export class VideoSource {
message: { case: 'captureVideoFrame', value: req },
});
}

close() {
this.ffiHandle.dispose();
}
}

0 comments on commit e9500e5

Please sign in to comment.