http://bugs.winehq.org/show_bug.cgi?id=28723
--- Comment #78 from Alexey Loukianov mooroon2@mail.ru 2011-12-09 02:02:49 CST --- Took another - now more thorough - look at latest path. Here are two minor remarks about this section of the code:
+ else if(err<0 || delay_frames > position - This->last_pos_frames) + /* Pulse bug: after an underrun, despite recovery, avail_frames + * may be larger than alsa_bufsize_frames, as if cumulating frames. */
a) Signess issue. position and last_pos_frames are both unsigned, wouldn't we hit an "undeflow" with flipping to a huge numbers (due to sign bit treated as a part of unsigned value) in case position is less than last_pos_frames?
b) IMO aside from possible signess issues it'd be better to rewrite comparison to this:
+ else if(err<0 || This->last_pos_frames > position - delay_frames)
In this form it'd be obvious from a first glance that we're clamping position here to be at least last_pos_frames.
c) In comment you write about avail_frames which is not used for calculations in surrounding code. Does the same bug affect delay_frames as well?