aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2009-08-14 13:08:25 -0700
committerChris Robinson <[email protected]>2009-08-14 13:08:25 -0700
commit4e4c9aef1581fbec81294f20e2466d9d63e26ad8 (patch)
treea0a068a035932389ff01b1f63b72ca01beafd362
parent4031ee5ef08326e0e33cb561f9e3c9662891b588 (diff)
Calculate the buffer size and frame size when needed
-rw-r--r--Alc/pulseaudio.c25
1 files 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;