Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
90d94efe
Commit
90d94efe
authored
Jun 07, 2007
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winmm: Fix computation of sleep time until next timeout.
parent
622f62d3
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
26 deletions
+18
-26
time.c
dlls/winmm/time.c
+18
-26
No files found.
dlls/winmm/time.c
View file @
90d94efe
...
@@ -113,7 +113,7 @@ static void TIME_TriggerCallBack(LPWINE_TIMERENTRY lpTimer)
...
@@ -113,7 +113,7 @@ static void TIME_TriggerCallBack(LPWINE_TIMERENTRY lpTimer)
/**************************************************************************
/**************************************************************************
* TIME_MMSysTimeCallback
* TIME_MMSysTimeCallback
*/
*/
static
DWORD
CALLBACK
TIME_MMSysTimeCallback
(
LPWINE_MM_IDATA
iData
)
static
int
TIME_MMSysTimeCallback
(
LPWINE_MM_IDATA
iData
)
{
{
static
int
nSizeLpTimers
;
static
int
nSizeLpTimers
;
static
LPWINE_TIMERENTRY
lpTimers
;
static
LPWINE_TIMERENTRY
lpTimers
;
...
@@ -121,14 +121,7 @@ static LPWINE_TIMERENTRY lpTimers;
...
@@ -121,14 +121,7 @@ static LPWINE_TIMERENTRY lpTimers;
LPWINE_TIMERENTRY
timer
,
*
ptimer
,
*
next_ptimer
;
LPWINE_TIMERENTRY
timer
,
*
ptimer
,
*
next_ptimer
;
int
idx
;
int
idx
;
DWORD
cur_time
;
DWORD
cur_time
;
DWORD
delta_time
;
int
delta_time
,
ret_time
=
-
1
;
DWORD
ret_time
=
INFINITE
;
DWORD
adjust_time
;
/* optimize for the most frequent case - no events */
if
(
!
TIME_TimersList
)
return
(
ret_time
);
/* since timeSetEvent() and timeKillEvent() can be called
/* since timeSetEvent() and timeKillEvent() can be called
* from 16 bit code, there are cases where win16 lock is
* from 16 bit code, there are cases where win16 lock is
...
@@ -151,7 +144,8 @@ static LPWINE_TIMERENTRY lpTimers;
...
@@ -151,7 +144,8 @@ static LPWINE_TIMERENTRY lpTimers;
for
(
ptimer
=
&
TIME_TimersList
;
*
ptimer
!=
NULL
;
)
{
for
(
ptimer
=
&
TIME_TimersList
;
*
ptimer
!=
NULL
;
)
{
timer
=
*
ptimer
;
timer
=
*
ptimer
;
next_ptimer
=
&
timer
->
lpNext
;
next_ptimer
=
&
timer
->
lpNext
;
if
(
cur_time
>=
timer
->
dwTriggerTime
)
delta_time
=
timer
->
dwTriggerTime
-
cur_time
;
if
(
delta_time
<=
0
)
{
{
if
(
timer
->
lpFunc
)
{
if
(
timer
->
lpFunc
)
{
if
(
idx
==
nSizeLpTimers
)
{
if
(
idx
==
nSizeLpTimers
)
{
...
@@ -180,23 +174,22 @@ static LPWINE_TIMERENTRY lpTimers;
...
@@ -180,23 +174,22 @@ static LPWINE_TIMERENTRY lpTimers;
HeapFree
(
GetProcessHeap
(),
0
,
timer
);
HeapFree
(
GetProcessHeap
(),
0
,
timer
);
/* We don't need to trigger oneshots again */
/* We don't need to trigger oneshots again */
delta_time
=
INFINITE
;
delta_time
=
-
1
;
}
}
else
else
{
{
/* Compute when this event needs this function
/* Compute when this event needs this function
to be called again */
to be called again */
if
(
timer
->
dwTriggerTime
<=
cur_time
)
delta_time
=
0
;
else
delta_time
=
timer
->
dwTriggerTime
-
cur_time
;
delta_time
=
timer
->
dwTriggerTime
-
cur_time
;
if
(
delta_time
<
0
)
delta_time
=
0
;
}
}
}
}
else
delta_time
=
timer
->
dwTriggerTime
-
cur_time
;
/* Determine when we need to return to this function */
/* Determine when we need to return to this function */
ret_time
=
min
(
ret_time
,
delta_time
);
if
(
delta_time
!=
-
1
)
{
if
(
ret_time
==
-
1
||
ret_time
>
delta_time
)
ret_time
=
delta_time
;
}
ptimer
=
next_ptimer
;
ptimer
=
next_ptimer
;
}
}
...
@@ -209,15 +202,15 @@ static LPWINE_TIMERENTRY lpTimers;
...
@@ -209,15 +202,15 @@ static LPWINE_TIMERENTRY lpTimers;
/* Finally, adjust the recommended wait time downward
/* Finally, adjust the recommended wait time downward
by the amount of time the processing routines
by the amount of time the processing routines
actually took */
actually took */
adjust_time
=
GetTickCount
()
-
cur_time
;
if
(
ret_time
!=
-
1
)
if
(
adjust_time
>
ret_time
)
{
ret_time
=
0
;
ret_time
-=
GetTickCount
()
-
cur_time
;
else
if
(
ret_time
<
0
)
ret_time
=
0
;
ret_time
-=
adjust_time
;
}
/* We return the amount of time our caller should sleep
/* We return the amount of time our caller should sleep
before needing to check in on us again */
before needing to check in on us again */
return
(
ret_time
)
;
return
ret_time
;
}
}
/**************************************************************************
/**************************************************************************
...
@@ -226,7 +219,6 @@ static LPWINE_TIMERENTRY lpTimers;
...
@@ -226,7 +219,6 @@ static LPWINE_TIMERENTRY lpTimers;
static
DWORD
CALLBACK
TIME_MMSysTimeThread
(
LPVOID
arg
)
static
DWORD
CALLBACK
TIME_MMSysTimeThread
(
LPVOID
arg
)
{
{
LPWINE_MM_IDATA
iData
=
(
LPWINE_MM_IDATA
)
arg
;
LPWINE_MM_IDATA
iData
=
(
LPWINE_MM_IDATA
)
arg
;
DWORD
sleep_time
;
DWORD
rc
;
DWORD
rc
;
TRACE
(
"Starting main winmm thread
\n
"
);
TRACE
(
"Starting main winmm thread
\n
"
);
...
@@ -239,12 +231,12 @@ static DWORD CALLBACK TIME_MMSysTimeThread(LPVOID arg)
...
@@ -239,12 +231,12 @@ static DWORD CALLBACK TIME_MMSysTimeThread(LPVOID arg)
while
(
!
TIME_TimeToDie
)
while
(
!
TIME_TimeToDie
)
{
{
sleep_time
=
TIME_MMSysTimeCallback
(
iData
);
int
sleep_time
=
TIME_MMSysTimeCallback
(
iData
);
if
(
sleep_time
==
0
)
if
(
sleep_time
==
0
)
continue
;
continue
;
rc
=
WaitForSingleObject
(
TIME_hWakeEvent
,
sleep_time
);
rc
=
WaitForSingleObject
(
TIME_hWakeEvent
,
(
sleep_time
==
-
1
)
?
INFINITE
:
(
DWORD
)
sleep_time
);
if
(
rc
!=
WAIT_TIMEOUT
&&
rc
!=
WAIT_OBJECT_0
)
if
(
rc
!=
WAIT_TIMEOUT
&&
rc
!=
WAIT_OBJECT_0
)
{
{
FIXME
(
"Unexpected error %d(%d) in timer thread
\n
"
,
rc
,
GetLastError
());
FIXME
(
"Unexpected error %d(%d) in timer thread
\n
"
,
rc
,
GetLastError
());
...
...
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