Skip to content

Commit f827e50

Browse files
jyavenardpadenot
authored andcommitted
Handle case where AudioContext.outputLatency isn't implemented.
Not all User Agents implement AudioContext.outputLatency (such as Safari). On those, totalOutputLatency would always be NaN, resulting in no video frames ever displayed.
1 parent f511c90 commit f827e50

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

samples/lib/web_audio_controller.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ export class WebAudioController {
7777
// hardware buffering, etc. This starts out negative, because it takes some
7878
// time to buffer, and crosses zero as the first audio sample is produced
7979
// by the audio output device.
80-
let totalOutputLatency =
81-
this.audioContext.outputLatency + this.audioContext.baseLatency;
80+
let outputLatency = this.audioContext.outputLatency ? this.audioContext.outputLatency : 0;
81+
let totalOutputLatency = outputLatency + this.audioContext.baseLatency;
8282

8383
return Math.max(this.audioContext.currentTime - totalOutputLatency, 0.0);
8484
}

0 commit comments

Comments
 (0)