diff options
author | Chris Robinson <[email protected]> | 2011-09-14 02:01:35 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2011-09-14 02:01:35 -0700 |
commit | 97024151e49d97ed3ae9d73a9426de0f1a9ebb0f (patch) | |
tree | 841c413a23725d55a6b872b531bcc38689ba96cd /Alc/backends/portaudio.c | |
parent | 62dfea43c699cb18a7538980794106d3ac0edca6 (diff) |
Return an error from the CaptureSamples method instead of setting it
Diffstat (limited to 'Alc/backends/portaudio.c')
-rw-r--r-- | Alc/backends/portaudio.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/Alc/backends/portaudio.c b/Alc/backends/portaudio.c index c3898ef8..2345a282 100644 --- a/Alc/backends/portaudio.c +++ b/Alc/backends/portaudio.c @@ -377,19 +377,20 @@ static void pa_stop_capture(ALCdevice *device) ERR("Error stopping stream: %s\n", Pa_GetErrorText(err)); } -static void pa_capture_samples(ALCdevice *device, ALCvoid *buffer, ALCuint samples) +static ALCuint pa_available_samples(ALCdevice *device) { pa_data *data = device->ExtraData; - if(samples <= (ALCuint)RingBufferSize(data->ring)) - ReadRingBuffer(data->ring, buffer, samples); - else - alcSetError(device, ALC_INVALID_VALUE); + return RingBufferSize(data->ring); } -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); + + if(pa_available_samples(device) < samples) + return ALC_INVALID_VALUE; + ReadRingBuffer(data->ring, buffer, samples); + return ALC_NO_ERROR; } |