aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/backends
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2011-09-18 20:27:34 -0700
committerChris Robinson <[email protected]>2011-09-18 20:27:34 -0700
commitcc3dd648ace1f1276e909dcb07adf782a39f1cf3 (patch)
treeb23d5bb282553f028d96795320d2f5b5b10de5fe /Alc/backends
parent98b2fa6cb523cab6702bfeee36e089711012b9d8 (diff)
Check the number of available samples before calling the capture method
Diffstat (limited to 'Alc/backends')
-rw-r--r--Alc/backends/alsa.c17
-rw-r--r--Alc/backends/coreaudio.c15
-rw-r--r--Alc/backends/oss.c12
-rw-r--r--Alc/backends/portaudio.c13
-rw-r--r--Alc/backends/pulseaudio.c17
-rw-r--r--Alc/backends/winmm.c13
6 files changed, 35 insertions, 52 deletions
diff --git a/Alc/backends/alsa.c b/Alc/backends/alsa.c
index d953f52f..6d4528c1 100644
--- a/Alc/backends/alsa.c
+++ b/Alc/backends/alsa.c
@@ -979,6 +979,13 @@ static void alsa_stop_capture(ALCdevice *Device)
data->doCapture = AL_FALSE;
}
+static ALCenum alsa_capture_samples(ALCdevice *Device, ALCvoid *Buffer, ALCuint Samples)
+{
+ alsa_data *data = (alsa_data*)Device->ExtraData;
+ ReadRingBuffer(data->ring, Buffer, Samples);
+ return ALC_NO_ERROR;
+}
+
static ALCuint alsa_available_samples(ALCdevice *Device)
{
alsa_data *data = (alsa_data*)Device->ExtraData;
@@ -1040,16 +1047,6 @@ static ALCuint alsa_available_samples(ALCdevice *Device)
return RingBufferSize(data->ring);
}
-static ALCenum alsa_capture_samples(ALCdevice *Device, ALCvoid *Buffer, ALCuint Samples)
-{
- alsa_data *data = (alsa_data*)Device->ExtraData;
-
- if(alsa_available_samples(Device) < Samples)
- return ALC_INVALID_VALUE;
- ReadRingBuffer(data->ring, Buffer, Samples);
- return ALC_NO_ERROR;
-}
-
static const BackendFuncs alsa_funcs = {
alsa_open_playback,
diff --git a/Alc/backends/coreaudio.c b/Alc/backends/coreaudio.c
index 2d9ab7a8..7ac43325 100644
--- a/Alc/backends/coreaudio.c
+++ b/Alc/backends/coreaudio.c
@@ -630,12 +630,6 @@ static void ca_stop_capture(ALCdevice *device)
ERR("AudioOutputUnitStop failed\n");
}
-static ALCuint ca_available_samples(ALCdevice *device)
-{
- ca_data *data = device->ExtraData;
- return RingBufferSize(data->ring) / data->sampleRateRatio;
-}
-
static ALCenum ca_capture_samples(ALCdevice *device, ALCvoid *buffer, ALCuint samples)
{
ca_data *data = (ca_data*)device->ExtraData;
@@ -643,9 +637,6 @@ static ALCenum ca_capture_samples(ALCdevice *device, ALCvoid *buffer, ALCuint sa
UInt32 frameCount;
OSStatus err;
- if(ca_available_samples(device) < samples)
- return ALC_INVALID_VALUE;
-
// If no samples are requested, just return
if(samples == 0)
return ALC_NO_ERROR;
@@ -671,6 +662,12 @@ static ALCenum ca_capture_samples(ALCdevice *device, ALCvoid *buffer, ALCuint sa
return ALC_NO_ERROR;
}
+static ALCuint ca_available_samples(ALCdevice *device)
+{
+ ca_data *data = device->ExtraData;
+ return RingBufferSize(data->ring) / data->sampleRateRatio;
+}
+
static const BackendFuncs ca_funcs = {
ca_open_playback,
diff --git a/Alc/backends/oss.c b/Alc/backends/oss.c
index 79830c06..9206343b 100644
--- a/Alc/backends/oss.c
+++ b/Alc/backends/oss.c
@@ -461,19 +461,17 @@ static void oss_stop_capture(ALCdevice *pDevice)
data->doCapture = 0;
}
-static ALCuint oss_available_samples(ALCdevice *pDevice)
+static ALCenum oss_capture_samples(ALCdevice *pDevice, ALCvoid *pBuffer, ALCuint lSamples)
{
oss_data *data = (oss_data*)pDevice->ExtraData;
- return RingBufferSize(data->ring);
+ ReadRingBuffer(data->ring, pBuffer, lSamples);
+ return ALC_NO_ERROR;
}
-static ALCenum oss_capture_samples(ALCdevice *pDevice, ALCvoid *pBuffer, ALCuint lSamples)
+static ALCuint oss_available_samples(ALCdevice *pDevice)
{
oss_data *data = (oss_data*)pDevice->ExtraData;
- if(oss_available_samples(pDevice) < lSamples)
- return ALC_INVALID_VALUE;
- ReadRingBuffer(data->ring, pBuffer, lSamples);
- return ALC_NO_ERROR;
+ return RingBufferSize(data->ring);
}
diff --git a/Alc/backends/portaudio.c b/Alc/backends/portaudio.c
index 8070942c..4275ad80 100644
--- a/Alc/backends/portaudio.c
+++ b/Alc/backends/portaudio.c
@@ -377,20 +377,17 @@ static void pa_stop_capture(ALCdevice *device)
ERR("Error stopping stream: %s\n", Pa_GetErrorText(err));
}
-static ALCuint pa_available_samples(ALCdevice *device)
+static ALCenum pa_capture_samples(ALCdevice *device, ALCvoid *buffer, ALCuint samples)
{
pa_data *data = device->ExtraData;
- return RingBufferSize(data->ring);
+ ReadRingBuffer(data->ring, buffer, samples);
+ return ALC_NO_ERROR;
}
-static ALCenum pa_capture_samples(ALCdevice *device, ALCvoid *buffer, ALCuint samples)
+static ALCuint pa_available_samples(ALCdevice *device)
{
pa_data *data = device->ExtraData;
-
- if(pa_available_samples(device) < samples)
- return ALC_INVALID_VALUE;
- ReadRingBuffer(data->ring, buffer, samples);
- return ALC_NO_ERROR;
+ return RingBufferSize(data->ring);
}
diff --git a/Alc/backends/pulseaudio.c b/Alc/backends/pulseaudio.c
index 2382a708..f727b639 100644
--- a/Alc/backends/pulseaudio.c
+++ b/Alc/backends/pulseaudio.c
@@ -1266,6 +1266,13 @@ static void pulse_stop_capture(ALCdevice *device) //{{{
pa_threaded_mainloop_unlock(data->loop);
} //}}}
+static ALCenum pulse_capture_samples(ALCdevice *device, ALCvoid *buffer, ALCuint samples) //{{{
+{
+ pulse_data *data = device->ExtraData;
+ ReadRingBuffer(data->ring, buffer, samples);
+ return ALC_NO_ERROR;
+} //}}}
+
static ALCuint pulse_available_samples(ALCdevice *device) //{{{
{
pulse_data *data = device->ExtraData;
@@ -1297,16 +1304,6 @@ static ALCuint pulse_available_samples(ALCdevice *device) //{{{
return RingBufferSize(data->ring);
} //}}}
-static ALCenum pulse_capture_samples(ALCdevice *device, ALCvoid *buffer, ALCuint samples) //{{{
-{
- pulse_data *data = device->ExtraData;
-
- if(pulse_available_samples(device) < samples)
- return ALC_INVALID_VALUE;
- ReadRingBuffer(data->ring, buffer, samples);
- return ALC_NO_ERROR;
-} //}}}
-
static const BackendFuncs pulse_funcs = { //{{{
pulse_open_playback,
diff --git a/Alc/backends/winmm.c b/Alc/backends/winmm.c
index 1a9f099b..67182950 100644
--- a/Alc/backends/winmm.c
+++ b/Alc/backends/winmm.c
@@ -677,20 +677,17 @@ static void WinMMStopCapture(ALCdevice *pDevice)
waveInStop(pData->hWaveHandle.In);
}
-static ALCuint WinMMAvailableSamples(ALCdevice *pDevice)
+static ALCenum WinMMCaptureSamples(ALCdevice *pDevice, ALCvoid *pBuffer, ALCuint lSamples)
{
WinMMData *pData = (WinMMData*)pDevice->ExtraData;
- return RingBufferSize(pData->pRing);
+ ReadRingBuffer(pData->pRing, pBuffer, lSamples);
+ return ALC_NO_ERROR;
}
-static ALCenum WinMMCaptureSamples(ALCdevice *pDevice, ALCvoid *pBuffer, ALCuint lSamples)
+static ALCuint WinMMAvailableSamples(ALCdevice *pDevice)
{
WinMMData *pData = (WinMMData*)pDevice->ExtraData;
-
- if(WinMMAvailableSamples(pDevice) < lSamples)
- return ALC_INVALID_VALUE;
- ReadRingBuffer(pData->pRing, pBuffer, lSamples);
- return ALC_NO_ERROR;
+ return RingBufferSize(pData->pRing);
}