aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2008-01-06 00:18:06 -0800
committerChris Robinson <[email protected]>2008-01-06 00:18:06 -0800
commitdd60366aecf6721775eba007465f78c36e17dd5c (patch)
treeca52e50b46c7e16c6ab095c61a2b49d802fb3967 /Alc
parent017fc933074947b9f8dd85d9582030fe4ce367ea (diff)
Fix the buffer size so ALSA doesn't multiply by the number of periods
Diffstat (limited to 'Alc')
-rw-r--r--Alc/alsa.c10
1 files changed, 6 insertions, 4 deletions
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 */