Skip to content

Commit 89c52b2

Browse files
Fix negative queue size (#539)
* fix negative queue size * clearer formatting * Create lemon-laws-wave.md --------- Co-authored-by: lukasIO <mail@lukasseiler.de>
1 parent 318f734 commit 89c52b2

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

.changeset/lemon-laws-wave.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@livekit/rtc-node": patch
3+
---
4+
5+
Fix negative queue size on captureFrame

packages/livekit-rtc/src/audio_source.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export class AudioSource {
115115
const now = Number(process.hrtime.bigint() / BigInt(1000000));
116116
const elapsed = this.lastCapture === 0 ? 0 : now - this.lastCapture;
117117
const frameDurationMs = (frame.samplesPerChannel / frame.sampleRate) * 1000;
118-
this.currentQueueSize += frameDurationMs - elapsed;
118+
this.currentQueueSize = Math.max(this.currentQueueSize - elapsed, 0) + frameDurationMs;
119119

120120
this.lastCapture = now;
121121

0 commit comments

Comments
 (0)