mirror of
https://github.com/reactos/wine.git
synced 2024-11-30 23:20:56 +00:00
dsound: Remove unconditional memory allocation in mixing thread.
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
5b0914ece9
commit
db316c1243
@ -234,6 +234,7 @@ static ULONG DirectSoundDevice_Release(DirectSoundDevice * device)
|
||||
IAudioStreamVolume_Release(device->volume);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, device->tmp_buffer);
|
||||
HeapFree(GetProcessHeap(), 0, device->cp_buffer);
|
||||
HeapFree(GetProcessHeap(), 0, device->buffer);
|
||||
RtlDeleteResource(&device->buffer_list_lock);
|
||||
device->mixlock.DebugInfo->Spare[0] = 0;
|
||||
|
@ -87,8 +87,8 @@ struct DirectSoundDevice
|
||||
int speaker_num[DS_MAX_CHANNELS];
|
||||
int num_speakers;
|
||||
int lfe_channel;
|
||||
float *tmp_buffer;
|
||||
DWORD tmp_buffer_len;
|
||||
float *tmp_buffer, *cp_buffer;
|
||||
DWORD tmp_buffer_len, cp_buffer_len;
|
||||
|
||||
DSVOLUMEPAN volpan;
|
||||
|
||||
|
@ -292,18 +292,29 @@ static UINT cp_fields_resample(IDirectSoundBufferImpl *dsb, UINT count, LONG64 *
|
||||
|
||||
UINT fir_cachesize = (fir_len + dsbfirstep - 2) / dsbfirstep;
|
||||
UINT required_input = max_ipos + fir_cachesize;
|
||||
float *intermediate, *fir_copy, *itmp;
|
||||
|
||||
float* intermediate = HeapAlloc(GetProcessHeap(), 0,
|
||||
sizeof(float) * required_input * channels);
|
||||
DWORD len = required_input * channels;
|
||||
len += fir_cachesize;
|
||||
len *= sizeof(float);
|
||||
|
||||
if (!dsb->device->cp_buffer) {
|
||||
dsb->device->cp_buffer = HeapAlloc(GetProcessHeap(), 0, len);
|
||||
dsb->device->cp_buffer_len = len;
|
||||
} else if (len > dsb->device->cp_buffer_len) {
|
||||
dsb->device->cp_buffer = HeapReAlloc(GetProcessHeap(), 0, dsb->device->cp_buffer, len);
|
||||
dsb->device->cp_buffer_len = len;
|
||||
}
|
||||
|
||||
fir_copy = dsb->device->cp_buffer;
|
||||
intermediate = fir_copy + fir_cachesize;
|
||||
|
||||
float* fir_copy = HeapAlloc(GetProcessHeap(), 0,
|
||||
sizeof(float) * fir_cachesize);
|
||||
|
||||
/* Important: this buffer MUST be non-interleaved
|
||||
* if you want -msse3 to have any effect.
|
||||
* This is good for CPU cache effects, too.
|
||||
*/
|
||||
float* itmp = intermediate;
|
||||
itmp = intermediate;
|
||||
for (channel = 0; channel < channels; channel++)
|
||||
for (i = 0; i < required_input; i++)
|
||||
*(itmp++) = get_current_sample(dsb,
|
||||
@ -338,9 +349,6 @@ static UINT cp_fields_resample(IDirectSoundBufferImpl *dsb, UINT count, LONG64 *
|
||||
|
||||
*freqAccNum = freqAcc_end % dsb->freqAdjustDen;
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, fir_copy);
|
||||
HeapFree(GetProcessHeap(), 0, intermediate);
|
||||
|
||||
return max_ipos;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user