dsound: Avoid division by zero when calculating Doppler shift.

This commit is contained in:
Anton Baskanov 2023-04-23 23:46:10 +07:00 committed by Alexandre Julliard
parent feaaa5bcc3
commit 64cdecc632
2 changed files with 4 additions and 1 deletions

View file

@ -298,7 +298,8 @@ void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb)
}
else if (!(dsb->ds3db_ds3db.vVelocity.x == dsb->device->ds3dl.vVelocity.x &&
dsb->ds3db_ds3db.vVelocity.y == dsb->device->ds3dl.vVelocity.y &&
dsb->ds3db_ds3db.vVelocity.z == dsb->device->ds3dl.vVelocity.z))
dsb->ds3db_ds3db.vVelocity.z == dsb->device->ds3dl.vVelocity.z) &&
!(vDistance.x == 0.0f && vDistance.y == 0.0f && vDistance.z == 0.0f))
{
/* calculate length of ds3db_ds3db.vVelocity component which causes Doppler Effect
NOTE: if buffer moves TOWARDS the listener, its velocity component is NEGATIVE

View file

@ -1439,6 +1439,8 @@ static void test_doppler(GUID *guid, BOOL play)
check_doppler(dsound, listener, play, DS3DMODE_NORMAL, 0, 0, 1, -90, 22050, 29400);
check_doppler(dsound, listener, play, DS3DMODE_NORMAL, 0, 0, 1, 90, 22050, 17640);
check_doppler(dsound, listener, play, DS3DMODE_NORMAL, 0, 0, 0, -90, 22050, 22050);
IDirectSound3DListener_Release(listener);
ref = IDirectSoundBuffer_Release(primary);
ok(!ref, "Got outstanding refcount %ld.\n", ref);