Module: wine
Branch: oldstable
Commit: a2802c8ffb2880e3f06fe460f84b2f60979855b5
URL: http://source.winehq.org/git/wine.git/?a=commit;h=a2802c8ffb2880e3f06fe460f…
Author: Andrew Eikum <aeikum(a)codeweavers.com>
Date: Wed Dec 28 14:02:54 2016 -0600
dsound: Fix rolloff factor calculation.
We should treat the rolloff factor as a factor of the distance of the
buffer. For example, a rolloff factor of 2 should treat the buffer as if
it were twice as far away from the listener as it is.
The previous calculation would instead double the decibels of
attenuation.
Signed-off-by: Andrew Eikum <aeikum(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
(cherry picked from commit 1671a83f55bee46ee57cc0c8869e943d67f14ea5)
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/dsound/sound3d.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/dlls/dsound/sound3d.c b/dlls/dsound/sound3d.c
index eb01881..1afcb8c 100644
--- a/dlls/dsound/sound3d.c
+++ b/dlls/dsound/sound3d.c
@@ -206,9 +206,11 @@ void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb)
if (flDistance < dsb->ds3db_ds3db.flMinDistance)
flDistance = dsb->ds3db_ds3db.flMinDistance;
+
+ flDistance = dsb->ds3db_ds3db.flMinDistance + (flDistance - dsb->ds3db_ds3db.flMinDistance) * dsb->device->ds3dl.flRolloffFactor;
/* attenuation proportional to the distance squared, converted to millibels as in lVolume*/
- lVolume -= log10(flDistance/dsb->ds3db_ds3db.flMinDistance * flDistance/dsb->ds3db_ds3db.flMinDistance)*1000 * dsb->device->ds3dl.flRolloffFactor;
+ lVolume -= log10(flDistance/dsb->ds3db_ds3db.flMinDistance * flDistance/dsb->ds3db_ds3db.flMinDistance)*1000;
TRACE("dist. att: Distance = %f, MinDistance = %f => adjusting volume %d to %f\n", flDistance, dsb->ds3db_ds3db.flMinDistance, dsb->ds3db_lVolume, lVolume);
/* conning */