Timers now always processed in correct order. Fixes sound in Lion King and probably some other timing related issues.
This commit is contained in:
parent
390c5e2999
commit
276650c145
1 changed files with 35 additions and 15 deletions
50
src/timer.c
50
src/timer.c
|
|
@ -31,29 +31,49 @@ void timer_process()
|
|||
{
|
||||
int c;
|
||||
int retry;
|
||||
int process = 0;
|
||||
/*Get actual elapsed time*/
|
||||
int diff = timer_latch - timer_count;
|
||||
|
||||
int enable[TIMERS_MAX];
|
||||
|
||||
timer_latch = 0;
|
||||
|
||||
do
|
||||
for (c = 0; c < timers_present; c++)
|
||||
{
|
||||
retry = 0;
|
||||
for (c = 0; c < timers_present; c++)
|
||||
enable[c] = *timers[c].enable;
|
||||
if (*timers[c].enable)
|
||||
{
|
||||
if (*timers[c].enable)
|
||||
*timers[c].count = *timers[c].count - (diff << TIMER_SHIFT);
|
||||
if (*timers[c].count <= 0)
|
||||
process = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!process)
|
||||
return;
|
||||
|
||||
while (1)
|
||||
{
|
||||
int lowest = 1, lowest_c;
|
||||
|
||||
for (c = 0; c < timers_present; c++)
|
||||
{
|
||||
if (enable[c])
|
||||
{
|
||||
*timers[c].count = *timers[c].count - (diff << TIMER_SHIFT);
|
||||
if (*timers[c].count <= 0)
|
||||
timers[c].callback(timers[c].priv);
|
||||
if (*timers[c].count <= 0)
|
||||
retry = 1;
|
||||
}
|
||||
}
|
||||
diff = 0;
|
||||
}
|
||||
while (retry);
|
||||
if (*timers[c].count < lowest)
|
||||
{
|
||||
lowest = *timers[c].count;
|
||||
lowest_c = c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (lowest > 0)
|
||||
break;
|
||||
|
||||
timers[lowest_c].callback(timers[lowest_c].priv);
|
||||
enable[lowest_c] = *timers[lowest_c].enable;
|
||||
}
|
||||
}
|
||||
|
||||
void timer_update_outstanding()
|
||||
|
|
|
|||
Loading…
Reference in a new issue