Return an ALC error enum from the OpenCapture backend method
This commit is contained in:
parent
c696d4dbb2
commit
7e2155d937
@ -1377,6 +1377,7 @@ static ALCvoid FreeContext(ALCcontext *context)
|
||||
ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *deviceName, ALCuint frequency, ALCenum format, ALCsizei SampleSize)
|
||||
{
|
||||
ALCdevice *device = NULL;
|
||||
ALCenum err;
|
||||
|
||||
DO_INITCONFIG();
|
||||
|
||||
@ -1426,7 +1427,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *deviceName,
|
||||
device->NumUpdates = 1;
|
||||
|
||||
LockLists();
|
||||
if(ALCdevice_OpenCapture(device, deviceName))
|
||||
if((err=ALCdevice_OpenCapture(device, deviceName)) == ALC_NO_ERROR)
|
||||
{
|
||||
device->next = g_pDeviceList;
|
||||
g_pDeviceList = device;
|
||||
@ -1437,7 +1438,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *deviceName,
|
||||
DeleteCriticalSection(&device->Mutex);
|
||||
free(device);
|
||||
device = NULL;
|
||||
alcSetError(NULL, ALC_INVALID_VALUE);
|
||||
alcSetError(NULL, err);
|
||||
}
|
||||
UnlockLists();
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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) //{{{
|
||||
|
@ -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)
|
||||
|
@ -275,7 +275,7 @@ typedef struct {
|
||||
ALCboolean (*ResetPlayback)(ALCdevice*);
|
||||
void (*StopPlayback)(ALCdevice*);
|
||||
|
||||
ALCboolean (*OpenCapture)(ALCdevice*, const ALCchar*);
|
||||
ALCenum (*OpenCapture)(ALCdevice*, const ALCchar*);
|
||||
void (*CloseCapture)(ALCdevice*);
|
||||
void (*StartCapture)(ALCdevice*);
|
||||
void (*StopCapture)(ALCdevice*);
|
||||
|
Loading…
x
Reference in New Issue
Block a user