From dd60366aecf6721775eba007465f78c36e17dd5c Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 6 Jan 2008 00:18:06 -0800 Subject: Fix the buffer size so ALSA doesn't multiply by the number of periods --- Alc/alsa.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'Alc') diff --git a/Alc/alsa.c b/Alc/alsa.c index 91a4543d..7b8d4dfa 100644 --- a/Alc/alsa.c +++ b/Alc/alsa.c @@ -396,7 +396,7 @@ open_alsa: periods = GetConfigValueInt("alsa", "periods", 4); if((int)periods <= 0) periods = 4; - bufferSizeInFrames = device->UpdateFreq; + bufferSizeInFrames = device->UpdateFreq / periods; psnd_pcm_hw_params_malloc(&p); #define ok(func, str) (i=(func),((i<0)?(err=(str)),0:1)) @@ -438,9 +438,9 @@ open_alsa: psnd_pcm_hw_params_free(p); device->MaxNoOfSources = 256; - device->UpdateFreq = bufferSizeInFrames; + device->UpdateFreq = bufferSizeInFrames * periods; - data->size = psnd_pcm_frames_to_bytes(data->pcmHandle, bufferSizeInFrames); + data->size = psnd_pcm_frames_to_bytes(data->pcmHandle, device->UpdateFreq); if(access == SND_PCM_ACCESS_RW_INTERLEAVED) { data->buffer = malloc(data->size); @@ -512,7 +512,7 @@ static ALCboolean alsa_open_capture(ALCdevice *pDevice, const ALCchar *deviceNam snd_pcm_format_t alsaFormat; snd_pcm_hw_params_t *p; unsigned int periods = 4; - snd_pcm_uframes_t bufferSizeInFrames = SampleSize; + snd_pcm_uframes_t bufferSizeInFrames; alsa_data *data; char driver[64]; char *err; @@ -575,6 +575,8 @@ open_alsa: AL_PRINT("Unknown format?! %x\n", format); } + bufferSizeInFrames = SampleSize / periods; + psnd_pcm_hw_params_malloc(&p); #define ok(func, str) (i=(func),((i<0)?(err=(str)),0:1)) /* start with the largest configuration space possible */ -- cgit v1.2.3