From 41f41a7c98a2cd8e4d063808628a11cad7ebdbd8 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Sat, 28 Mar 2015 21:38:50 +0100 Subject: [PATCH] Added patch to fix calculation of 3D sound source. --- README.md | 3 +- debian/changelog | 1 + ...ix-angle-to-sound-source-calculation.patch | 66 +++++++++++++++++ patches/dsound-3DSound/definition | 1 + patches/patchinstall.sh | 73 ++++++++++++------- 5 files changed, 116 insertions(+), 28 deletions(-) create mode 100644 patches/dsound-3DSound/0001-dsound-Fix-angle-to-sound-source-calculation.patch create mode 100644 patches/dsound-3DSound/definition diff --git a/README.md b/README.md index c2fad0b4..e21e4cd3 100644 --- a/README.md +++ b/README.md @@ -38,11 +38,12 @@ Wine. All those differences are also documented on the Included bug fixes and improvements =================================== -**Bugfixes and features included in the next upcoming release [7]:** +**Bugfixes and features included in the next upcoming release [8]:** * Add stubs for Power[Set|Clear]Request * Avoid spam of FIXME messages for PsLookupProcessByProcessId stub ([Wine Bug #36821](https://bugs.winehq.org/show_bug.cgi?id=36821)) * Don't return an error in WS_select when EINTR happens during timeout +* Fix calculation of 3D sound source ([Wine Bug #38041](https://bugs.winehq.org/show_bug.cgi?id=38041)) * Fix compatibility of Uplay with gnutls28 ([Wine Bug #38134](https://bugs.winehq.org/show_bug.cgi?id=38134)) * Fix handling of ANSI NTLM credentials ([Wine Bug #37063](https://bugs.winehq.org/show_bug.cgi?id=37063)) * Implement empty enumerator for IWiaDevMgr::EnumDeviceInfo ([Wine Bug #27775](https://bugs.winehq.org/show_bug.cgi?id=27775)) diff --git a/debian/changelog b/debian/changelog index 87da0c42..7dff1377 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,6 +7,7 @@ wine-staging (1.7.40) UNRELEASED; urgency=low * Added patch to fix compatibility of Uplay with gnutls28. * Added patches for Environmental Audio Extensions (EAX), pull request #311 from Mark Harmstone. * Added patch to fix return value of WS_select in case of EINTR during timeout. + * Added patch to fix calculation of 3D sound source. * Removed patch to fix regression causing black screen on startup (accepted upstream). * Removed patch to fix edge cases in TOOLTIPS_GetTipText (fixed upstream). * Removed patch for IConnectionPoint/INetworkListManagerEvents stub interface (accepted upstream). diff --git a/patches/dsound-3DSound/0001-dsound-Fix-angle-to-sound-source-calculation.patch b/patches/dsound-3DSound/0001-dsound-Fix-angle-to-sound-source-calculation.patch new file mode 100644 index 00000000..9a5f5ff0 --- /dev/null +++ b/patches/dsound-3DSound/0001-dsound-Fix-angle-to-sound-source-calculation.patch @@ -0,0 +1,66 @@ +From a0b63f4c0c9695606fe8466cb9574ebfb9230d7b Mon Sep 17 00:00:00 2001 +From: Stas Cymbalov +Date: Sun, 22 Mar 2015 18:22:49 +0300 +Subject: dsound: Fix angle to sound source calculation. + +This patch fixes incorrect sound positioning in dsound. +As of now, angle to sound source is calculated as angle between +vDistance and vOrientFront. +This leads to incorrect results for all sources that are not in the +same plane as speakers. +In extreme case: for sources directly above or below origin, angle is +calculated to -90 degrees, and they are played in the left speaker. + +This patch changes angle calculation: angle to sound source is +calculated as angle between vDistance and plane given by vectors +vOrientFront and vOrientTop. +--- + dlls/dsound/sound3d.c | 25 ++++++++++++++----------- + 1 file changed, 14 insertions(+), 11 deletions(-) + +diff --git a/dlls/dsound/sound3d.c b/dlls/dsound/sound3d.c +index 9a0226a..ffd4d45 100644 +--- a/dlls/dsound/sound3d.c ++++ b/dlls/dsound/sound3d.c +@@ -112,7 +112,6 @@ static inline D3DVALUE AngleBetweenVectorsRad (const D3DVECTOR *a, const D3DVECT + + cos = product/(la*lb); + angle = acos(cos); +- if (cos < 0.0f) { angle -= M_PI; } + TRACE("angle between (%f,%f,%f) and (%f,%f,%f) = %f radians (%f degrees)\n", a->x, a->y, a->z, b->x, + b->y, b->z, angle, RadToDeg(angle)); + return angle; +@@ -264,16 +263,20 @@ void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb) + else + { + vLeft = VectorProduct(&dsb->device->ds3dl.vOrientFront, &dsb->device->ds3dl.vOrientTop); +- flAngle = AngleBetweenVectorsRad(&dsb->device->ds3dl.vOrientFront, &vDistance); +- flAngle2 = AngleBetweenVectorsRad(&vLeft, &vDistance); +- +- /* AngleBetweenVectorsRad performs a dot product, which gives us the cosine of the angle +- * between two vectors. Unfortunately, because cos(theta) = cos(-theta), we've no idea from +- * this whether the sound is to our left or to our right. We have to perform another dot +- * product, with a vector at right angles to the initial one, to get the correct angle. +- * The angle should be between -180 degrees and 180 degrees. */ +- if (flAngle < 0.0f) { flAngle += M_PI; } +- if (flAngle2 > 0.0f) { flAngle = -flAngle; } ++ /* To calculate angle to sound source we need to: ++ * 1) Get angle between vDistance and a plane on which angle to sound source should be 0. ++ * Such a plane is given by vectors vOrientFront and vOrientTop, and angle between vector ++ * and a plane equals to M_PI_2 - angle between vector and normal to this plane (vLeft in this case). ++ * 2) Determine if the source is behind or in front of us by calculating angle between vDistance ++ * and vOrientFront. ++ */ ++ flAngle = AngleBetweenVectorsRad(&vLeft, &vDistance); ++ flAngle2 = AngleBetweenVectorsRad(&dsb->device->ds3dl.vOrientFront, &vDistance); ++ if (flAngle2 > M_PI_2) ++ flAngle = -flAngle; ++ flAngle -= M_PI_2; ++ if (flAngle < -M_PI) ++ flAngle += 2*M_PI; + } + TRACE("panning: Angle = %f rad, lPan = %d\n", flAngle, dsb->volpan.lPan); + +-- +2.3.3 + diff --git a/patches/dsound-3DSound/definition b/patches/dsound-3DSound/definition new file mode 100644 index 00000000..fdcd4a37 --- /dev/null +++ b/patches/dsound-3DSound/definition @@ -0,0 +1 @@ +Fixes: [38041] Fix calculation of 3D sound source diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index 1fbf292e..38679d53 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -94,6 +94,7 @@ patch_enable_all () enable_ddraw_Hotpatch="$1" enable_ddraw_d3d_execute_buffer="$1" enable_dinput_Events="$1" + enable_dsound_3DSound="$1" enable_dsound_EAX="$1" enable_dsound_Fast_Mixer="$1" enable_dxgi_GetDesc="$1" @@ -342,6 +343,9 @@ patch_enable () dinput-Events) enable_dinput_Events="$2" ;; + dsound-3DSound) + enable_dsound_3DSound="$2" + ;; dsound-EAX) enable_dsound_EAX="$2" ;; @@ -1797,6 +1801,21 @@ if test "$enable_dinput_Events" -eq 1; then ) >> "$patchlist" fi +# Patchset dsound-3DSound +# | +# | This patchset fixes the following Wine bugs: +# | * [#38041] Fix calculation of 3D sound source +# | +# | Modified files: +# | * dlls/dsound/sound3d.c +# | +if test "$enable_dsound_3DSound" -eq 1; then + patch_apply dsound-3DSound/0001-dsound-Fix-angle-to-sound-source-calculation.patch + ( + echo '+ { "Stas Cymbalov", "dsound: Fix angle to sound source calculation.", 1 },'; + ) >> "$patchlist" +fi + # Patchset dsound-Fast_Mixer # | # | This patchset fixes the following Wine bugs: @@ -1920,6 +1939,18 @@ if test "$enable_wined3d_CSMT_Helper" -eq 1; then ) >> "$patchlist" fi +# Patchset wined3d-UnhandledBlendFactor +# | +# | Modified files: +# | * dlls/wined3d/state.c +# | +if test "$enable_wined3d_UnhandledBlendFactor" -eq 1; then + patch_apply wined3d-UnhandledBlendFactor/0001-wined3d-Silence-repeated-Unhandled-blend-factor-0-me.patch + ( + echo '+ { "Sebastian Lackner", "wined3d: Silence repeated '\''Unhandled blend factor 0'\'' messages.", 1 },'; + ) >> "$patchlist" +fi + # Patchset wined3d-Multisampling # | # | This patchset fixes the following Wine bugs: @@ -1969,18 +2000,6 @@ if test "$enable_wined3d_Revert_PixelFormat" -eq 1; then ) >> "$patchlist" fi -# Patchset wined3d-UnhandledBlendFactor -# | -# | Modified files: -# | * dlls/wined3d/state.c -# | -if test "$enable_wined3d_UnhandledBlendFactor" -eq 1; then - patch_apply wined3d-UnhandledBlendFactor/0001-wined3d-Silence-repeated-Unhandled-blend-factor-0-me.patch - ( - echo '+ { "Sebastian Lackner", "wined3d: Silence repeated '\''Unhandled blend factor 0'\'' messages.", 1 },'; - ) >> "$patchlist" -fi - # Patchset wined3d-CSMT_Main # | # | This patchset fixes the following Wine bugs: @@ -3754,6 +3773,21 @@ if test "$enable_server_CreateProcess_ACLs" -eq 1; then ) >> "$patchlist" fi +# Patchset server-OpenProcess +# | +# | This patchset fixes the following Wine bugs: +# | * [#37087] Return an error when trying to open a terminated process +# | +# | Modified files: +# | * server/process.c, server/process.h +# | +if test "$enable_server_OpenProcess" -eq 1; then + patch_apply server-OpenProcess/0001-server-Return-error-when-opening-a-terminating-proce.patch + ( + echo '+ { "Michael Müller", "server: Return error when opening a terminating process.", 3 },'; + ) >> "$patchlist" +fi + # Patchset server-Misc_ACL # | # | This patchset fixes the following Wine bugs: @@ -3771,21 +3805,6 @@ if test "$enable_server_Misc_ACL" -eq 1; then ) >> "$patchlist" fi -# Patchset server-OpenProcess -# | -# | This patchset fixes the following Wine bugs: -# | * [#37087] Return an error when trying to open a terminated process -# | -# | Modified files: -# | * server/process.c, server/process.h -# | -if test "$enable_server_OpenProcess" -eq 1; then - patch_apply server-OpenProcess/0001-server-Return-error-when-opening-a-terminating-proce.patch - ( - echo '+ { "Michael Müller", "server: Return error when opening a terminating process.", 3 },'; - ) >> "$patchlist" -fi - # Patchset server-JobObjects # | # | This patchset fixes the following Wine bugs: