Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-2-2
Commits
0db5d1d2
Commit
0db5d1d2
authored
Sep 06, 2012
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Win32: run-time support for Vista's tick count
parent
1bd2dabf
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
16 deletions
+44
-16
src/win32/thread.c
src/win32/thread.c
+44
-16
No files found.
src/win32/thread.c
View file @
0db5d1d2
...
...
@@ -717,6 +717,20 @@ mtime_t mdate (void)
return
mdate_selected
();
}
static
union
{
struct
{
LARGE_INTEGER
freq
;
}
perf
;
struct
{
#if (_WIN32_WINNT < 0x0600)
ULONGLONG
(
*
get
)
(
void
);
#endif
}
tick
;
}
clk
;
#if (_WIN32_WINNT >= 0x0601)
static
mtime_t
mdate_interrupt
(
void
)
{
...
...
@@ -730,16 +744,19 @@ static mtime_t mdate_interrupt (void)
return
ts
/
(
10000000
/
CLOCK_FREQ
);
}
#endif
#if (_WIN32_WINNT >= 0x0600)
static
mtime_t
mdate_tick
(
void
)
{
#if (_WIN32_WINNT >= 0x0600)
ULONGLONG
ts
=
GetTickCount64
();
#else
ULONGLONG
ts
=
clk
.
tick
.
get
();
#endif
/* milliseconds */
static_assert
((
CLOCK_FREQ
%
1000
)
==
0
,
"Broken frequencies ratio"
);
return
ts
*
(
CLOCK_FREQ
/
1000
);
}
#endif
#include <mmsystem.h>
static
mtime_t
mdate_multimedia
(
void
)
{
...
...
@@ -750,8 +767,6 @@ static mtime_t mdate_multimedia (void)
return
ts
*
(
CLOCK_FREQ
/
1000
);
}
static
LARGE_INTEGER
perf_freq
;
static
mtime_t
mdate_perf
(
void
)
{
/* We don't need the real date, just the value of a high precision timer */
...
...
@@ -761,9 +776,9 @@ static mtime_t mdate_perf (void)
/* Convert to from (1/freq) to microsecond resolution */
/* We need to split the division to avoid 63-bits overflow */
lldiv_t
d
=
lldiv
(
counter
.
QuadPart
,
perf_
freq
.
QuadPart
);
lldiv_t
d
=
lldiv
(
counter
.
QuadPart
,
clk
.
perf
.
freq
.
QuadPart
);
return
(
d
.
quot
*
1000000
)
+
((
d
.
rem
*
1000000
)
/
perf_
freq
.
QuadPart
);
return
(
d
.
quot
*
1000000
)
+
((
d
.
rem
*
1000000
)
/
clk
.
perf
.
freq
.
QuadPart
);
}
static
mtime_t
mdate_wall
(
void
)
...
...
@@ -826,14 +841,20 @@ void SelectClockSource (vlc_object_t *obj)
}
else
#endif
#if (_WIN32_WINNT >= 0x0600)
if
(
!
strcmp
(
name
,
"tick"
))
{
msg_Dbg
(
obj
,
"using Windows time as clock source"
);
#if (_WIN32_WINNT < 0x0601)
HANDLE
h
=
GetModuleHandle
(
_T
(
"kernel32.dll"
));
if
(
unlikely
(
h
==
NULL
))
abort
();
clk
.
tick
.
get
=
(
void
*
)
GetProcAddress
(
h
,
_T
(
"GetTickCount64"
));
if
(
unlikely
(
clk
.
tick
.
get
==
NULL
))
abort
();
#endif
mdate_selected
=
mdate_tick
;
}
else
#endif
if
(
!
strcmp
(
name
,
"multimedia"
))
{
TIMECAPS
caps
;
...
...
@@ -849,9 +870,9 @@ void SelectClockSource (vlc_object_t *obj)
if
(
!
strcmp
(
name
,
"perf"
))
{
msg_Dbg
(
obj
,
"using performance counters as clock source"
);
if
(
!
QueryPerformanceFrequency
(
&
perf_
freq
))
if
(
!
QueryPerformanceFrequency
(
&
clk
.
perf
.
freq
))
abort
();
msg_Dbg
(
obj
,
" frequency: %llu Hz"
,
perf_
freq
.
QuadPart
);
msg_Dbg
(
obj
,
" frequency: %llu Hz"
,
clk
.
perf
.
freq
.
QuadPart
);
mdate_selected
=
mdate_perf
;
}
else
...
...
@@ -876,9 +897,13 @@ size_t EnumClockSource (vlc_object_t *obj, char ***vp, char ***np)
const
size_t
max
=
6
;
char
**
values
=
xmalloc
(
sizeof
(
*
values
)
*
max
);
char
**
names
=
xmalloc
(
sizeof
(
*
names
)
*
max
);
size_t
n
=
0
;
#if (_WIN32_WINNT < 0x0600)
DWORD
version
=
LOWORD
(
GetVersion
());
version
=
(
LOBYTE
(
version
)
<<
8
)
|
(
HIBYTE
(
version
)
<<
0
);
#endif
values
[
n
]
=
xstrdup
(
""
);
names
[
n
]
=
xstrdup
(
_
(
"Auto"
));
n
++
;
...
...
@@ -887,11 +912,14 @@ size_t EnumClockSource (vlc_object_t *obj, char ***vp, char ***np)
names
[
n
]
=
xstrdup
(
"Interrupt time"
);
n
++
;
#endif
#if (_WIN32_WINNT >= 0x0600)
#if (_WIN32_WINNT < 0x0600)
if
(
version
>=
0x0600
)
#endif
{
values
[
n
]
=
xstrdup
(
"tick"
);
names
[
n
]
=
xstrdup
(
"Windows time"
);
n
++
;
#endif
}
values
[
n
]
=
xstrdup
(
"multimedia"
);
names
[
n
]
=
xstrdup
(
"Multimedia timers"
);
n
++
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment