diff --git a/examples/publish-wav/index.ts b/examples/publish-wav/index.ts index 56722969..df538d2a 100644 --- a/examples/publish-wav/index.ts +++ b/examples/publish-wav/index.ts @@ -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(); diff --git a/packages/livekit-rtc/src/audio_source.ts b/packages/livekit-rtc/src/audio_source.ts index 4975d8e4..8ae3bb36 100644 --- a/packages/livekit-rtc/src/audio_source.ts +++ b/packages/livekit-rtc/src/audio_source.ts @@ -134,4 +134,8 @@ export class AudioSource { throw new Error(cb.error); } } + + close() { + this.ffiHandle.dispose(); + } } diff --git a/packages/livekit-rtc/src/video_source.ts b/packages/livekit-rtc/src/video_source.ts index 9ac4170d..4290d14f 100644 --- a/packages/livekit-rtc/src/video_source.ts +++ b/packages/livekit-rtc/src/video_source.ts @@ -64,4 +64,8 @@ export class VideoSource { message: { case: 'captureVideoFrame', value: req }, }); } + + close() { + this.ffiHandle.dispose(); + } }