0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-20 04:42:18 +02:00

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
This commit is contained in:
James Park 2019-07-05 08:41:34 -07:00
parent 534c553b23
commit da87f08da4
2 changed files with 5 additions and 1 deletions

View File

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

View File

@ -1267,8 +1267,11 @@ static void source_output_audio_data(obs_source_t *source,
if (diff > MAX_TS_VAR && !using_direct_ts)
handle_ts_jump(source, source->next_audio_ts_min,
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;
}
}
source->last_audio_ts = in.timestamp;