Use separate lists for playback and capture backends

This commit is contained in:
Chris Robinson 2011-08-19 00:23:26 -07:00
parent c96a6c2b1b
commit 6ba5128f72
8 changed files with 58 additions and 140 deletions

View File

@ -117,6 +117,11 @@ static struct BackendInfo BackendLoopback = {
};
#undef EmptyFuncs
static struct BackendInfo PlaybackBackend[sizeof(BackendList)/sizeof(BackendList[0])];
static ALCuint NumPlaybackBackends;
static struct BackendInfo CaptureBackend[sizeof(BackendList)/sizeof(BackendList[0])];
static ALCuint NumCaptureBackends;
///////////////////////////////////////////////////////
// STRING and EXTENSIONS
@ -533,6 +538,9 @@ static void alc_deinit(void)
ReleaseALC(ALC_TRUE);
memset(PlaybackBackend, 0, sizeof(PlaybackBackend));
memset(CaptureBackend, 0, sizeof(CaptureBackend));
for(i = 0;BackendList[i].Deinit;i++)
BackendList[i].Deinit();
BackendLoopback.Deinit();
@ -542,7 +550,7 @@ static void alc_deinit(void)
static void alc_initconfig(void)
{
int i;
int i, n;
const char *devs, *str;
str = getenv("ALSOFT_LOGLEVEL");
@ -645,10 +653,24 @@ static void alc_initconfig(void)
while(BackendList[i].Init)
{
if(BackendList[i].Init(&BackendList[i].Funcs))
{
TRACE("Initialized backend \"%s\"\n", BackendList[i].name);
if(BackendList[i].Funcs.OpenPlayback)
{
PlaybackBackend[NumPlaybackBackends++] = BackendList[i];
TRACE("Added \"%s\" for playback\n", BackendList[i].name);
}
if(BackendList[i].Funcs.OpenCapture)
{
CaptureBackend[NumCaptureBackends++] = BackendList[i];
TRACE("Added \"%s\" for capture\n", BackendList[i].name);
}
i++;
}
else
{
int n = i;
TRACE("Failed to initialize backend \"%s\"\n", BackendList[i].name);
n = i;
do {
BackendList[n] = BackendList[n+1];
++n;
@ -660,7 +682,6 @@ static void alc_initconfig(void)
str = GetConfigValue(NULL, "excludefx", "");
if(str[0])
{
int n;
size_t len;
const char *next = str;
@ -703,15 +724,23 @@ static pthread_once_t once_control = PTHREAD_ONCE_INIT;
static void ProbeList(ALCchar **list, size_t *listsize, int type)
{
ALint i;
ALCuint i;
free(*list);
*list = NULL;
*listsize = 0;
DO_INITCONFIG();
for(i = 0;BackendList[i].Probe;i++)
BackendList[i].Probe(type);
if(type == CAPTURE_DEVICE_PROBE)
{
for(i = 0;i < NumCaptureBackends;i++)
CaptureBackend[i].Probe(type);
}
else
{
for(i = 0;i < NumPlaybackBackends;i++)
PlaybackBackend[i].Probe(type);
}
}
static void ProbeDeviceList()
@ -1621,7 +1650,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *deviceName,
{
ALCboolean DeviceFound = ALC_FALSE;
ALCdevice *device = NULL;
ALCint i;
ALCuint i;
DO_INITCONFIG();
@ -1664,9 +1693,9 @@ ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *deviceName,
device->NumUpdates = 1;
LockLists();
for(i = 0;BackendList[i].Init;i++)
for(i = 0;i < NumCaptureBackends;i++)
{
device->Funcs = &BackendList[i].Funcs;
device->Funcs = &CaptureBackend[i].Funcs;
if(ALCdevice_OpenCapture(device, deviceName))
{
device->next = g_pDeviceList;
@ -2681,7 +2710,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName)
ALboolean bDeviceFound = AL_FALSE;
const ALCchar *fmt;
ALCdevice *device;
ALint i;
ALCuint i;
DO_INITCONFIG();
@ -2752,9 +2781,9 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName)
// Find a playback device to open
LockLists();
for(i = 0;BackendList[i].Init;i++)
for(i = 0;i < NumPlaybackBackends;i++)
{
device->Funcs = &BackendList[i].Funcs;
device->Funcs = &PlaybackBackend[i].Funcs;
if(ALCdevice_OpenPlayback(device, deviceName))
{
device->next = g_pDeviceList;

View File

@ -556,53 +556,17 @@ static void DSoundStopPlayback(ALCdevice *device)
}
static ALCboolean DSoundOpenCapture(ALCdevice *pDevice, const ALCchar *deviceName)
{
(void)pDevice;
(void)deviceName;
return ALC_FALSE;
}
static void DSoundCloseCapture(ALCdevice *pDevice)
{
(void)pDevice;
}
static void DSoundStartCapture(ALCdevice *pDevice)
{
(void)pDevice;
}
static void DSoundStopCapture(ALCdevice *pDevice)
{
(void)pDevice;
}
static void DSoundCaptureSamples(ALCdevice *pDevice, ALCvoid *pBuffer, ALCuint lSamples)
{
(void)pDevice;
(void)pBuffer;
(void)lSamples;
}
static ALCuint DSoundAvailableSamples(ALCdevice *pDevice)
{
(void)pDevice;
return 0;
}
static const BackendFuncs DSoundFuncs = {
DSoundOpenPlayback,
DSoundClosePlayback,
DSoundResetPlayback,
DSoundStopPlayback,
DSoundOpenCapture,
DSoundCloseCapture,
DSoundStartCapture,
DSoundStopCapture,
DSoundCaptureSamples,
DSoundAvailableSamples
NULL,
NULL,
NULL,
NULL,
NULL,
NULL
};

View File

@ -726,20 +726,12 @@ static void MMDevApiStopPlayback(ALCdevice *device)
}
static ALCboolean MMDevApiOpenCapture(ALCdevice *device, const ALCchar *deviceName)
{
(void)device;
(void)deviceName;
return ALC_FALSE;
}
static const BackendFuncs MMDevApiFuncs = {
MMDevApiOpenPlayback,
MMDevApiClosePlayback,
MMDevApiResetPlayback,
MMDevApiStopPlayback,
MMDevApiOpenCapture,
NULL,
NULL,
NULL,
NULL,

View File

@ -125,20 +125,12 @@ static void null_stop_playback(ALCdevice *device)
}
static ALCboolean null_open_capture(ALCdevice *device, const ALCchar *deviceName)
{
(void)device;
(void)deviceName;
return ALC_FALSE;
}
static const BackendFuncs null_funcs = {
null_open_playback,
null_close_playback,
null_reset_playback,
null_stop_playback,
null_open_capture,
NULL,
NULL,
NULL,
NULL,

View File

@ -384,20 +384,13 @@ static void opensl_stop_playback(ALCdevice *Device)
data->bufferSize = 0;
}
static ALCboolean opensl_open_capture(ALCdevice *Device, const ALCchar *deviceName)
{
return ALC_FALSE;
(void)Device;
(void)deviceName;
}
static const BackendFuncs opensl_funcs = {
opensl_open_playback,
opensl_close_playback,
opensl_reset_playback,
opensl_stop_playback,
opensl_open_capture,
NULL,
NULL,
NULL,
NULL,

View File

@ -335,20 +335,12 @@ static void sndio_stop_playback(ALCdevice *device)
}
static ALCboolean sndio_open_capture(ALCdevice *device, const ALCchar *deviceName)
{
(void)device;
(void)deviceName;
return ALC_FALSE;
}
static const BackendFuncs sndio_funcs = {
sndio_open_playback,
sndio_close_playback,
sndio_reset_playback,
sndio_stop_playback,
sndio_open_capture,
NULL,
NULL,
NULL,
NULL,

View File

@ -237,53 +237,17 @@ static void solaris_stop_playback(ALCdevice *device)
}
static ALCboolean solaris_open_capture(ALCdevice *device, const ALCchar *deviceName)
{
(void)device;
(void)deviceName;
return ALC_FALSE;
}
static void solaris_close_capture(ALCdevice *device)
{
(void)device;
}
static void solaris_start_capture(ALCdevice *pDevice)
{
(void)pDevice;
}
static void solaris_stop_capture(ALCdevice *pDevice)
{
(void)pDevice;
}
static void solaris_capture_samples(ALCdevice *pDevice, ALCvoid *pBuffer, ALCuint lSamples)
{
(void)pDevice;
(void)pBuffer;
(void)lSamples;
}
static ALCuint solaris_available_samples(ALCdevice *pDevice)
{
(void)pDevice;
return 0;
}
static const BackendFuncs solaris_funcs = {
solaris_open_playback,
solaris_close_playback,
solaris_reset_playback,
solaris_stop_playback,
solaris_open_capture,
solaris_close_capture,
solaris_start_capture,
solaris_stop_capture,
solaris_capture_samples,
solaris_available_samples
NULL,
NULL,
NULL,
NULL,
NULL,
NULL
};
ALCboolean alc_solaris_init(BackendFuncs *func_list)

View File

@ -313,20 +313,12 @@ static void wave_stop_playback(ALCdevice *device)
}
static ALCboolean wave_open_capture(ALCdevice *pDevice, const ALCchar *deviceName)
{
(void)pDevice;
(void)deviceName;
return ALC_FALSE;
}
static const BackendFuncs wave_funcs = {
wave_open_playback,
wave_close_playback,
wave_reset_playback,
wave_stop_playback,
wave_open_capture,
NULL,
NULL,
NULL,
NULL,