The tests aren't really tested though (they partially require interactive mode and they caused lag issues on one person's machine).
-- v3: dsound/tests: Add NaN tests for floating-point 3D functions.
From: Aida Jonikienė aidas957@gmail.com
GTA San Andreas calls these functions with NaN positions under certain circumstances which eventually results in dwTotalAmpFactor value being really high (and causing extremely loud audio output). --- dlls/dsound/sound3d.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/dlls/dsound/sound3d.c b/dlls/dsound/sound3d.c index 3fa9ff6801f..e9c69ae7193 100644 --- a/dlls/dsound/sound3d.c +++ b/dlls/dsound/sound3d.c @@ -703,6 +703,9 @@ static HRESULT WINAPI IDirectSound3DBufferImpl_SetPosition(IDirectSound3DBuffer
TRACE("setting: Position vector = (%f,%f,%f); dwApply = %ld\n", x, y, z, dwApply);
+ if (isnan(x) || isnan(y) || isnan(z)) + return DSERR_INVALIDPARAM; + AcquireSRWLockExclusive(&This->lock);
This->ds3db_ds3db.vPosition.x = x; @@ -961,6 +964,11 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_SetOrientation(IDirectSound3DLi
TRACE("setting: Front vector = (%f,%f,%f); Top vector = (%f,%f,%f); dwApply = %ld\n", xFront, yFront, zFront, xTop, yTop, zTop, dwApply); + + if (isnan(xFront) || isnan(yFront) || isnan(zFront) + || isnan(xTop) || isnan(yTop) || isnan(zTop)) + return DSERR_INVALIDPARAM; + This->device->ds3dl.vOrientFront.x = xFront; This->device->ds3dl.vOrientFront.y = yFront; This->device->ds3dl.vOrientFront.z = zFront; @@ -982,6 +990,10 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_SetPosition(IDirectSound3DListe IDirectSoundBufferImpl *This = impl_from_IDirectSound3DListener(iface);
TRACE("setting: Position vector = (%f,%f,%f); dwApply = %ld\n", x, y, z, dwApply); + + if (isnan(x) || isnan(y) || isnan(z)) + return DSERR_INVALIDPARAM; + This->device->ds3dl.vPosition.x = x; This->device->ds3dl.vPosition.y = y; This->device->ds3dl.vPosition.z = z;
From: Aida Jonikienė aidas957@gmail.com
--- dlls/dsound/tests/ds3d.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
diff --git a/dlls/dsound/tests/ds3d.c b/dlls/dsound/tests/ds3d.c index 9c65f674b3b..ddd79db3907 100644 --- a/dlls/dsound/tests/ds3d.c +++ b/dlls/dsound/tests/ds3d.c @@ -669,6 +669,16 @@ void test_buffer(LPDIRECTSOUND dso, LPDIRECTSOUNDBUFFER *dsbo, buffer_param.vPosition.x,buffer_param.vPosition.y, buffer_param.vPosition.z,DS3D_IMMEDIATE); ok(rc==DS_OK,"IDirectSound3dBuffer_SetPosition() failed: %08lx\n", rc); + rc=IDirectSound3DBuffer_SetPosition(buffer, + NAN,0,0,DS3D_IMMEDIATE); + ok(rc==DSERR_INVALIDPARAM,"IDirectSound3dBuffer_SetPosition() returned %08lx\n", rc); + rc=IDirectSound3DBuffer_SetPosition(buffer, + 0,NAN,0,DS3D_IMMEDIATE); + ok(rc==DSERR_INVALIDPARAM,"IDirectSound3dBuffer_SetPosition() returned %08lx\n", rc); + rc=IDirectSound3DBuffer_SetPosition(buffer, + 0,0,NAN,DS3D_IMMEDIATE); + ok(rc==DSERR_INVALIDPARAM,"IDirectSound3dBuffer_SetPosition() returned %08lx\n", rc); + } } /* Check the sound duration was within 10% of the expected value */ @@ -1350,6 +1360,24 @@ static void check_doppler(IDirectSound *dsound, IDirectSound3DListener *listener ok(hr == S_OK, "Got hr %#lx.\n", hr); hr = IDirectSound3DListener_SetVelocity(listener, 0, 0, 0, DS3D_DEFERRED); ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirectSound3DListener_SetPosition(listener, NAN, 0, 0, DS3D_DEFERRED); + ok(hr == DSERR_INVALIDPARAM, "Got hr %#lx.\n", hr); + hr = IDirectSound3DListener_SetPosition(listener, 0, NAN, 0, DS3D_DEFERRED); + ok(hr == DSERR_INVALIDPARAM, "Got hr %#lx.\n", hr); + hr = IDirectSound3DListener_SetPosition(listener, 0, 0, NAN, DS3D_DEFERRED); + ok(hr == DSERR_INVALIDPARAM, "Got hr %#lx.\n", hr); + hr = IDirectSound3DListener_SetOrientation(listener, NAN, 0, 0, 0, 0, 0, DS3D_DEFERRED); + ok(hr == DSERR_INVALIDPARAM, "Got hr %#lx.\n", hr); + hr = IDirectSound3DListener_SetOrientation(listener, 0, NAN, 0, 0, 0, 0, DS3D_DEFERRED); + ok(hr == DSERR_INVALIDPARAM, "Got hr %#lx.\n", hr); + hr = IDirectSound3DListener_SetOrientation(listener, 0, 0, NAN, 0, 0, 0, DS3D_DEFERRED); + ok(hr == DSERR_INVALIDPARAM, "Got hr %#lx.\n", hr); + hr = IDirectSound3DListener_SetOrientation(listener, 0, 0, 0, NAN, 0, 0, DS3D_DEFERRED); + ok(hr == DSERR_INVALIDPARAM, "Got hr %#lx.\n", hr); + hr = IDirectSound3DListener_SetOrientation(listener, 0, 0, 0, 0, NAN, 0, DS3D_DEFERRED); + ok(hr == DSERR_INVALIDPARAM, "Got hr %#lx.\n", hr); + hr = IDirectSound3DListener_SetOrientation(listener, 0, 0, 0, 0, 0, NAN, DS3D_DEFERRED); + ok(hr == DSERR_INVALIDPARAM, "Got hr %#lx.\n", hr); hr = IDirectSound3DBuffer_SetPosition(buffer_3d, 0, 1, 0, DS3D_DEFERRED); ok(hr == S_OK, "Got hr %#lx.\n", hr); hr = IDirectSound3DBuffer_SetVelocity(buffer_3d, 0, -60, 0, DS3D_DEFERRED);
On Sat Nov 23 08:00:56 2024 +0000, Aida Jonikienė wrote:
changed this line in [version 3 of the diff](/wine/wine/-/merge_requests/6289/diffs?diff_id=145056&start_sha=53a4393d03270c46d1a62284d8f08d92348c476b#3edb4f3c85c6c9f2b5511c6e5295a598c0f8a9ad_673_673)
For some reason GitLab didn't notify me about this comment (but this should be fixed now)
On Sat Nov 23 08:00:57 2024 +0000, Aida Jonikienė wrote:
changed this line in [version 3 of the diff](/wine/wine/-/merge_requests/6289/diffs?diff_id=145056&start_sha=53a4393d03270c46d1a62284d8f08d92348c476b#3edb4f3c85c6c9f2b5511c6e5295a598c0f8a9ad_1359_1379)
Ditto
The TestBot tests reveal some interesting results (so I should find a better approach instead of returning failure)