Dang. Forgot to attach. --- Here's another patch to fix the clicking noise. Once again apply over the top.
With this one, I think everything should be at least as good as it was with my very first patch. (Plus the full device buffer will be used if UseDirectHW="y", which should reduce underrun problems). Davin On Thu, 3 Nov 2005 18:42:50 +1100 Davin McCall <[EMAIL PROTECTED]> wrote: > Thanks for that - > > There was at least one problem with the patch. I've attached a fix for that > (apply over the top of the previous one). > > I don't get buffer underruns in my own testing, but I do get an annoying > clicking noise every so often (seems to be when streaming buffers wrap from > the end back to the start). I think that's a mixer issue rather than an ALSA > driver issue however as it occurs with OSS as well as ALSA. At the moment, > I'm focusing primarily on the ALSA driver issues. > > I'd be grateful if you could try this modification (best results should be > with full acceleration, and UseDirectHW set to "y"). > > Davin > > > > On Thu, 03 Nov 2005 02:18:48 +0000 > Randall Walls <[EMAIL PROTECTED]> wrote: > > > Tested again with BattleZone2 and I'm still getting what sounds like > > serious buffer underruns with this new patch. This one seemed to 'skip' > > a bit more too, depending on action taking place on screen, but that > > could be due to other issues (system load etc...). Running with Alsa as > > the audio driver and full hardware acceleration, no emulation. Tested > > both with and without the registry key set, and stuttering and the > > looping sounds actually seemed to get worse WITH the key. Switched to > > OSS driver to test (this would be Alsa's OSS emulation) and I still get > > the repeating sounds but some of the other issues are better. > > BattleZone2 does have a demo that can still be found online, and there > > was a patch on the list not too long ago to get the demo up and running. > > > > Again, let me know if any traces would be benneficial. > > > > Randall Walls > > > > >
--- wine-0.9-progressive/dlls/dsound/mixer.c Thu Nov 3 09:53:15 2005 +++ wine-0.9/dlls/dsound/mixer.c Thu Nov 3 20:47:49 2005 @@ -277,7 +277,7 @@ ibp += iAdvance; ilen += iAdvance; obp += oAdvance; - if (ibp >= (BYTE *)(dsb->buffer->memory + dsb->buflen)) { + if (ibp >= (BYTE *)dsb->buffer->memory + dsb->buflen) { if (wrap) { ibp = dsb->buffer->memory; /* wrap */ } else { @@ -307,14 +307,14 @@ ULONG adv = (dsb->freqAcc>>DSOUND_FREQSHIFT) * iAdvance; dsb->freqAcc &= (1<<DSOUND_FREQSHIFT)-1; ipos += adv; - if (ipos > dsb->buflen) { + ilen += adv; + if (ipos >= dsb->buflen) { if (wrap) { ipos -= dsb->buflen; } else { break; } } - ilen += adv; } } i *= oAdvance; @@ -461,20 +461,27 @@ return 0; blockalign = dsb->dsound->device->pwfx->nBlockAlign; - adjusted_remainder = MulDiv(dsb->dsound->device->pwfx->nAvgBytesPerSec, secondary_remainder, dsb->nAvgBytesPerSec) + blockalign; + adjusted_remainder = MulDiv(dsb->dsound->device->pwfx->nAvgBytesPerSec, secondary_remainder, dsb->nAvgBytesPerSec); adjusted_remainder -= adjusted_remainder % blockalign; + if (adjusted_remainder == 0) { + /* The adjusted remainder must be at least one sample, + * otherwise we will never reach the end of the + * secondary buffer, as there will perpetually be a + * fractional remainder */ + adjusted_remainder = blockalign; + } + assert(adjusted_remainder >= 0); TRACE("secondary_remainder = %d, adjusted_remainder = %d, len = %d\n", secondary_remainder, adjusted_remainder, len); if (adjusted_remainder < len) { TRACE("clipping len to remainder of secondary buffer\n"); len = adjusted_remainder; } - if (len == 0) - return 0; } if (len % dsb->dsound->device->pwfx->nBlockAlign) { + /* This shouldn't ever happen anymore */ INT nBlockAlign = dsb->dsound->device->pwfx->nBlockAlign; ERR("length not a multiple of block size, len = %d, block size = %d\n", len, nBlockAlign); len = (len / nBlockAlign) * nBlockAlign; /* data alignment */