Commit 3bafbb22 authored by Maarten Lankhorst's avatar Maarten Lankhorst Committed by Alexandre Julliard

dsound: Use smaller buffers for wavein capture.

parent 290869b0
...@@ -253,7 +253,6 @@ struct DirectSoundCaptureDevice ...@@ -253,7 +253,6 @@ struct DirectSoundCaptureDevice
/* more stuff */ /* more stuff */
LPBYTE buffer; LPBYTE buffer;
DWORD buflen; DWORD buflen;
DWORD read_position;
PWAVEFORMATEX pwfx; PWAVEFORMATEX pwfx;
...@@ -420,6 +419,7 @@ HRESULT DSOUND_Create8(REFIID riid, LPDIRECTSOUND8 *ppDS); ...@@ -420,6 +419,7 @@ HRESULT DSOUND_Create8(REFIID riid, LPDIRECTSOUND8 *ppDS);
/* primary.c */ /* primary.c */
DWORD DSOUND_fraglen(DWORD nSamplesPerSec, DWORD nBlockAlign);
HRESULT DSOUND_PrimaryCreate(DirectSoundDevice *device); HRESULT DSOUND_PrimaryCreate(DirectSoundDevice *device);
HRESULT DSOUND_PrimaryDestroy(DirectSoundDevice *device); HRESULT DSOUND_PrimaryDestroy(DirectSoundDevice *device);
HRESULT DSOUND_PrimaryPlay(DirectSoundDevice *device); HRESULT DSOUND_PrimaryPlay(DirectSoundDevice *device);
......
...@@ -36,36 +36,44 @@ ...@@ -36,36 +36,44 @@
WINE_DEFAULT_DEBUG_CHANNEL(dsound); WINE_DEFAULT_DEBUG_CHANNEL(dsound);
static void DSOUND_RecalcPrimary(DirectSoundDevice *device) /** Calculate how long a fragment length of about 10 ms should be in frames
*
* nSamplesPerSec: Frequency rate in samples per second
* nBlockAlign: Size of a single blockalign
*
* Returns:
* Size in bytes of a single fragment
*/
DWORD DSOUND_fraglen(DWORD nSamplesPerSec, DWORD nBlockAlign)
{ {
DWORD nBlockAlign; DWORD fraglen = 512 * nBlockAlign;
DWORD fraglen;
TRACE("(%p)\n", device);
nBlockAlign = device->pwfx->nBlockAlign; /* Compensate for only being roughly accurate */
/* Alsa doesn't have continuous buffers, instead it has buffers with power of 2, if (nSamplesPerSec <= 26000)
* If DS_TIME_DEL is about 10 ms, 512 * nBlockAlign is roughly correct */ fraglen /= 2;
fraglen = 512 * nBlockAlign;
/* Compensate for only being roughly accurate */ if (nSamplesPerSec <= 12000)
if (device->pwfx->nSamplesPerSec <= 26000) fraglen /= 2;
fraglen /= 2;
if (device->pwfx->nSamplesPerSec <= 12000) if (nSamplesPerSec >= 80000)
fraglen /= 2; fraglen *= 2;
if (device->pwfx->nSamplesPerSec >= 80000) return fraglen;
fraglen *= 2; }
static void DSOUND_RecalcPrimary(DirectSoundDevice *device)
{
TRACE("(%p)\n", device);
device->fraglen = fraglen; device->fraglen = DSOUND_fraglen(device->pwfx->nSamplesPerSec, device->pwfx->nBlockAlign);
device->helfrags = device->buflen / fraglen; device->helfrags = device->buflen / device->fraglen;
TRACE("fraglen=%d helfrags=%d\n", device->fraglen, device->helfrags); TRACE("fraglen=%d helfrags=%d\n", device->fraglen, device->helfrags);
if (device->hwbuf && device->drvdesc.dwFlags & DSDDESC_DONTNEEDWRITELEAD) if (device->hwbuf && device->drvdesc.dwFlags & DSDDESC_DONTNEEDWRITELEAD)
device->writelead = 0; device->writelead = 0;
else else
/* calculate the 10ms write lead */ /* calculate the 10ms write lead */
device->writelead = (device->pwfx->nSamplesPerSec / 100) * nBlockAlign; device->writelead = (device->pwfx->nSamplesPerSec / 100) * device->pwfx->nBlockAlign;
} }
HRESULT DSOUND_ReopenDevice(DirectSoundDevice *device, BOOL forcewave) HRESULT DSOUND_ReopenDevice(DirectSoundDevice *device, BOOL forcewave)
......
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