aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/backends
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2011-08-24 14:44:15 -0700
committerChris Robinson <[email protected]>2011-08-24 14:44:15 -0700
commit7e2155d937e66dc7c4a1445bf12e64684eebb5a0 (patch)
tree4af5b1cc0f824b60e30be1d1d9cfed9216d8ac7a /Alc/backends
parentc696d4dbb23461066ed741a36a83da10b6ad17f5 (diff)
Return an ALC error enum from the OpenCapture backend method
Diffstat (limited to 'Alc/backends')
-rw-r--r--Alc/backends/alsa.c10
-rw-r--r--Alc/backends/coreaudio.c8
-rw-r--r--Alc/backends/oss.c21
-rw-r--r--Alc/backends/portaudio.c16
-rw-r--r--Alc/backends/pulseaudio.c10
-rw-r--r--Alc/backends/winmm.c16
6 files changed, 35 insertions, 46 deletions
diff --git a/Alc/backends/alsa.c b/Alc/backends/alsa.c
index fc873489..838f464c 100644
--- a/Alc/backends/alsa.c
+++ b/Alc/backends/alsa.c
@@ -799,7 +799,7 @@ static void alsa_stop_playback(ALCdevice *device)
}
-static ALCboolean alsa_open_capture(ALCdevice *pDevice, const ALCchar *deviceName)
+static ALCenum alsa_open_capture(ALCdevice *pDevice, const ALCchar *deviceName)
{
snd_pcm_hw_params_t *p;
snd_pcm_uframes_t bufferSizeInFrames;
@@ -834,7 +834,7 @@ static ALCboolean alsa_open_capture(ALCdevice *pDevice, const ALCchar *deviceNam
}
}
if(idx == numCaptureDevNames)
- return ALC_FALSE;
+ return ALC_INVALID_VALUE;
}
data = (alsa_data*)calloc(1, sizeof(alsa_data));
@@ -844,7 +844,7 @@ static ALCboolean alsa_open_capture(ALCdevice *pDevice, const ALCchar *deviceNam
{
ERR("Could not open capture device '%s': %s\n", driver, snd_strerror(i));
free(data);
- return ALC_FALSE;
+ return ALC_INVALID_VALUE;
}
format = -1;
@@ -927,7 +927,7 @@ static ALCboolean alsa_open_capture(ALCdevice *pDevice, const ALCchar *deviceNam
pDevice->szDeviceName = strdup(deviceName);
pDevice->ExtraData = data;
- return ALC_TRUE;
+ return ALC_NO_ERROR;
error:
free(data->buffer);
@@ -936,7 +936,7 @@ error:
free(data);
pDevice->ExtraData = NULL;
- return ALC_FALSE;
+ return ALC_INVALID_VALUE;
}
static void alsa_close_capture(ALCdevice *pDevice)
diff --git a/Alc/backends/coreaudio.c b/Alc/backends/coreaudio.c
index 4a042285..b0c600d3 100644
--- a/Alc/backends/coreaudio.c
+++ b/Alc/backends/coreaudio.c
@@ -376,7 +376,7 @@ static void ca_stop_playback(ALCdevice *device)
ERR("-- AudioUnitUninitialize failed.\n");
}
-static ALCboolean ca_open_capture(ALCdevice *device, const ALCchar *deviceName)
+static ALCenum ca_open_capture(ALCdevice *device, const ALCchar *deviceName)
{
AudioStreamBasicDescription requestedFormat; // The application requested format
AudioStreamBasicDescription hardwareFormat; // The hardware format
@@ -402,7 +402,7 @@ static ALCboolean ca_open_capture(ALCdevice *device, const ALCchar *deviceName)
if(comp == NULL)
{
ERR("FindNextComponent failed\n");
- return ALC_FALSE;
+ return ALC_INVALID_VALUE;
}
data = calloc(1, sizeof(*data));
@@ -587,7 +587,7 @@ static ALCboolean ca_open_capture(ALCdevice *device, const ALCchar *deviceName)
goto error;
}
- return ALC_TRUE;
+ return ALC_NO_ERROR;
error:
DestroyRingBuffer(data->ring);
@@ -602,7 +602,7 @@ error:
free(data);
device->ExtraData = NULL;
- return ALC_FALSE;
+ return ALC_INVALID_VALUE;
}
static void ca_close_capture(ALCdevice *device)
diff --git a/Alc/backends/oss.c b/Alc/backends/oss.c
index e361dff4..c94e3044 100644
--- a/Alc/backends/oss.c
+++ b/Alc/backends/oss.c
@@ -308,7 +308,7 @@ static void oss_stop_playback(ALCdevice *device)
}
-static ALCboolean oss_open_capture(ALCdevice *device, const ALCchar *deviceName)
+static ALCenum oss_open_capture(ALCdevice *device, const ALCchar *deviceName)
{
int numFragmentsLogSize;
int log2FragmentSize;
@@ -324,10 +324,11 @@ static ALCboolean oss_open_capture(ALCdevice *device, const ALCchar *deviceName)
strncpy(driver, GetConfigValue("oss", "capture", "/dev/dsp"), sizeof(driver)-1);
driver[sizeof(driver)-1] = 0;
+
if(!deviceName)
deviceName = oss_device;
else if(strcmp(deviceName, oss_device) != 0)
- return ALC_FALSE;
+ return ALC_INVALID_VALUE;
data = (oss_data*)calloc(1, sizeof(oss_data));
data->killNow = 0;
@@ -337,7 +338,7 @@ static ALCboolean oss_open_capture(ALCdevice *device, const ALCchar *deviceName)
{
free(data);
ERR("Could not open %s: %s\n", driver, strerror(errno));
- return ALC_FALSE;
+ return ALC_INVALID_VALUE;
}
switch(device->FmtType)
@@ -355,7 +356,7 @@ static ALCboolean oss_open_capture(ALCdevice *device, const ALCchar *deviceName)
case DevFmtFloat:
free(data);
ERR("%s capture samples not supported on OSS\n", DevFmtTypeString(device->FmtType));
- return ALC_FALSE;
+ return ALC_INVALID_VALUE;
}
periods = 4;
@@ -385,7 +386,7 @@ static ALCboolean oss_open_capture(ALCdevice *device, const ALCchar *deviceName)
ERR("%s failed: %s\n", err, strerror(errno));
close(data->fd);
free(data);
- return ALC_FALSE;
+ return ALC_INVALID_VALUE;
}
#undef CHECKERR
@@ -394,7 +395,7 @@ static ALCboolean oss_open_capture(ALCdevice *device, const ALCchar *deviceName)
ERR("Failed to set %s, got %d channels instead\n", DevFmtChannelsString(device->FmtChans), numChannels);
close(data->fd);
free(data);
- return ALC_FALSE;
+ return ALC_INVALID_VALUE;
}
if(!((ossFormat == AFMT_S8 && device->FmtType == DevFmtByte) ||
@@ -404,7 +405,7 @@ static ALCboolean oss_open_capture(ALCdevice *device, const ALCchar *deviceName)
ERR("Failed to set %s samples, got OSS format %#x\n", DevFmtTypeString(device->FmtType), ossFormat);
close(data->fd);
free(data);
- return ALC_FALSE;
+ return ALC_INVALID_VALUE;
}
data->ring = CreateRingBuffer(frameSize, device->UpdateSize * device->NumUpdates);
@@ -413,7 +414,7 @@ static ALCboolean oss_open_capture(ALCdevice *device, const ALCchar *deviceName)
ERR("Ring buffer create failed\n");
close(data->fd);
free(data);
- return ALC_FALSE;
+ return ALC_OUT_OF_MEMORY;
}
data->data_size = info.fragsize;
@@ -426,11 +427,11 @@ static ALCboolean oss_open_capture(ALCdevice *device, const ALCchar *deviceName)
device->ExtraData = NULL;
free(data->mix_data);
free(data);
- return ALC_FALSE;
+ return ALC_OUT_OF_MEMORY;
}
device->szDeviceName = strdup(deviceName);
- return ALC_TRUE;
+ return ALC_NO_ERROR;
}
static void oss_close_capture(ALCdevice *device)
diff --git a/Alc/backends/portaudio.c b/Alc/backends/portaudio.c
index 606d0633..c3898ef8 100644
--- a/Alc/backends/portaudio.c
+++ b/Alc/backends/portaudio.c
@@ -278,7 +278,7 @@ static void pa_stop_playback(ALCdevice *device)
}
-static ALCboolean pa_open_capture(ALCdevice *device, const ALCchar *deviceName)
+static ALCenum pa_open_capture(ALCdevice *device, const ALCchar *deviceName)
{
PaStreamParameters inParams;
ALuint frame_size;
@@ -288,22 +288,16 @@ static ALCboolean pa_open_capture(ALCdevice *device, const ALCchar *deviceName)
if(!deviceName)
deviceName = pa_device;
else if(strcmp(deviceName, pa_device) != 0)
- return ALC_FALSE;
+ return ALC_INVALID_VALUE;
data = (pa_data*)calloc(1, sizeof(pa_data));
if(data == NULL)
- {
- alcSetError(device, ALC_OUT_OF_MEMORY);
- return ALC_FALSE;
- }
+ return ALC_OUT_OF_MEMORY;
frame_size = FrameSizeFromDevFmt(device->FmtChans, device->FmtType);
data->ring = CreateRingBuffer(frame_size, device->UpdateSize*device->NumUpdates);
if(data->ring == NULL)
- {
- alcSetError(device, ALC_OUT_OF_MEMORY);
goto error;
- }
inParams.device = GetConfigValueInt("port", "capture", -1);
if(inParams.device < 0)
@@ -342,12 +336,12 @@ static ALCboolean pa_open_capture(ALCdevice *device, const ALCchar *deviceName)
device->szDeviceName = strdup(deviceName);
device->ExtraData = data;
- return ALC_TRUE;
+ return ALC_NO_ERROR;
error:
DestroyRingBuffer(data->ring);
free(data);
- return ALC_FALSE;
+ return ALC_INVALID_VALUE;
}
static void pa_close_capture(ALCdevice *device)
diff --git a/Alc/backends/pulseaudio.c b/Alc/backends/pulseaudio.c
index 5a39bacf..62b6286b 100644
--- a/Alc/backends/pulseaudio.c
+++ b/Alc/backends/pulseaudio.c
@@ -1085,7 +1085,7 @@ static void pulse_stop_playback(ALCdevice *device) //{{{
} //}}}
-static ALCboolean pulse_open_capture(ALCdevice *device, const ALCchar *device_name) //{{{
+static ALCenum pulse_open_capture(ALCdevice *device, const ALCchar *device_name) //{{{
{
char *pulse_name = NULL;
pulse_data *data;
@@ -1111,11 +1111,11 @@ static ALCboolean pulse_open_capture(ALCdevice *device, const ALCchar *device_na
}
}
if(i == numCaptureDevNames)
- return ALC_FALSE;
+ return ALC_INVALID_VALUE;
}
if(pulse_open(device, device_name) == ALC_FALSE)
- return ALC_FALSE;
+ return ALC_INVALID_VALUE;
data = device->ExtraData;
pa_threaded_mainloop_lock(data->loop);
@@ -1217,11 +1217,11 @@ static ALCboolean pulse_open_capture(ALCdevice *device, const ALCchar *device_na
pa_stream_set_state_callback(data->stream, stream_state_callback2, device);
pa_threaded_mainloop_unlock(data->loop);
- return ALC_TRUE;
+ return ALC_NO_ERROR;
fail:
pulse_close(device);
- return ALC_FALSE;
+ return ALC_INVALID_VALUE;
} //}}}
static void pulse_close_capture(ALCdevice *device) //{{{
diff --git a/Alc/backends/winmm.c b/Alc/backends/winmm.c
index cd61a156..2a286259 100644
--- a/Alc/backends/winmm.c
+++ b/Alc/backends/winmm.c
@@ -483,7 +483,7 @@ static void WinMMStopPlayback(ALCdevice *device)
}
-static ALCboolean WinMMOpenCapture(ALCdevice *pDevice, const ALCchar *deviceName)
+static ALCenum WinMMOpenCapture(ALCdevice *pDevice, const ALCchar *deviceName)
{
WAVEFORMATEX wfexCaptureFormat;
DWORD ulCapturedDataSize;
@@ -522,22 +522,16 @@ static ALCboolean WinMMOpenCapture(ALCdevice *pDevice, const ALCchar *deviceName
}
}
if(i == NumCaptureDevices)
- return ALC_FALSE;
+ return ALC_INVALID_VALUE;
pData = calloc(1, sizeof(*pData));
if(!pData)
- {
- alcSetError(pDevice, ALC_OUT_OF_MEMORY);
- return ALC_FALSE;
- }
+ return ALC_OUT_OF_MEMORY;
pDevice->ExtraData = pData;
if((pDevice->FmtChans != DevFmtMono && pDevice->FmtChans != DevFmtStereo) ||
(pDevice->FmtType != DevFmtUByte && pDevice->FmtType != DevFmtShort))
- {
- alcSetError(pDevice, ALC_INVALID_ENUM);
goto failure;
- }
memset(&wfexCaptureFormat, 0, sizeof(WAVEFORMATEX));
wfexCaptureFormat.wFormatTag = WAVE_FORMAT_PCM;
@@ -605,7 +599,7 @@ static ALCboolean WinMMOpenCapture(ALCdevice *pDevice, const ALCchar *deviceName
goto failure;
pDevice->szDeviceName = strdup(CaptureDeviceList[lDeviceID]);
- return ALC_TRUE;
+ return ALC_NO_ERROR;
failure:
if(pData->hWaveThread)
@@ -632,7 +626,7 @@ failure:
free(pData);
pDevice->ExtraData = NULL;
- return ALC_FALSE;
+ return ALC_INVALID_VALUE;
}
static void WinMMCloseCapture(ALCdevice *pDevice)