2010-09-01 20:06, pl bossart skrev: >>> Probably either one will work, but if we're about to release 0.9.22 >>> (heard something from Lennart yet?), I suggest we go with my version for >>> 0.9.22 as that one is the least invasive (only touches non-tsched >>> devices), and keep Pierre's version in master. >> >> Sounds reasonable. Pierre, what's your take? > > That would mean an additional post-release patch for tsched devices. I > am lazy and would prefer a one-stop fix. I don't care if this is > David's or mine, as long as the solution works for both cases. > The only real difference is the bytes/ms parameter. Although ms are > more intuitive, the bytes makes more sense from a hardware point of > view. If you pass a parameter in ms, there might be cases where the > actual number of bytes is lower than the DMA burst, it'll depend on > what frequency the sink operates at. There are some cases where > alsa-sink works at 8kHz (BT-SCO) or 48kHz (all other cases), a 6x > variability in the rewind behavior is difficult to handle.
Fair enough, how about the attached compromise (untested)? If you then would like to turn the define of dma_rewind_margin_bytes into a parameter, that should be fairly simple. -- David Henningsson, Canonical Ltd. http://launchpad.net/~diwic
>From 5ae6c880e20adfa0f372f2caf293e70253651c5a Mon Sep 17 00:00:00 2001 From: David Henningsson <david.hennings...@canonical.com> Date: Thu, 2 Sep 2010 08:22:36 +0200 Subject: [PATCH] ALSA: Fix calculation of rewind margins For non-tsched devices, use 20 ms as a default rewind margin. Also make sure that we have at least 256 bytes as rewind margin for all devices, to avoid problems with DMA controllers. Signed-off-by: David Henningsson <david.hennings...@canonical.com> --- src/modules/alsa/alsa-sink.c | 13 ++++++++++++- 1 files changed, 12 insertions(+), 1 deletions(-) diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c index a253cc5..097bb20 100644 --- a/src/modules/alsa/alsa-sink.c +++ b/src/modules/alsa/alsa-sink.c @@ -63,6 +63,9 @@ #define DEFAULT_DEVICE "default" +#define NON_TSCHED_REWIND_MARGIN_USEC (20*PA_USEC_PER_MSEC) /* 20ms -- Default rewind margin for non-tsched devices */ +#define DMA_REWIND_MARGIN_BYTES (256) /* Make sure we're always have a rewind margin of at least 256 bytes - to avoid problems with some DMA controllers */ + #define DEFAULT_TSCHED_BUFFER_USEC (2*PA_USEC_PER_SEC) /* 2s -- Overall buffer size */ #define DEFAULT_TSCHED_WATERMARK_USEC (20*PA_USEC_PER_MSEC) /* 20ms -- Fill up when only this much is left in the buffer */ @@ -1309,7 +1312,15 @@ static int process_rewind(struct userdata *u) { return -1; } - unused_nbytes = u->tsched_watermark + (size_t) unused * u->frame_size; + + if (u->use_tsched) + unused_nbytes = u->tsched_watermark; + else + unused_nbytes = pa_usec_to_bytes(NON_TSCHED_REWIND_MARGIN_USEC, &u->sink->sample_spec); + if (unused_nbytes < DMA_REWIND_MARGIN_BYTES) + unused_nbytes = DMA_REWIND_MARGIN_BYTES; + + unused_nbytes += (size_t) unused * u->frame_size; if (u->hwbuf_size > unused_nbytes) limit_nbytes = u->hwbuf_size - unused_nbytes; -- 1.7.0.4
_______________________________________________ pulseaudio-discuss mailing list pulseaudio-discuss@mail.0pointer.de https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss