浏览代码

libobs: Buffer-smoothing enhancements

If an audio source does not provide enough data at a steady pace, the
timestamp update does not happen, and buffering increases until it
maxes out. To counteract this, update the timestamp anyway.

Another issue for decoupled audio sources is that timing is not
adjusted for divergence from system time. Making this adjustment is
better for timing stability.

5+ hours of stable audio without any buffering on my GV-USB2 where it
used to add 21ms every 5 mintues or so.

Fixes https://obsproject.com/mantis/view.php?id=1269
James Park 6 年之前
父节点
当前提交
da87f08da4
共有 2 个文件被更改,包括 5 次插入1 次删除
  1. 1 0
      libobs/obs-audio.c
  2. 4 1
      libobs/obs-source.c

+ 1 - 0
libobs/obs-audio.c

@@ -211,6 +211,7 @@ static inline void discard_audio(struct obs_core_audio *audio,
 		if (is_audio_source)
 		if (is_audio_source)
 			blog(LOG_DEBUG, "can't discard, data still pending");
 			blog(LOG_DEBUG, "can't discard, data still pending");
 #endif
 #endif
+		source->audio_ts = ts->end;
 		return;
 		return;
 	}
 	}
 
 

+ 4 - 1
libobs/obs-source.c

@@ -1267,8 +1267,11 @@ static void source_output_audio_data(obs_source_t *source,
 		if (diff > MAX_TS_VAR && !using_direct_ts)
 		if (diff > MAX_TS_VAR && !using_direct_ts)
 			handle_ts_jump(source, source->next_audio_ts_min,
 			handle_ts_jump(source, source->next_audio_ts_min,
 				       in.timestamp, diff, os_time);
 				       in.timestamp, diff, os_time);
-		else if (diff < TS_SMOOTHING_THRESHOLD)
+		else if (diff < TS_SMOOTHING_THRESHOLD) {
+			if (source->async_unbuffered && source->async_decoupled)
+				source->timing_adjust = os_time - in.timestamp;
 			in.timestamp = source->next_audio_ts_min;
 			in.timestamp = source->next_audio_ts_min;
+		}
 	}
 	}
 
 
 	source->last_audio_ts = in.timestamp;
 	source->last_audio_ts = in.timestamp;