Commit c76d5561 authored by Chris Robinson's avatar Chris Robinson Committed by Alexandre Julliard

quartz: Use a second-long DSound buffer for playback.

parent 996ced19
......@@ -64,6 +64,7 @@ typedef struct DSoundRenderImpl
LPDIRECTSOUND dsound;
LPDIRECTSOUNDBUFFER dsbuffer;
DWORD buf_size;
DWORD write_pos;
BOOL init;
......@@ -100,8 +101,6 @@ static HRESULT DSoundRender_InputPin_Construct(const PIN_INFO * pPinInfo, SAMPLE
}
#define DSBUFFERSIZE 8192
static HRESULT DSoundRender_CreateSoundBuffer(IBaseFilter * iface)
{
HRESULT hr;
......@@ -148,13 +147,15 @@ static HRESULT DSoundRender_CreateSoundBuffer(IBaseFilter * iface)
goto getout;
}
This->buf_size = format->nAvgBytesPerSec;
wav_fmt = *format;
wav_fmt.cbSize = 0;
memset(&buf_desc,0,sizeof(DSBUFFERDESC));
buf_desc.dwSize = sizeof(DSBUFFERDESC);
buf_desc.dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLPAN | DSBCAPS_CTRLFREQUENCY;
buf_desc.dwBufferBytes = DSBUFFERSIZE;
buf_desc.dwBufferBytes = This->buf_size;
buf_desc.lpwfxFormat = &wav_fmt;
hr = IDirectSound_CreateSoundBuffer(This->dsound, &buf_desc, &This->dsbuffer, NULL);
if (FAILED(hr)) {
......@@ -206,10 +207,10 @@ static HRESULT DSoundRender_SendSampleData(DSoundRenderImpl* This, LPBYTE data,
if (This->write_pos <= play_pos)
buf_free = play_pos-This->write_pos;
else
buf_free = DSBUFFERSIZE - This->write_pos + play_pos;
buf_free = This->buf_size - This->write_pos + play_pos;
/* Wait for enough of the buffer to empty before filling it */
if(buf_free < DSBUFFERSIZE/4)
if(buf_free < This->buf_size/4)
{
Sleep(10);
continue;
......@@ -233,7 +234,7 @@ static HRESULT DSoundRender_SendSampleData(DSoundRenderImpl* This, LPBYTE data,
size -= dwsize1 + dwsize2;
data += dwsize1 + dwsize2;
This->write_pos = (This->write_pos + dwsize1 + dwsize2) % DSBUFFERSIZE;
This->write_pos = (This->write_pos + dwsize1 + dwsize2) % This->buf_size;
} while (size && This->state == State_Running);
return hr;
......
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