[vlc-devel] [PATCH] wasapi: use a finer sleep precision
Rémi Denis-Courmont
remi at remlab.net
Thu May 14 17:14:29 CEST 2020
Le torstaina 14. toukokuuta 2020, 17.09.55 EEST Thomas Guillem a écrit :
> Using the device period and the remaining block sample.
Doesn't make much sense to me. Could end up with insanely short or worse
insanely long waits.
> ---
> modules/audio_output/wasapi.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/modules/audio_output/wasapi.c b/modules/audio_output/wasapi.c
> index 5180e93f8e8..d338351963f 100644
> --- a/modules/audio_output/wasapi.c
> +++ b/modules/audio_output/wasapi.c
> @@ -107,6 +107,7 @@ typedef struct aout_stream_sys
> UINT64 written; /**< Frames written to the buffer */
> UINT32 frames; /**< Total buffer size (frames) */
> bool s24s32; /**< Output configured as S24N, but input as S32N */
> + vlc_tick_t period;
> } aout_stream_sys_t;
>
> static void ResetTimer(aout_stream_t *s)
> @@ -304,7 +305,8 @@ static HRESULT Play(aout_stream_t *s, block_t *block,
> vlc_tick_t date) break; /* done */
>
> /* Out of buffer space, sleep */
> - vlc_tick_sleep(sys->frames * VLC_TICK_FROM_MS(500) / sys->rate);
> + vlc_tick_sleep(vlc_tick_from_samples(block->i_nb_samples,
> sys->rate) + + sys->period);
> }
> IAudioRenderClient_Release(render);
> out:
> @@ -884,7 +886,10 @@ static HRESULT Start(aout_stream_t *s,
> audio_sample_format_t *restrict pfmt, msg_Dbg(s, "maximum latency:
> %"PRIu64"00 ns", latT);
> msg_Dbg(s, "default period : %"PRIu64"00 ns", defT);
> msg_Dbg(s, "minimum period : %"PRIu64"00 ns", minT);
> + sys->period = VLC_TICK_FROM_MSFTIME(defT);
> }
> + else
> + sys->period = 0;
>
> CoTaskMemFree(pwf_mix);
> *pfmt = fmt;
--
レミ・デニ-クールモン
http://www.remlab.net/
More information about the vlc-devel
mailing list