libobs: Fix corruption of audio data in audio_input_buf

Previously, source->next_audio_ts_min was incremented by
conv_frames_to_time(sample_rate, in.frames) in each call of
source_output_audio_data(), so only by the duration of the audio
data itself.
However, this does not take the current timestamp into account,
which also includes execution time (audio source timestamps are
not necessarily continuous).

This causes the incoming audio timestamp to gradually deviate further
from the expected next_audio_ts_min timestamp, eventually exceeding
TS_SMOOTHING_THRESHOLD and then causing a call to
source_output_audio_place() which either overwrites existing audio
data and causes a glitch or puts data beyond the end of the buffer,
inserting a gap and thus causing a dropout.

Now use incoming timestamp for calculation of the next minimum
timestamp.
This commit is contained in:
floele 2022-02-21 22:29:12 +01:00
parent 6d5dd75e4a
commit 03518891c8

View file

@ -1482,7 +1482,7 @@ static void source_output_audio_data(obs_source_t *source,
source->last_audio_ts = in.timestamp;
source->next_audio_ts_min =
in.timestamp + conv_frames_to_time(sample_rate, in.frames);
data->timestamp + conv_frames_to_time(sample_rate, in.frames);
in.timestamp += source->timing_adjust;