Commit 7a098bba authored by Thomas Guillem's avatar Thomas Guillem

coreaudio: always return a valid delay

Even if the render callbacks is not yet called.
parent 34b1d4f1
......@@ -206,20 +206,24 @@ ca_TimeGet(audio_output_t *p_aout, mtime_t *delay)
{
struct aout_sys_common *p_sys = (struct aout_sys_common *) p_aout->sys;
if (unlikely(tinfo.denom == 0))
return -1;
lock_lock(p_sys);
if (tinfo.denom == 0 || p_sys->i_render_host_time == 0)
mtime_t i_render_delay;
if (likely(p_sys->i_render_host_time != 0))
{
lock_unlock(p_sys);
return -1;
const uint64_t i_render_time_us = p_sys->i_render_host_time
* tinfo.numer / tinfo.denom / 1000;
i_render_delay = i_render_time_us - mdate();
}
const uint64_t i_render_time_us = p_sys->i_render_host_time
* tinfo.numer / tinfo.denom / 1000;
else
i_render_delay = 0;
const int64_t i_out_frames = BytesToFrames(p_sys, p_sys->i_out_size);
*delay = FramesToUs(p_sys, i_out_frames + p_sys->i_render_frames)
+ p_sys->i_dev_latency_us + i_render_time_us - mdate();
+ p_sys->i_dev_latency_us + i_render_delay;
lock_unlock(p_sys);
return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment