http://bugs.winehq.org/show_bug.cgi?id=30071
Bug #: 30071 Summary: Need a CreateTimerQueueTimer that is stable over time Product: Wine Version: 1.3.25 Platform: x86 OS/Version: Linux Status: NEW Severity: major Priority: P2 Component: ntdll AssignedTo: wine-bugs@winehq.org ReportedBy: hoehle@users.sourceforge.net Classification: Unclassified
Andrew Eikum's quick test in http://www.winehq.org/pipermail/wine-devel/2012-February/094457.html suggests that CreateTimerQueueTimer stabilizes itself over time on *average*. For instance, when asked for a 12ms period, it will trigger 5 times within 60ms even though it is unable to trigger every 12ms. The deltas are: 20, 10, 10, 10, 10, 20, 10, 10, 10, 10, ...
This is an essential property that it would share with winmm timers.
Both winealsa and wineoss today crucially depend on this property. The XAudio2 algorithm described in bug #28723 either writes one or zero period worth of data per callback. Hence it requires callbacks to agree with frame consumption by the audio device. If too late, XAudio2 will not catch up by writing 2 periods.
What currently happens is irregular crackling due to occasional underruns because callbacks are further and further delayed and the audio buffers slowly empties. Compare timestamps from apps using winmm with mmdevapi: winmm mmdevapi x.304 x.304 x.315 x.315 x.324 x.326 x.334 x.336 x.346 x.348 x.354 x.359 winmm corrects itself and manages to trigger all 10ms events on the same millisecond as the initial one: x.xx4.
CTQT accumulates delays because as its core, queue_timer_expire uses: [t->expire =] queue_current_time() + t->period;
I've separated this issue from bug #28723 because the root cause is not an audio component and because several other bugs mention CreateTimerQueue, e.g. bug #29585.
http://bugs.winehq.org/show_bug.cgi?id=30071
--- Comment #1 from Jörg Höhle hoehle@users.sourceforge.net 2012-03-04 01:17:59 CST --- Created attachment 39178 --> http://bugs.winehq.org/attachment.cgi?id=39178 Stabilize CreateTimerQueue
With the patch in place, mmdevapi:render:test_worst_case is right on time and produces no audio glitch: render.c:2152: Released 48000=100x480 -480 frames at 48000 worth 990ms in 1001ms render.c:2098: Should play 1000ms continuous tone with fragment size 480. render.c:2152: Released 48000=100x480 -480 frames at 48000 worth 990ms in 1000ms render.c:2098: Should play 1000ms continuous tone with fragment size 480.
Note that this happens despite this particular system's inability to trigger on 10ms boundaries. It seems to know only multiples of 4ms: 9.309:alsa_write_data pad: 1132 9.317:alsa_write_data pad: 1229 9.329:alsa_write_data pad: 1133 9.337:alsa_write_data pad: 1229 9.349:alsa_write_data pad: 1133 9.357:alsa_write_data pad: 1228 The winealsa feeder algorithm was designed to accommodate such variation by hiding a few periods from GetCurrentPadding's sight.
http://bugs.winehq.org/show_bug.cgi?id=30071
Jörg Höhle hoehle@users.sourceforge.net changed:
What |Removed |Added ---------------------------------------------------------------------------- Blocks| |28723
http://bugs.winehq.org/show_bug.cgi?id=30071
Dmitry Timoshkov dmitry@baikal.ru changed:
What |Removed |Added ---------------------------------------------------------------------------- Severity|major |minor
http://bugs.winehq.org/show_bug.cgi?id=30071
Andrew Eikum aeikum@codeweavers.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |aeikum@codeweavers.com
http://bugs.winehq.org/show_bug.cgi?id=30071
Jörg Höhle hoehle@users.sourceforge.net changed:
What |Removed |Added ---------------------------------------------------------------------------- Severity|minor |major
--- Comment #2 from Jörg Höhle hoehle@users.sourceforge.net 2012-03-06 04:32:27 CST --- Dmitry, this may be a minor issue from ntdll's POV, but it's a critical issue for Wine's audio. Please visit testbot job #17175 and read my interpretation of its results in: http://www.winehq.org/pipermail/wine-devel/2012-March/094524.html The test shows that since Vista, native stabilizes on average. Wine's audio needs that too, for as long as it uses CreateTimerQueue.
http://bugs.winehq.org/show_bug.cgi?id=30071
Dmitry Timoshkov dmitry@baikal.ru changed:
What |Removed |Added ---------------------------------------------------------------------------- Severity|major |minor
--- Comment #3 from Dmitry Timoshkov dmitry@baikal.ru 2012-03-06 05:59:26 CST --- This bug mentions no applications affected by this. Yes, there are sound related issues scattered over bugzilla, but I haven't seen that they are broken because of CreateTimerQueueTimer implementation *they are using*. If some of Wine API use CreateTimerQueueTimer for internal purposes that doesn't mean they can't use something else instead.
http://bugs.winehq.org/show_bug.cgi?id=30071
Jörg Höhle hoehle@users.sourceforge.net changed:
What |Removed |Added ---------------------------------------------------------------------------- Severity|minor |normal
--- Comment #4 from Jörg Höhle hoehle@users.sourceforge.net 2012-03-06 07:49:24 CST --- Look at patch #84102 for a list of bugs:
This is one of the most important audio-related late pre-1.4 patches. It fixes bug #30071, bug #28856, allows to close bug #28723 and perhaps every other bug report about occasional or continuous crackling sound from ALSA, e.g. bug #28622, comment #34 or bug #28282.
Well, DSound still has issues on its own.
that doesn't mean they can't use something else instead.
WineXYZ.drv happens to use CTQ and doing so, uncovered a non-conformance in its implementation. The expected response is to become conforming, e.g. by applying the suggested patch or a similar one, not to suggest that you're waiting for an app author to complain directly about bad CTQ intervals and dismiss Wine-internal feedback and needs.
Please read http://www.winehq.org/pipermail/wine-devel/2012-March/094525.html for a summary of native w7 behaviour. It again proves that Wine is non-conforming to (Vista/w2k8/)w7 behaviour.
Well, major + minor -> normal as average :-) Anyway, I don't care. At one point in time, audio was considered an important goal for 1.4.0. I don't know if that's still the case, but either we use a few chances to fix some of audio prior to 1.4.0, or I stop wasting my time on Wine audio and go read a good book and sleep well at night, without worrying about what improvement to apply next.
http://bugs.winehq.org/show_bug.cgi?id=30071
Jörg Höhle hoehle@users.sourceforge.net changed:
What |Removed |Added ---------------------------------------------------------------------------- Attachment #39178|0 |1 is obsolete| |
--- Comment #5 from Jörg Höhle hoehle@users.sourceforge.net 2012-03-09 04:22:47 CST --- Created attachment 39261 --> http://bugs.winehq.org/attachment.cgi?id=39261 Check stability & callback running past DeleteTimerQueue
Here's the test I've used to assess the timer's (in)stability. The current patch to stabilize Wine was submitted here: http://www.winehq.org/pipermail/wine-patches/2012-March/112038.html
It also demonstrates another bug I found: Wine lets callbacks execute after DeleteTimerQueue! A fix was submitted too: http://www.winehq.org/pipermail/wine-patches/2012-March/112040.html
I'll submit a variation of the tests in a few days. They'll be less verbose, take less time in the default setting and instead of printing the average rate, they'll fail with Wine for as long as it doesn't stabilize its timer rate.
http://bugs.winehq.org/show_bug.cgi?id=30071
Michael Hampton error@ioerror.us changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |error@ioerror.us
http://bugs.winehq.org/show_bug.cgi?id=30071
Jörg Höhle hoehle@users.sourceforge.net changed:
What |Removed |Added ---------------------------------------------------------------------------- Fixed by SHA1| |2f0b93ca134ca68857bef36a3f2 | |a5cf8f620740a Status|NEW |RESOLVED Resolution| |FIXED
--- Comment #6 from Jörg Höhle hoehle@users.sourceforge.net 2013-03-02 16:02:03 CST --- The CTQ stabilisator patch is in wine-1.5.25, without the tests.
http://bugs.winehq.org/show_bug.cgi?id=30071
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #7 from Alexandre Julliard julliard@winehq.org 2013-03-15 14:46:05 CDT --- Closing bugs fixed in 1.5.26.