Added patch to clear the dsound mixing buffer after allocation.

This commit is contained in:
Sebastian Lackner
2017-01-08 20:09:24 +01:00
parent 024a141714
commit 252ee012a2
5 changed files with 92 additions and 28 deletions

View File

@@ -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 <sebastian@fds-team.de>
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

View File

@@ -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