Skip to content

Commit

Permalink
win32: threads: do not use mdate_perf as the default clock source
Browse files Browse the repository at this point in the history
It relies on clk.perf.freq.QuadPart which is uninitialized and unknown until
SelectClockSource() is called. So it calls vlc_threads_setup() each time until
vlc_threads_setup() is called with the libvlc instance.

Except vlc_threads_setup(NULL) will crash on the
var_InheritBool(vlc, "high-priority") call. It's broken since
d0c4c5a

Usable candidates at startup are:
* mdate_interrupt which is a counter in 100 ns, not a wall clock
* mdate_tick which is a counter in 1 ms, not a wall clock
* mdate_perf_100ns which is a clock in 100 ns but we don't know if the system
uses that resolution
* mdate_wall which is a clock in 100 ns resolution (slowest)

mdate_wall gives the better results and should provide a safe transition with
mdate_perf/mdate_perf_100ns values.
  • Loading branch information
robUx4 authored and chouquette committed Aug 11, 2022
1 parent 9d21543 commit 6d233f3
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/win32/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,7 @@ static vlc_tick_t mdate_wall (void)

static vlc_tick_t mdate_default(void)
{
vlc_threads_setup(NULL);
return mdate_perf();
return mdate_wall();
}

static vlc_tick_t (*mdate_selected) (void) = mdate_default;
Expand Down

0 comments on commit 6d233f3

Please sign in to comment.