quartz/dsoundrender: Don't let writepos advance past playpos.

Fixes audio stuttering during video playback in multiple games (e.g.
Commandos 2, Alien Nations, Dino Crisis Demo).

Signed-off-by: Anton Baskanov <baskanov@gmail.com>
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Anton Baskanov 2021-04-26 09:51:23 +07:00 committed by Alexandre Julliard
parent 56b9a72f64
commit 9b30d09282
2 changed files with 2 additions and 5 deletions

View file

@ -149,7 +149,6 @@ static void DSoundRender_UpdatePositions(struct dsound_render *This, DWORD *seqw
static HRESULT DSoundRender_GetWritePos(struct dsound_render *This,
DWORD *ret_writepos, REFERENCE_TIME write_at, DWORD *pfree, DWORD *skip)
{
WAVEFORMATEX *wfx = (WAVEFORMATEX *)This->sink.pin.mt.pbFormat;
DWORD writepos, min_writepos, playpos;
REFERENCE_TIME max_lag = 50 * 10000;
REFERENCE_TIME cur, writepos_t, delta_t;
@ -212,10 +211,8 @@ static HRESULT DSoundRender_GetWritePos(struct dsound_render *This,
*ret_writepos = (min_writepos + aheadbytes) % This->buf_size;
}
end:
if (playpos > *ret_writepos)
if (playpos >= *ret_writepos)
*pfree = playpos - *ret_writepos;
else if (playpos == *ret_writepos)
*pfree = This->buf_size - wfx->nBlockAlign;
else
*pfree = This->buf_size + playpos - *ret_writepos;
if (time_from_pos(This, This->buf_size - *pfree) >= DSoundRenderer_Max_Fill) {

View file

@ -737,7 +737,7 @@ static HRESULT send_frame(IMemInputPin *sink)
params->sink = sink;
params->sample = sample;
thread = CreateThread(NULL, 0, frame_thread, params, 0, NULL);
ret = WaitForSingleObject(thread, 500);
ret = WaitForSingleObject(thread, 2000);
todo_wine_if (ret) ok(!ret, "Wait failed.\n");
GetExitCodeThread(thread, &ret);
CloseHandle(thread);