Andrew Eikum : dsound: Don't use IAudioClock:: GetPosition to determine buffer fullness.
Alexandre Julliard
julliard at winehq.org
Wed May 16 14:22:39 CDT 2012
Module: wine
Branch: master
Commit: 1cc9ecb558e09a94e1b92331ca132634e8dac8f9
URL: http://source.winehq.org/git/wine.git/?a=commit;h=1cc9ecb558e09a94e1b92331ca132634e8dac8f9
Author: Andrew Eikum <aeikum at codeweavers.com>
Date: Tue May 15 14:41:24 2012 -0500
dsound: Don't use IAudioClock::GetPosition to determine buffer fullness.
---
dlls/dsound/dsound_private.h | 1 -
dlls/dsound/mixer.c | 29 ++++++++++++++---------------
dlls/dsound/primary.c | 2 +-
3 files changed, 15 insertions(+), 17 deletions(-)
diff --git a/dlls/dsound/dsound_private.h b/dlls/dsound/dsound_private.h
index 1d43c5a..45c8c5d 100644
--- a/dlls/dsound/dsound_private.h
+++ b/dlls/dsound/dsound_private.h
@@ -83,7 +83,6 @@ struct DirectSoundDevice
DWORD priolevel;
PWAVEFORMATEX pwfx;
UINT timerID, playing_offs_bytes, in_mmdev_bytes, prebuf, helfrags;
- UINT64 last_pos_bytes;
DWORD fraglen;
LPBYTE buffer;
DWORD writelead, buflen, state, playpos, mixpos;
diff --git a/dlls/dsound/mixer.c b/dlls/dsound/mixer.c
index 06e5773..fed9165 100644
--- a/dlls/dsound/mixer.c
+++ b/dlls/dsound/mixer.c
@@ -667,8 +667,7 @@ static void DSOUND_WaveQueue(DirectSoundDevice *device, BOOL force)
*/
static void DSOUND_PerformMix(DirectSoundDevice *device)
{
- UINT64 clock_pos, clock_freq, pos_bytes;
- UINT delta_frags;
+ UINT32 pad, to_mix_frags, to_mix_bytes;
HRESULT hr;
TRACE("(%p)\n", device);
@@ -676,28 +675,28 @@ static void DSOUND_PerformMix(DirectSoundDevice *device)
/* **** */
EnterCriticalSection(&device->mixlock);
- hr = IAudioClock_GetFrequency(device->clock, &clock_freq);
+ hr = IAudioClient_GetCurrentPadding(device->client, &pad);
if(FAILED(hr)){
- WARN("GetFrequency failed: %08x\n", hr);
- LeaveCriticalSection(&device->mixlock);
+ WARN("GetCurrentPadding failed: %08x\n", hr);
+ LeaveCriticalSection(&device->mixlock);
return;
}
- hr = IAudioClock_GetPosition(device->clock, &clock_pos, NULL);
- if(FAILED(hr)){
- WARN("GetCurrentPadding failed: %08x\n", hr);
- LeaveCriticalSection(&device->mixlock);
+ to_mix_frags = device->prebuf - (pad * device->pwfx->nBlockAlign + device->fraglen - 1) / device->fraglen;
+
+ if(to_mix_frags == 0){
+ /* nothing to do! */
+ LeaveCriticalSection(&device->mixlock);
return;
}
- pos_bytes = (clock_pos * device->pwfx->nSamplesPerSec * device->pwfx->nBlockAlign) / clock_freq;
+ to_mix_bytes = to_mix_frags * device->fraglen;
- delta_frags = (pos_bytes - device->last_pos_bytes) / device->fraglen;
- if(delta_frags > 0){
- device->playing_offs_bytes += delta_frags * device->fraglen;
+ if(device->in_mmdev_bytes > 0){
+ DWORD delta_bytes = min(to_mix_bytes, device->in_mmdev_bytes);
+ device->in_mmdev_bytes -= delta_bytes;
+ device->playing_offs_bytes += delta_bytes;
device->playing_offs_bytes %= device->buflen;
- device->in_mmdev_bytes -= delta_frags * device->fraglen;
- device->last_pos_bytes = pos_bytes - (pos_bytes % device->fraglen);
}
if (device->priolevel != DSSCL_WRITEPRIMARY) {
diff --git a/dlls/dsound/primary.c b/dlls/dsound/primary.c
index b3b77f9..8da12e2 100644
--- a/dlls/dsound/primary.c
+++ b/dlls/dsound/primary.c
@@ -196,7 +196,7 @@ static HRESULT DSOUND_PrimaryOpen(DirectSoundDevice *device)
FillMemory(device->buffer, device->buflen, (device->pwfx->wBitsPerSample == 8) ? 128 : 0);
FillMemory(device->mix_buffer, device->mix_buffer_len, 0);
- device->last_pos_bytes = device->playing_offs_bytes = device->in_mmdev_bytes = device->playpos = device->mixpos = 0;
+ device->playing_offs_bytes = device->in_mmdev_bytes = device->playpos = device->mixpos = 0;
return DS_OK;
}
More information about the wine-cvs
mailing list