浏览代码

libobs: Avoid position underflow when mixing audio sources

When a variable `pos` became larger than `AUDIO_OUTPUT_FRAMES`, `count`
will get overflowed number. To avoid the overflow, continue the loop
when `AUDIO_OUTPUT_FRAMES - pos` is not positive.
Norihiro Kamae 2 年之前
父节点
当前提交
ee6ddeeaed
共有 1 个文件被更改,包括 6 次插入0 次删除
  1. 6 0
      libobs/obs-scene.c

+ 6 - 0
libobs/obs-scene.c

@@ -1472,6 +1472,12 @@ static bool scene_audio_render(void *data, uint64_t *ts_out,
 
 		pos = (size_t)ns_to_audio_frames(sample_rate,
 						 source_ts - timestamp);
+
+		if (pos >= AUDIO_OUTPUT_FRAMES) {
+			item = item->next;
+			continue;
+		}
+
 		count = AUDIO_OUTPUT_FRAMES - pos;
 
 		if (!apply_buf && !item->visible &&