aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/oss.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2009-09-16 22:58:54 -0700
committerChris Robinson <[email protected]>2009-09-16 22:58:54 -0700
commitcbcaa54173bf6b14435adf3daf9feb2fa2e37d04 (patch)
treea56832a1ee9f96e72ac03a0424893714794cae4a /Alc/oss.c
parent94e3fca7022c5c7f8147200ffdb3cda5ded62488 (diff)
Store the number of periods in the device instead of the buffer size
Also keep all the fields in sync
Diffstat (limited to 'Alc/oss.c')
-rw-r--r--Alc/oss.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/Alc/oss.c b/Alc/oss.c
index 7af734ae..7c7fe73f 100644
--- a/Alc/oss.c
+++ b/Alc/oss.c
@@ -221,18 +221,19 @@ static ALCboolean oss_reset_playback(ALCdevice *device)
AL_PRINT("Unknown format?! %x\n", device->Format);
}
- periods = GetConfigValueInt("oss", "periods", 4);
- if((int)periods <= 0)
+ periods = GetConfigValueInt("oss", "periods", device->NumUpdates);
+ if((int)periods < 2)
periods = 4;
numChannels = aluChannelsFromFormat(device->Format);
frameSize = numChannels * aluBytesFromFormat(device->Format);
ossSpeed = device->Frequency;
- log2FragmentSize = log2i(device->BufferSize * frameSize / periods);
+ log2FragmentSize = log2i(device->UpdateSize * frameSize);
/* according to the OSS spec, 16 bytes are the minimum */
if (log2FragmentSize < 4)
log2FragmentSize = 4;
+ if(periods > 2) periods--;
numFragmentsLogSize = (periods << 16) | log2FragmentSize;
#define ok(func, str) (i=(func),((i<0)?(err=(str)),0:1))
@@ -262,6 +263,7 @@ static ALCboolean oss_reset_playback(ALCdevice *device)
device->Frequency = ossSpeed;
device->UpdateSize = info.fragsize / frameSize;
+ device->NumUpdates = info.fragments + 1;
data->data_size = device->UpdateSize * frameSize;
data->mix_data = calloc(1, data->data_size);
@@ -343,7 +345,8 @@ static ALCboolean oss_open_capture(ALCdevice *device, const ALCchar *deviceName)
numChannels = aluChannelsFromFormat(device->Format);
frameSize = numChannels * aluBytesFromFormat(device->Format);
ossSpeed = device->Frequency;
- log2FragmentSize = log2i(device->BufferSize * frameSize / periods);
+ log2FragmentSize = log2i(device->UpdateSize * device->NumUpdates *
+ frameSize / periods);
/* according to the OSS spec, 16 bytes are the minimum */
if (log2FragmentSize < 4)
@@ -381,7 +384,7 @@ static ALCboolean oss_open_capture(ALCdevice *device, const ALCchar *deviceName)
return ALC_FALSE;
}
- data->ring = CreateRingBuffer(frameSize, device->BufferSize);
+ data->ring = CreateRingBuffer(frameSize, device->UpdateSize * device->NumUpdates);
if(!data->ring)
{
AL_PRINT("ring buffer create failed\n");