Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
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-gpu
Commits
df291664
Commit
df291664
authored
Feb 27, 2008
by
Jean-Baptiste Kempf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Src: change Windows Timer Precision, ref #264. Patch by atmo / Andre Weber.
parent
fb26fc48
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
4 deletions
+50
-4
src/misc/mtime.c
src/misc/mtime.c
+43
-4
src/misc/win32_specific.c
src/misc/win32_specific.c
+7
-0
No files found.
src/misc/mtime.c
View file @
df291664
...
@@ -49,7 +49,13 @@
...
@@ -49,7 +49,13 @@
#if defined( WIN32 ) || defined( UNDER_CE )
#if defined( WIN32 ) || defined( UNDER_CE )
# include <windows.h>
# include <windows.h>
# include <mmsystem.h>
#endif
#endif
#if defined( UNDER_CE )
# include <windows.h>
#endif
#if defined(HAVE_SYS_TIME_H)
#if defined(HAVE_SYS_TIME_H)
# include <sys/time.h>
# include <sys/time.h>
#endif
#endif
...
@@ -211,6 +217,30 @@ mtime_t mdate( void )
...
@@ -211,6 +217,30 @@ mtime_t mdate( void )
freq
=
(
QueryPerformanceFrequency
(
&
buf
)
&&
freq
=
(
QueryPerformanceFrequency
(
&
buf
)
&&
(
buf
.
QuadPart
==
I64C
(
1193182
)
||
buf
.
QuadPart
==
I64C
(
3579545
)
)
)
(
buf
.
QuadPart
==
I64C
(
1193182
)
||
buf
.
QuadPart
==
I64C
(
3579545
)
)
)
?
buf
.
QuadPart
:
0
;
?
buf
.
QuadPart
:
0
;
#if defined( WIN32 )
/* on windows 2000, XP and Vista detect if there are two
cores there - that makes QueryPerformanceFrequency in
any case not trustable?
(may also be true, for single cores with adaptive
CPU frequency and active power management?)
*/
HINSTANCE
h_Kernel32
=
LoadLibraryA
(
"kernel32.dll"
);
if
(
h_Kernel32
)
{
void
WINAPI
(
*
pf_GetSystemInfo
)(
LPSYSTEM_INFO
*
);
pf_GetSystemInfo
=
(
void
WINAPI
(
*
)(
LPSYSTEM_INFO
*
))
GetProcAddress
(
h_Kernel32
,
"GetSystemInfo"
);
if
(
pf_GetSystemInfo
)
{
SYSTEM_INFO
system_info
;
pf_GetSystemInfo
(
&
system_info
);
if
(
system_info
.
dwNumberOfProcessors
>
1
)
freq
=
0
;
}
FreeLibrary
(
h_Kernel32
);
}
#endif
}
}
if
(
freq
!=
0
)
if
(
freq
!=
0
)
...
@@ -226,9 +256,9 @@ mtime_t mdate( void )
...
@@ -226,9 +256,9 @@ mtime_t mdate( void )
}
}
else
else
{
{
/* Fallback on
GetTickCount
() which has a milisecond resolution
/* Fallback on
timeGetTime
() which has a milisecond resolution
* (actually, best case is about
10
ms resolution)
* (actually, best case is about
5
ms resolution)
*
GetTickCount
() only returns a DWORD thus will wrap after
*
timeGetTime
() only returns a DWORD thus will wrap after
* about 49.7 days so we try to detect the wrapping. */
* about 49.7 days so we try to detect the wrapping. */
static
CRITICAL_SECTION
date_lock
;
static
CRITICAL_SECTION
date_lock
;
...
@@ -238,14 +268,23 @@ mtime_t mdate( void )
...
@@ -238,14 +268,23 @@ mtime_t mdate( void )
if
(
i_wrap_counts
==
-
1
)
if
(
i_wrap_counts
==
-
1
)
{
{
/* Initialization */
/* Initialization */
#if defined( WIN32 )
i_previous_time
=
I64C
(
1000
)
*
timeGetTime
();
#else
i_previous_time
=
I64C
(
1000
)
*
GetTickCount
();
i_previous_time
=
I64C
(
1000
)
*
GetTickCount
();
#endif
InitializeCriticalSection
(
&
date_lock
);
InitializeCriticalSection
(
&
date_lock
);
i_wrap_counts
=
0
;
i_wrap_counts
=
0
;
}
}
EnterCriticalSection
(
&
date_lock
);
EnterCriticalSection
(
&
date_lock
);
#if defined( WIN32 )
res
=
I64C
(
1000
)
*
(
i_wrap_counts
*
I64C
(
0x100000000
)
+
timeGetTime
());
#else
res
=
I64C
(
1000
)
*
res
=
I64C
(
1000
)
*
(
i_wrap_counts
*
I64C
(
0x100000000
)
+
GetTickCount
());
(
i_wrap_counts
*
I64C
(
0x100000000
)
+
GetTickCount
());
#endif
if
(
i_previous_time
>
res
)
if
(
i_previous_time
>
res
)
{
{
/* Counter wrapped */
/* Counter wrapped */
...
@@ -331,7 +370,7 @@ void msleep( mtime_t delay )
...
@@ -331,7 +370,7 @@ void msleep( mtime_t delay )
snooze
(
delay
);
snooze
(
delay
);
#elif defined( WIN32 ) || defined( UNDER_CE )
#elif defined( WIN32 ) || defined( UNDER_CE )
Sleep
(
(
int
)
(
delay
/
1000
)
);
Sleep
(
(
DWORD
)
(
delay
/
1000
)
);
#elif defined( HAVE_NANOSLEEP )
#elif defined( HAVE_NANOSLEEP )
struct
timespec
ts_delay
;
struct
timespec
ts_delay
;
...
...
src/misc/win32_specific.c
View file @
df291664
...
@@ -38,6 +38,7 @@
...
@@ -38,6 +38,7 @@
#if !defined( UNDER_CE )
#if !defined( UNDER_CE )
# include <io.h>
# include <io.h>
# include <fcntl.h>
# include <fcntl.h>
# include <mmsystem.h>
#endif
#endif
#include <winsock.h>
#include <winsock.h>
...
@@ -94,6 +95,8 @@ void system_Init( libvlc_int_t *p_this, int *pi_argc, const char *ppsz_argv[] )
...
@@ -94,6 +95,8 @@ void system_Init( libvlc_int_t *p_this, int *pi_argc, const char *ppsz_argv[] )
#if !defined( UNDER_CE )
#if !defined( UNDER_CE )
_fmode
=
_O_BINARY
;
_fmode
=
_O_BINARY
;
_setmode
(
_fileno
(
stdin
),
_O_BINARY
);
/* Needed for pipes */
_setmode
(
_fileno
(
stdin
),
_O_BINARY
);
/* Needed for pipes */
timeBeginPeriod
(
5
);
#endif
#endif
/* Call mdate() once to make sure it is initialized properly */
/* Call mdate() once to make sure it is initialized properly */
...
@@ -370,5 +373,9 @@ void system_End( libvlc_int_t *p_this )
...
@@ -370,5 +373,9 @@ void system_End( libvlc_int_t *p_this )
vlc_global
()
->
psz_vlcpath
=
NULL
;
vlc_global
()
->
psz_vlcpath
=
NULL
;
}
}
#if !defined( UNDER_CE )
timeEndPeriod
(
5
);
#endif
WSACleanup
();
WSACleanup
();
}
}
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