浏览代码

libobs: Fix starting timestamp for preloaded frames

If audio monitoring is enabled and set to output only, the
obs_source_show_preloaded_video function would still incorrectly set the
current source audio output timestamp to the current system time, which
would cause audio to use an incorrect starting point from long ago for
the first starting audio segment if audio monitoring is then turned off
some time after having started the source.

Instead, the starting timestamp should be set to 0 if audio monitoring
is enabled with no output to stream, so that if/when audio monitoring is
disabled, it recalculates the starting timestamp of the first audio
packet on the spot again.

Closes obsproject/obs-studio#1522
jp9000 6 年之前
父节点
当前提交
4fa30c619c
共有 1 个文件被更改,包括 3 次插入1 次删除
  1. 3 1
      libobs/obs-source.c

+ 3 - 1
libobs/obs-source.c

@@ -2484,7 +2484,9 @@ void obs_source_show_preloaded_video(obs_source_t *source)
 	source->async_active = true;
 	source->async_active = true;
 
 
 	pthread_mutex_lock(&source->audio_buf_mutex);
 	pthread_mutex_lock(&source->audio_buf_mutex);
-	sys_ts = os_gettime_ns();
+	sys_ts = (source->monitoring_type != OBS_MONITORING_TYPE_MONITOR_ONLY)
+		? os_gettime_ns()
+		: 0;
 	reset_audio_timing(source, source->last_frame_ts, sys_ts);
 	reset_audio_timing(source, source->last_frame_ts, sys_ts);
 	reset_audio_data(source, sys_ts);
 	reset_audio_data(source, sys_ts);
 	pthread_mutex_unlock(&source->audio_buf_mutex);
 	pthread_mutex_unlock(&source->audio_buf_mutex);