Переглянути джерело

win-wasapi: Subtract frame duration from timestamp

It would appear that the timestamp values returned by devices are not
perfectly accurate, and in some cases may be calculated on the spot --
to combat that, it's best to subtract the audio segment's duration from
the current audio segment's timestamp to ensure the timing is as
accurate as possible.
jp9000 8 роки тому
батько
коміт
5b20942247
1 змінених файлів з 3 додано та 0 видалено
  1. 3 0
      plugins/win-wasapi/win-wasapi.cpp

+ 3 - 0
plugins/win-wasapi/win-wasapi.cpp

@@ -421,6 +421,9 @@ bool WASAPISource::ProcessCaptureData()
 		data.timestamp        = useDeviceTiming ?
 			ts*100 : os_gettime_ns();
 
+		data.timestamp -= (uint64_t)frames * 1000000000ULL /
+			(uint64_t)sampleRate;
+
 		obs_source_output_audio(source, &data);
 
 		capture->ReleaseBuffer(frames);