ntdll: Stabilize CreateTimerQueueTimer callbacks over time. (resend)

Joerg-Cyril.Hoehle at t-systems.com Joerg-Cyril.Hoehle at t-systems.com
Wed Mar 14 04:58:11 CDT 2012


[patch perhaps lost in pre-1.4 queue, resent unmodified]
[try 2: exdented queue_move_timer to have the code structure appear clearly.]

This is one of the most important audio-enhancement patches.
It fixes #30071, #28856, allows to close #28723 and perhaps most bug reports
about occasional or continuous crackling sound from ALSA, e.g. #28622 comment #34 or #28282.

All w7 XAudio2 clients are affected. Winmm less so, because apps tend to write more than one period
at a time. DSound benefits too, also it's not cured yet as it does not use mmdevapi period sizes,
GetCurrentPadding and GetPosition like I believe it should.

The key part is
fire next = t->expire + t->period (like winmm:time functions)
instead of
fire next = now + t->period.
to provide a stable rate (on average) over time.

Googling CreateTimerQueuerTimer, you'll find a few posting where its stability is discussed,
although there's no master's voice. There's also A. Eikum's observation:

Visit testbot job #17175 and other about CreateTimerQueue
and you'll see that Vista/w2k8/w7 adapt the intervals to maintain the average too, unlike w2k/xp.

I've left
fire next < now ? now + t->period
such that when the system is overloaded, the current behaviour (now + period) is maintained.
This particular case is not backed by tests, it's simply what the old code always did.

Winmm:time* behave differently when overloaded: if late by 100ms when trying to deliver 10ms
events, it'll trigger 10 times in a row.  This may be ok for multimedia winmm timers issued from a
single timer thread, but I feel that's not ok for a mechanism backed by N worker threads which
would then run in parallel. That wouldn't help an already overloaded system.

 Jörg Höhle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-ntdll-Stabilize-CreateTimerQueueTimer-callbacks-over.patch
Type: application/octet-stream
Size: 1497 bytes
Desc: 0002-ntdll-Stabilize-CreateTimerQueueTimer-callbacks-over.patch
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20120314/6eb76f7b/attachment-0001.obj>

More information about the wine-patches mailing list