aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/backends
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2011-09-13 23:51:22 -0700
committerChris Robinson <[email protected]>2011-09-13 23:51:22 -0700
commit62dfea43c699cb18a7538980794106d3ac0edca6 (patch)
treeb72f5bf2d6f8384cba3ef8597395d92edf23d3e2 /Alc/backends
parenta4f8408150edf94b8ff684c6c383d87f99e77e76 (diff)
Limit the minimum ALSA capture size to 100ms, and the maximum period size to 50ms
Diffstat (limited to 'Alc/backends')
-rw-r--r--Alc/backends/alsa.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/Alc/backends/alsa.c b/Alc/backends/alsa.c
index 838f464c..7fa8f7b8 100644
--- a/Alc/backends/alsa.c
+++ b/Alc/backends/alsa.c
@@ -803,6 +803,7 @@ static ALCenum alsa_open_capture(ALCdevice *pDevice, const ALCchar *deviceName)
{
snd_pcm_hw_params_t *p;
snd_pcm_uframes_t bufferSizeInFrames;
+ snd_pcm_uframes_t periodSizeInFrames;
snd_pcm_format_t format;
ALuint frameSize;
alsa_data *data;
@@ -868,7 +869,9 @@ static ALCenum alsa_open_capture(ALCdevice *pDevice, const ALCchar *deviceName)
}
err = NULL;
- bufferSizeInFrames = pDevice->UpdateSize * pDevice->NumUpdates;
+ bufferSizeInFrames = maxu(pDevice->UpdateSize*pDevice->NumUpdates,
+ 100*pDevice->Frequency/1000);
+ periodSizeInFrames = minu(bufferSizeInFrames, 50*pDevice->Frequency/1000);
snd_pcm_hw_params_malloc(&p);
if((i=snd_pcm_hw_params_any(data->pcmHandle, p)) < 0)
@@ -888,6 +891,9 @@ static ALCenum alsa_open_capture(ALCdevice *pDevice, const ALCchar *deviceName)
/* set buffer size in frame units (implicitly sets period size/bytes/time and buffer time/bytes) */
if(i >= 0 && (i=snd_pcm_hw_params_set_buffer_size_near(data->pcmHandle, p, &bufferSizeInFrames)) < 0)
err = "set buffer size near";
+ /* set buffer size in frame units (implicitly sets period size/bytes/time and buffer time/bytes) */
+ if(i >= 0 && (i=snd_pcm_hw_params_set_period_size_near(data->pcmHandle, p, &periodSizeInFrames, NULL)) < 0)
+ err = "set period size near";
/* install and prepare hardware configuration */
if(i >= 0 && (i=snd_pcm_hw_params(data->pcmHandle, p)) < 0)
err = "set params";