[pulseaudio-discuss] [PATCH] Change the default fragment size to 5 ms
Andrew Eikum
aeikum at codeweavers.com
Thu Oct 23 12:44:48 PDT 2014
On Fri, Oct 24, 2014 at 12:38:16AM +0600, Alexander E. Patrakov wrote:
> 24.10.2014 00:08, Andrew Eikum wrote:
> >I have a patch in-hand which improves the current driver
> >significantly, but it isn't enough to fix the USB devices problem. If
> >someone wants to review the winealsa driver with the patch applied and
> >discuss solutions, let me know. I'd love to get this problem solved.
>
> If you send me the patch, I promise to have a look at it. But, see
> my other reply why there cannot be a full solution within the ALSA
> API.
>
I've attached the patch here. It's been a while since I've worked on
this, so I'm fuzzy on the details. It should apply on any recent Wine
version, including today's.
There's a comment above alsa_write_data() describing how the buffer is
laid out and what the offsets point to. alsa_write_data() is where we
actually send data to ALSA. AudioClient_Stop() and _Start() are where
the stream is rewound and paused. AudioClient_Initialize() is where
the device setup occurs. AudioClock_GetPosition() returns the number
of played frames.
Note that we explicitly toggle handle_underrun to TRUE in
make_handle_underrun_config(). Toggling this off does seem to have an
impact on USB devices. The underruns aren't fixed in either setting,
but it's worth playing with.
If I remember correctly, the problem with USB devices is that
snd_pcm_avail_update() updates too infrequently. To keep low latency,
we set up a buffer size of four ALSA periods (about 40ms, I think).
But, snd_pcm_avail_update() updates less frequently than that, so we
constantly hit underruns. Some Windows applications behave very badly
with large latencies.
I think the issue was more complicated than that, but I've forgotten
the details in the meantime...
I believe disabling BATCH mode on USB devices "fixes" everything with
this patch applied, but I presume there was a reason it was introduced
in the first place (see PA bug 66962). I could be wrong here, I never
totally understood the issue.
There are two important programs that I test with:
-Any well-behaved dsound program (I use the "American McGee's Alice
Demo"; "Marble Arena 1" is another good test program.)
-Microsoft Games's Pinball (This uses winmm very abusively, with lots
of starts and stops. Good at testing latency.)
Once the driver behaves well on those two, I usually run it through
the rest of my audio application gauntlet to look for issues.
Happy for feedback on any part of the driver.
Thanks,
Andrew
-------------- next part --------------
A non-text attachment was scrubbed...
Name: winealsa.patch
Type: text/x-diff
Size: 24452 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/pulseaudio-discuss/attachments/20141023/8fb94994/attachment.patch>
More information about the pulseaudio-discuss
mailing list