http://bugs.winehq.org/show_bug.cgi?id=28723
--- Comment #16 from Andrew Eikum aeikum@codeweavers.com 2011-11-02 08:47:38 CDT --- Created attachment 37257 --> http://bugs.winehq.org/attachment.cgi?id=37257 winealsa.drv: Don't set ALSA period time
Thanks for the nice logs and updates, Alexey. Sorry it's taken me so long to get to this bug.
I'll try to describe what I think is happening based on the log in comment 3. RAGE's audio thread runs in a loop polling IAudioClient::GetCurrentPadding(). When the current padding value is <= 441, it writes another packet (441 frames) of data. But, I think ALSA's period size is being set to something about the same size, so when GCP() is called, its value changes in chunks of approximately 441 frames. So you see patterns like this (trimmed for clarity):
007d:trace:alsa:AudioClient_GetCurrentPadding PCM state: 3, avail: 15927, pad: 441 007d:trace:alsa:AudioRenderClient_GetBuffer (0x48a9e70)->(441, 0x352de924) 007d:trace:alsa:AudioClient_GetCurrentPadding PCM state: 3, avail: 15927, pad: 441 007d:trace:alsa:AudioRenderClient_ReleaseBuffer (0x48a9e70)->(441, 0) 007d:trace:alsa:AudioClient_GetCurrentPadding PCM state: 3, avail: 15927, pad: 882 007d:trace:alsa:AudioClient_GetCurrentPadding PCM state: 3, avail: 15927, pad: 882 007d:trace:alsa:AudioClient_GetCurrentPadding PCM state: 3, avail: 15905, pad: 463 007d:trace:alsa:AudioClient_GetCurrentPadding PCM state: 3, avail: 16281, pad: 87 007d:trace:alsa:AudioRenderClient_GetBuffer (0x48a9e70)->(441, 0x352de924) 007d:trace:alsa:AudioClient_GetCurrentPadding PCM state: 4, avail: -32, pad: 0 007d:trace:alsa:AudioRenderClient_ReleaseBuffer (0x48a9e70)->(441, 0)
Notice the large skips in GCP() return values. When RAGE finally sees the <=441 value, ALSA will have run out of data by the time the GetBuffer() call completes.
I'm attaching a patch here which I hope fixes this. It just doesn't set the ALSA period time at all, letting ALSA figure out what it wants to use. I'm not sure about this in combination with fixes for Bug 28282, but it would be useful to know if this patch works for you.