File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @livekit/rtc-node ' : patch
3+ ---
4+
5+ bugfix: no more negative timeouts being set on AudioSource
Original file line number Diff line number Diff line change @@ -99,13 +99,19 @@ export class AudioSource {
9999 this . lastCapture = 0 ;
100100 this . currentQueueSize = 0 ;
101101 this . promise = this . newPromise ( ) ;
102+ this . timeout = undefined ;
102103 } ) ;
103104 }
104105
105106 async captureFrame ( frame : AudioFrame ) {
106107 if ( this . closed ) {
107108 throw new Error ( 'AudioSource is closed' ) ;
108109 }
110+
111+ if ( frame . samplesPerChannel === 0 ) {
112+ return ;
113+ }
114+
109115 const now = Number ( process . hrtime . bigint ( ) / BigInt ( 1000000 ) ) ;
110116 const elapsed = this . lastCapture === 0 ? 0 : now - this . lastCapture ;
111117 const frameDurationMs = ( frame . samplesPerChannel / frame . sampleRate ) * 1000 ;
@@ -117,9 +123,7 @@ export class AudioSource {
117123 clearTimeout ( this . timeout ) ;
118124 }
119125
120- // remove 50ms to account for processing time
121- // (e.g. using wait_for_playout for very small chunks)
122- this . timeout = setTimeout ( this . release , this . currentQueueSize - 50 ) ;
126+ this . timeout = setTimeout ( this . release , this . currentQueueSize ) ;
123127
124128 const req = new CaptureAudioFrameRequest ( {
125129 sourceHandle : this . ffiHandle . handle ,
You can’t perform that action at this time.
0 commit comments