From 4e4c9aef1581fbec81294f20e2466d9d63e26ad8 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 14 Aug 2009 13:08:25 -0700 Subject: Calculate the buffer size and frame size when needed --- Alc/pulseaudio.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/Alc/pulseaudio.c b/Alc/pulseaudio.c index a9fcb3df..2faf0ea5 100644 --- a/Alc/pulseaudio.c +++ b/Alc/pulseaudio.c @@ -206,21 +206,12 @@ static ALCboolean pulse_open(ALCdevice *device, ALCchar *device_name) //{{{ pulse_data *data = ppa_xmalloc0(sizeof(pulse_data)); data->device = device; - data->samples = device->BufferSize; - data->frame_size = aluBytesFromFormat(device->Format) * - aluChannelsFromFormat(device->Format); if(ppa_get_binary_name(data->path_name, sizeof(data->path_name))) data->context_name = ppa_path_get_filename(data->path_name); else data->context_name = "OpenAL Soft"; - if(!(data->ring = CreateRingBuffer(data->frame_size, data->samples))) - { - ppa_xfree(data); - return ALC_FALSE; - } - device->ExtraData = data; device->szDeviceName = device_name; @@ -291,7 +282,6 @@ out: } device->ExtraData = NULL; device->szDeviceName = NULL; - DestroyRingBuffer(data->ring); ppa_xfree(data); return ALC_FALSE; @@ -352,6 +342,10 @@ static ALCboolean pulse_start_context(ALCdevice *device, ALCcontext *context) // ppa_threaded_mainloop_lock(data->loop); + data->samples = device->BufferSize; + data->frame_size = aluBytesFromFormat(device->Format) * + aluChannelsFromFormat(device->Format); + device->UpdateSize = device->BufferSize / 4; data->attr.minreq = -1; @@ -469,6 +463,17 @@ static ALCboolean pulse_open_capture(ALCdevice *device, const ALCchar *device_na data = device->ExtraData; ppa_threaded_mainloop_lock(data->loop); + data->samples = device->BufferSize; + data->frame_size = aluBytesFromFormat(device->Format) * + aluChannelsFromFormat(device->Format); + + if(!(data->ring = CreateRingBuffer(data->frame_size, data->samples))) + { + ppa_threaded_mainloop_unlock(data->loop); + pulse_close(device); + return ALC_FALSE; + } + data->attr.minreq = -1; data->attr.prebuf = -1; data->attr.maxlength = -1; -- cgit v1.2.3