quartz: Don't fill the dsound buffer with small amounts.

This commit is contained in:
Chris Robinson 2007-03-30 03:13:54 -07:00 committed by Alexandre Julliard
parent 7a837e5386
commit 4eea356e2d

View File

@ -203,13 +203,13 @@ static HRESULT DSoundRender_SendSampleData(DSoundRenderImpl* This, LPBYTE data,
ERR("Error GetCurrentPosition: %x\n", hr); ERR("Error GetCurrentPosition: %x\n", hr);
break; break;
} }
if (This->write_pos < play_pos) if (This->write_pos <= play_pos)
buf_free = play_pos-This->write_pos; buf_free = play_pos-This->write_pos;
else else
buf_free = DSBUFFERSIZE - This->write_pos + play_pos; buf_free = DSBUFFERSIZE - This->write_pos + play_pos;
/* This situation is ambiguous; Assume full when playing */ /* Wait for enough of the buffer to empty before filling it */
if(buf_free == DSBUFFERSIZE) if(buf_free < DSBUFFERSIZE/4)
{ {
Sleep(10); Sleep(10);
continue; continue;
@ -234,11 +234,7 @@ static HRESULT DSoundRender_SendSampleData(DSoundRenderImpl* This, LPBYTE data,
size -= dwsize1 + dwsize2; size -= dwsize1 + dwsize2;
data += dwsize1 + dwsize2; data += dwsize1 + dwsize2;
This->write_pos = (This->write_pos + dwsize1 + dwsize2) % DSBUFFERSIZE; This->write_pos = (This->write_pos + dwsize1 + dwsize2) % DSBUFFERSIZE;
} while (size && This->state == State_Running);
if (!size)
break;
Sleep(10);
} while (This->state == State_Running);
return hr; return hr;
} }