[vlc-devel] [PATCH] aout: wasapi: disable deferred start for Winstore builds
Thomas Guillem
thomas at gllm.fr
Wed Apr 8 17:46:33 CEST 2020
YOu also need to ifdef
if (atomic_load(&sys->started_state) != STARTED_STATE_OK)
return E_FAIL;
from TimeGet().
Also, you could use a proper define name like #define DEFERRED_START VLC_WINSTORE_APP.
That being said, maybe it's better to use the vlc_timer API so that both OSes can benefit from it (and have winstore spawning a thread for each timer update ?)
On Wed, Apr 8, 2020, at 14:54, Steve Lhomme wrote:
> The timer API is not supported.
>
> Using vlc_timer_schedule() might work but is heavier/slower as it's using
> posix/timer.c which uses a thread to run the callback.
> ---
> modules/audio_output/wasapi.c | 14 +++++++++++++-
> 1 file changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/modules/audio_output/wasapi.c b/modules/audio_output/wasapi.c
> index 5180e93f8e8..61b6cc13d6f 100644
> --- a/modules/audio_output/wasapi.c
> +++ b/modules/audio_output/wasapi.c
> @@ -91,7 +91,9 @@ static msftime_t GetQPC(void)
> typedef struct aout_stream_sys
> {
> IAudioClient *client;
> +#if !VLC_WINSTORE_APP
> HANDLE hTimer;
> +#endif // !VLC_WINSTORE_APP
>
> #define STARTED_STATE_INIT 0
> #define STARTED_STATE_OK 1
> @@ -111,12 +113,16 @@ typedef struct aout_stream_sys
>
> static void ResetTimer(aout_stream_t *s)
> {
> +#if !VLC_WINSTORE_APP
> aout_stream_sys_t *sys = s->sys;
> if (sys->hTimer != NULL)
> {
> DeleteTimerQueueTimer(NULL, sys->hTimer, INVALID_HANDLE_VALUE);
> sys->hTimer = NULL;
> }
> +#else // VLC_WINSTORE_APP
> + VLC_UNUSED(s);
> +#endif // VLC_WINSTORE_APP
> }
>
> /*** VLC audio output callbacks ***/
> @@ -160,6 +166,7 @@ static HRESULT TimeGet(aout_stream_t *s, vlc_tick_t
> *restrict delay)
> return hr;
> }
>
> +#if !VLC_WINSTORE_APP
> static void CALLBACK StartDeferredCallback(void *val, BOOLEAN timeout)
> {
> aout_stream_t *s = val;
> @@ -170,15 +177,17 @@ static void CALLBACK StartDeferredCallback(void
> *val, BOOLEAN timeout)
> SUCCEEDED(hr) ? STARTED_STATE_OK :
> STARTED_STATE_ERROR);
> (void) timeout;
> }
> +#endif // !VLC_WINSTORE_APP
>
> static HRESULT StartDeferred(aout_stream_t *s, vlc_tick_t date)
> {
> aout_stream_sys_t *sys = s->sys;
> vlc_tick_t written = vlc_tick_from_frac(sys->written, sys->rate);
> vlc_tick_t start_delay = date - vlc_tick_now() - written;
> - DWORD start_delay_ms = start_delay > 0 ? MS_FROM_VLC_TICK(start_delay) : 0;
> BOOL timer_updated = false;
>
> +#if !VLC_WINSTORE_APP
> + DWORD start_delay_ms = start_delay > 0 ?
> MS_FROM_VLC_TICK(start_delay) : 0;
> /* Create or update the current timer */
> if (start_delay_ms > 0)
> {
> @@ -195,6 +204,7 @@ static HRESULT StartDeferred(aout_stream_t *s,
> vlc_tick_t date)
> }
> else
> ResetTimer(s);
> +#endif
>
> if (!timer_updated)
> {
> @@ -747,7 +757,9 @@ static HRESULT Start(aout_stream_t *s,
> audio_sample_format_t *restrict pfmt,
> if (unlikely(sys == NULL))
> return E_OUTOFMEMORY;
> sys->client = NULL;
> +#if !VLC_WINSTORE_APP
> sys->hTimer = NULL;
> +#endif // !VLC_WINSTORE_APP
> atomic_init(&sys->started_state, STARTED_STATE_INIT);
>
> /* Configure audio stream */
> --
> 2.17.1
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
More information about the vlc-devel
mailing list