diff --git a/patches/dsound-Clear_Mixing_Buffer/0001-dsound-Clear-the-temporary-mixing-buffer-after-alloc.patch b/patches/dsound-Clear_Mixing_Buffer/0001-dsound-Clear-the-temporary-mixing-buffer-after-alloc.patch new file mode 100644 index 00000000..1d9b942e --- /dev/null +++ b/patches/dsound-Clear_Mixing_Buffer/0001-dsound-Clear-the-temporary-mixing-buffer-after-alloc.patch @@ -0,0 +1,37 @@ +From 28c420fc650438718b2fdb2c61e1a7188c404b90 Mon Sep 17 00:00:00 2001 +From: "Erich E. Hoover" +Date: Mon, 19 Dec 2016 14:17:23 -0700 +Subject: dsound: Clear the temporary mixing buffer after allocation. + +Signed-off-by: Erich E. Hoover +--- + dlls/dsound/mixer.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/dlls/dsound/mixer.c b/dlls/dsound/mixer.c +index 309c338cd10..880b29c43b2 100644 +--- a/dlls/dsound/mixer.c ++++ b/dlls/dsound/mixer.c +@@ -429,6 +429,9 @@ static void DSOUND_MixToTemporary(IDirectSoundBufferImpl *dsb, DWORD frames) + dsb->device->tmp_buffer = HeapAlloc(GetProcessHeap(), 0, size_bytes); + } + ++ if(dsb->put_aux == putieee32_sum) ++ memset(dsb->device->tmp_buffer, 0, dsb->device->tmp_buffer_len); ++ + cp_fields(dsb, frames, &dsb->freqAccNum); + + if (size_bytes > 0) { +@@ -506,9 +509,6 @@ static DWORD DSOUND_MixInBuffer(IDirectSoundBufferImpl *dsb, float *mix_buffer, + + /* Resample buffer to temporary buffer specifically allocated for this purpose, if needed */ + oldpos = dsb->sec_mixpos; +- +- if(dsb->put_aux == putieee32_sum) +- memset(dsb->device->tmp_buffer, 0, dsb->device->tmp_buffer_len); + DSOUND_MixToTemporary(dsb, frames); + ibuf = dsb->device->tmp_buffer; + +-- +2.11.0 + diff --git a/patches/dsound-Clear_Mixing_Buffer/definition b/patches/dsound-Clear_Mixing_Buffer/definition new file mode 100644 index 00000000..616763c3 --- /dev/null +++ b/patches/dsound-Clear_Mixing_Buffer/definition @@ -0,0 +1 @@ +Fixes: Clear the dsound mixing buffer after allocation diff --git a/patches/dsound-EAX/0001-dsound-Apply-filters-before-sound-is-multiplied-to-s.patch b/patches/dsound-EAX/0001-dsound-Apply-filters-before-sound-is-multiplied-to-s.patch index 124de4b4..f06e4e9f 100644 --- a/patches/dsound-EAX/0001-dsound-Apply-filters-before-sound-is-multiplied-to-s.patch +++ b/patches/dsound-EAX/0001-dsound-Apply-filters-before-sound-is-multiplied-to-s.patch @@ -1,4 +1,4 @@ -From ed0264f5193ecf9d7724be5de6c9bda17919105f Mon Sep 17 00:00:00 2001 +From b23019f93121d8a1a57912c4ca335fa1c534c8d7 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Sat, 28 Mar 2015 08:18:10 +0100 Subject: dsound: Apply filters before sound is multiplied to speakers. @@ -7,11 +7,11 @@ Based on a patch by Mark Harmstone. --- dlls/dsound/dsound.c | 1 + dlls/dsound/dsound_private.h | 4 +- - dlls/dsound/mixer.c | 104 ++++++++++++++++++++++++++++++------------- - 3 files changed, 77 insertions(+), 32 deletions(-) + dlls/dsound/mixer.c | 108 ++++++++++++++++++++++++++++++------------- + 3 files changed, 79 insertions(+), 34 deletions(-) diff --git a/dlls/dsound/dsound.c b/dlls/dsound/dsound.c -index 64bfbd3..d73610e 100644 +index 4d515adcaf3..65a00787098 100644 --- a/dlls/dsound/dsound.c +++ b/dlls/dsound/dsound.c @@ -233,6 +233,7 @@ static ULONG DirectSoundDevice_Release(DirectSoundDevice * device) @@ -23,10 +23,10 @@ index 64bfbd3..d73610e 100644 HeapFree(GetProcessHeap(), 0, device->cp_buffer); HeapFree(GetProcessHeap(), 0, device->buffer); diff --git a/dlls/dsound/dsound_private.h b/dlls/dsound/dsound_private.h -index 34bab65..f580915 100644 +index 8e1e2dafc7c..f22849fb0a2 100644 --- a/dlls/dsound/dsound_private.h +++ b/dlls/dsound/dsound_private.h -@@ -88,8 +88,8 @@ struct DirectSoundDevice +@@ -89,8 +89,8 @@ struct DirectSoundDevice int speaker_num[DS_MAX_CHANNELS]; int num_speakers; int lfe_channel; @@ -38,10 +38,10 @@ index 34bab65..f580915 100644 DSVOLUMEPAN volpan; diff --git a/dlls/dsound/mixer.c b/dlls/dsound/mixer.c -index a2fd768..db4235d 100644 +index 1a99eebf30c..5b4af70093f 100644 --- a/dlls/dsound/mixer.c +++ b/dlls/dsound/mixer.c -@@ -266,23 +266,22 @@ static inline float get_current_sample(const IDirectSoundBufferImpl *dsb, +@@ -278,23 +278,22 @@ static inline float get_current_sample(const IDirectSoundBufferImpl *dsb, return dsb->get(dsb, mixpos % dsb->buflen, channel); } @@ -70,7 +70,7 @@ index a2fd768..db4235d 100644 UINT channels = dsb->mix_channels; LONG64 freqAcc_start = *freqAccNum; -@@ -310,7 +309,7 @@ static UINT cp_fields_resample_lq(IDirectSoundBufferImpl *dsb, UINT count, LONG6 +@@ -322,7 +321,7 @@ static UINT cp_fields_resample_lq(IDirectSoundBufferImpl *dsb, UINT count, LONG6 float s1 = get_current_sample(dsb, idx, channel); float s2 = get_current_sample(dsb, idx + istride, channel); float result = s1 * cur_freqAcc2 + s2 * cur_freqAcc; @@ -79,7 +79,7 @@ index a2fd768..db4235d 100644 } } -@@ -318,11 +317,11 @@ static UINT cp_fields_resample_lq(IDirectSoundBufferImpl *dsb, UINT count, LONG6 +@@ -330,11 +329,11 @@ static UINT cp_fields_resample_lq(IDirectSoundBufferImpl *dsb, UINT count, LONG6 return max_ipos; } @@ -93,7 +93,7 @@ index a2fd768..db4235d 100644 LONG64 freqAcc_start = *freqAccNum; LONG64 freqAcc_end = freqAcc_start + count * dsb->freqAdjustNum; -@@ -383,7 +382,7 @@ static UINT cp_fields_resample_hq(IDirectSoundBufferImpl *dsb, UINT count, LONG6 +@@ -395,7 +394,7 @@ static UINT cp_fields_resample_hq(IDirectSoundBufferImpl *dsb, UINT count, LONG6 float* cache = &intermediate[channel * required_input + ipos]; for (j = 0; j < fir_used; j++) sum += fir_copy[j] * cache[j]; @@ -102,7 +102,7 @@ index a2fd768..db4235d 100644 } } -@@ -392,16 +391,17 @@ static UINT cp_fields_resample_hq(IDirectSoundBufferImpl *dsb, UINT count, LONG6 +@@ -404,16 +403,17 @@ static UINT cp_fields_resample_hq(IDirectSoundBufferImpl *dsb, UINT count, LONG6 return max_ipos; } @@ -124,7 +124,7 @@ index a2fd768..db4235d 100644 ipos = dsb->sec_mixpos + adv * dsb->pwfx->nBlockAlign; if (ipos >= dsb->buflen) { -@@ -431,6 +431,21 @@ static inline DWORD DSOUND_BufPtrDiff(DWORD buflen, DWORD ptr1, DWORD ptr2) +@@ -443,6 +443,21 @@ static inline DWORD DSOUND_BufPtrDiff(DWORD buflen, DWORD ptr1, DWORD ptr2) return buflen + ptr1 - ptr2; } } @@ -146,7 +146,7 @@ index a2fd768..db4235d 100644 /** * Mix at most the given amount of data into the allocated temporary buffer * of the given secondary buffer, starting from the dsb's first currently -@@ -446,32 +461,61 @@ static inline DWORD DSOUND_BufPtrDiff(DWORD buflen, DWORD ptr1, DWORD ptr2) +@@ -458,35 +473,64 @@ static inline DWORD DSOUND_BufPtrDiff(DWORD buflen, DWORD ptr1, DWORD ptr2) */ static void DSOUND_MixToTemporary(IDirectSoundBufferImpl *dsb, DWORD frames) { @@ -173,12 +173,21 @@ index a2fd768..db4235d 100644 + dsb->device->tmp_buffer_len = size_bytes; } +- if(dsb->put_aux == putieee32_sum) +- memset(dsb->device->tmp_buffer, 0, dsb->device->tmp_buffer_len); ++ if(dsb->put_aux == putieee32_sum) ++ memset(dsb->device->tmp_buffer, 0, dsb->device->tmp_buffer_len); + - cp_fields(dsb, frames, &dsb->freqAccNum); + if (using_filters) { + put = putieee32_dsp; + ostride = dsb->mix_channels * sizeof(float); + size_bytes = frames * ostride; -+ + +- if (size_bytes > 0) { +- for (i = 0; i < dsb->num_filters; i++) { +- if (dsb->filters[i].inplace) { +- hr = IMediaObjectInPlace_Process(dsb->filters[i].inplace, size_bytes, (BYTE*)dsb->device->tmp_buffer, 0, DMO_INPLACE_NORMAL); + if (dsb->device->dsp_buffer_len < size_bytes || !dsb->device->dsp_buffer) { + if (dsb->device->dsp_buffer) + dsb->device->dsp_buffer = HeapReAlloc(GetProcessHeap(), 0, dsb->device->dsp_buffer, size_bytes); @@ -188,10 +197,12 @@ index a2fd768..db4235d 100644 + } + } -- if (size_bytes > 0) { -- for (i = 0; i < dsb->num_filters; i++) { -- if (dsb->filters[i].inplace) { -- hr = IMediaObjectInPlace_Process(dsb->filters[i].inplace, size_bytes, (BYTE*)dsb->device->tmp_buffer, 0, DMO_INPLACE_NORMAL); +- if (FAILED(hr)) +- WARN("IMediaObjectInPlace_Process failed for filter %u\n", i); +- } else +- WARN("filter %u has no inplace object - unsupported\n", i); +- } +- } + cp_fields(dsb, put, ostride, frames, &dsb->freqAccNum); + + if (using_filters) { @@ -206,13 +217,7 @@ index a2fd768..db4235d 100644 + WARN("filter %u has no inplace object - unsupported\n", i); + } + } - -- if (FAILED(hr)) -- WARN("IMediaObjectInPlace_Process failed for filter %u\n", i); -- } else -- WARN("filter %u has no inplace object - unsupported\n", i); -- } -- } ++ + istride = ostride; + ostride = dsb->device->pwfx->nChannels * sizeof(float); + for (i = 0; i < frames; i++) { @@ -225,5 +230,5 @@ index a2fd768..db4235d 100644 static void DSOUND_MixerVol(const IDirectSoundBufferImpl *dsb, INT frames) -- -2.8.0 +2.11.0 diff --git a/patches/dsound-EAX/definition b/patches/dsound-EAX/definition index 85ed7831..f3bfc9a1 100644 --- a/patches/dsound-EAX/definition +++ b/patches/dsound-EAX/definition @@ -1,3 +1,4 @@ Fixes: Software support for Environmental Audio Extensions (EAX) Depends: dsound-Fast_Mixer Depends: dsound-Revert_Cleanup +Depends: dsound-Clear_Mixing_Buffer diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index eb26ffd1..ec45f05e 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -140,6 +140,7 @@ patch_enable_all () enable_ddraw_Write_Vtable="$1" enable_dinput_Initialize="$1" enable_dmusic_SynthPort_IKsControl="$1" + enable_dsound_Clear_Mixing_Buffer="$1" enable_dsound_EAX="$1" enable_dsound_Fast_Mixer="$1" enable_dsound_Revert_Cleanup="$1" @@ -611,6 +612,9 @@ patch_enable () dmusic-SynthPort_IKsControl) enable_dmusic_SynthPort_IKsControl="$2" ;; + dsound-Clear_Mixing_Buffer) + enable_dsound_Clear_Mixing_Buffer="$2" + ;; dsound-EAX) enable_dsound_EAX="$2" ;; @@ -2382,12 +2386,16 @@ if test "$enable_dxdiagn_GetChildContainer_Leaf_Nodes" -eq 1; then fi if test "$enable_dsound_EAX" -eq 1; then + if test "$enable_dsound_Clear_Mixing_Buffer" -gt 1; then + abort "Patchset dsound-Clear_Mixing_Buffer disabled, but dsound-EAX depends on that." + fi if test "$enable_dsound_Fast_Mixer" -gt 1; then abort "Patchset dsound-Fast_Mixer disabled, but dsound-EAX depends on that." fi if test "$enable_dsound_Revert_Cleanup" -gt 1; then abort "Patchset dsound-Revert_Cleanup disabled, but dsound-EAX depends on that." fi + enable_dsound_Clear_Mixing_Buffer=1 enable_dsound_Fast_Mixer=1 enable_dsound_Revert_Cleanup=1 fi @@ -3722,6 +3730,18 @@ if test "$enable_dmusic_SynthPort_IKsControl" -eq 1; then ) >> "$patchlist" fi +# Patchset dsound-Clear_Mixing_Buffer +# | +# | Modified files: +# | * dlls/dsound/mixer.c +# | +if test "$enable_dsound_Clear_Mixing_Buffer" -eq 1; then + patch_apply dsound-Clear_Mixing_Buffer/0001-dsound-Clear-the-temporary-mixing-buffer-after-alloc.patch + ( + echo '+ { "Erich E. Hoover", "dsound: Clear the temporary mixing buffer after allocation.", 1 },'; + ) >> "$patchlist" +fi + # Patchset dsound-Fast_Mixer # | # | This patchset fixes the following Wine bugs: @@ -3754,7 +3774,7 @@ fi # Patchset dsound-EAX # | # | This patchset has the following (direct or indirect) dependencies: -# | * dsound-Fast_Mixer, dsound-Revert_Cleanup +# | * dsound-Clear_Mixing_Buffer, dsound-Fast_Mixer, dsound-Revert_Cleanup # | # | Modified files: # | * dlls/dsound/Makefile.in, dlls/dsound/buffer.c, dlls/dsound/dsound.c, dlls/dsound/dsound_eax.h,