зеркало из https://github.com/mozilla/cubeb.git
Clamp to positive value when computing latency for an output stream
Diagnosed by jolin@mozilla.com, the same code is also found in Chromium.
This commit is contained in:
Родитель
6c1a6e151c
Коммит
d52193ada5
|
@ -644,8 +644,10 @@ aaudio_get_latency(cubeb_stream * stm, aaudio_direction_t direction,
|
||||||
// Extrapolate from the known timestamp for a particular frame presented.
|
// Extrapolate from the known timestamp for a particular frame presented.
|
||||||
int64_t app_frame_hw_time = hw_tstamp + frame_time_delta;
|
int64_t app_frame_hw_time = hw_tstamp + frame_time_delta;
|
||||||
// For an output stream, the latency is positive, for an input stream, it's
|
// For an output stream, the latency is positive, for an input stream, it's
|
||||||
// negative.
|
// negative. It can happen in some instances, e.g. around start of the stream
|
||||||
int64_t latency_ns = is_output ? app_frame_hw_time - signed_tstamp_ns
|
// that the latency for output is negative, return 0 in this case.
|
||||||
|
int64_t latency_ns = is_output
|
||||||
|
? std::max(0ll, app_frame_hw_time - signed_tstamp_ns)
|
||||||
: signed_tstamp_ns - app_frame_hw_time;
|
: signed_tstamp_ns - app_frame_hw_time;
|
||||||
int64_t latency_frames = stm->sample_rate * latency_ns / NS_PER_S;
|
int64_t latency_frames = stm->sample_rate * latency_ns / NS_PER_S;
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче