Commit db316c12 authored by Maarten Lankhorst's avatar Maarten Lankhorst Committed by Alexandre Julliard

dsound: Remove unconditional memory allocation in mixing thread.

parent 5b0914ec
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment