Rebuild device lists when retrieving them
This commit is contained in:
@@ -44,33 +44,34 @@ static struct {
|
||||
const char *name;
|
||||
void (*Init)(BackendFuncs*);
|
||||
void (*Deinit)(void);
|
||||
void (*Probe)(int);
|
||||
BackendFuncs Funcs;
|
||||
} BackendList[] = {
|
||||
#ifdef HAVE_ALSA
|
||||
{ "alsa", alc_alsa_init, alc_alsa_deinit, EmptyFuncs },
|
||||
{ "alsa", alc_alsa_init, alc_alsa_deinit, alc_alsa_probe, EmptyFuncs },
|
||||
#endif
|
||||
#ifdef HAVE_OSS
|
||||
{ "oss", alc_oss_init, alc_oss_deinit, EmptyFuncs },
|
||||
{ "oss", alc_oss_init, alc_oss_deinit, alc_oss_probe, EmptyFuncs },
|
||||
#endif
|
||||
#ifdef HAVE_SOLARIS
|
||||
{ "solaris", alc_solaris_init, alc_solaris_deinit, EmptyFuncs },
|
||||
{ "solaris", alc_solaris_init, alc_solaris_deinit, alc_solaris_probe, EmptyFuncs },
|
||||
#endif
|
||||
#ifdef HAVE_DSOUND
|
||||
{ "dsound", alcDSoundInit, alcDSoundDeinit, EmptyFuncs },
|
||||
{ "dsound", alcDSoundInit, alcDSoundDeinit, alcDSoundProbe, EmptyFuncs },
|
||||
#endif
|
||||
#ifdef HAVE_WINMM
|
||||
{ "winmm", alcWinMMInit, alcWinMMDeinit, EmptyFuncs },
|
||||
{ "winmm", alcWinMMInit, alcWinMMDeinit, alcWinMMProbe, EmptyFuncs },
|
||||
#endif
|
||||
#ifdef HAVE_PORTAUDIO
|
||||
{ "port", alc_pa_init, alc_pa_deinit, EmptyFuncs },
|
||||
{ "port", alc_pa_init, alc_pa_deinit, alc_pa_probe, EmptyFuncs },
|
||||
#endif
|
||||
#ifdef HAVE_PULSEAUDIO
|
||||
{ "pulse", alc_pulse_init, alc_pulse_deinit, EmptyFuncs },
|
||||
{ "pulse", alc_pulse_init, alc_pulse_deinit, alc_pulse_probe, EmptyFuncs },
|
||||
#endif
|
||||
|
||||
{ "wave", alc_wave_init, alc_wave_deinit, EmptyFuncs },
|
||||
{ "wave", alc_wave_init, alc_wave_deinit, alc_wave_probe, EmptyFuncs },
|
||||
|
||||
{ NULL, NULL, NULL, EmptyFuncs }
|
||||
{ NULL, NULL, NULL, NULL, EmptyFuncs }
|
||||
};
|
||||
#undef EmptyFuncs
|
||||
|
||||
@@ -258,6 +259,45 @@ static void my_deinit()
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static void ProbeDeviceList()
|
||||
{
|
||||
ALint i;
|
||||
|
||||
free(alcDeviceList); alcDeviceList = NULL;
|
||||
alcDeviceListSize = 0;
|
||||
|
||||
for(i = 0;BackendList[i].Probe;i++)
|
||||
BackendList[i].Probe(DEVICE_PROBE);
|
||||
|
||||
alcDefaultDeviceSpecifier = alcDeviceList;
|
||||
}
|
||||
|
||||
static void ProbeAllDeviceList()
|
||||
{
|
||||
ALint i;
|
||||
|
||||
free(alcAllDeviceList); alcAllDeviceList = NULL;
|
||||
alcAllDeviceListSize = 0;
|
||||
|
||||
for(i = 0;BackendList[i].Probe;i++)
|
||||
BackendList[i].Probe(ALL_DEVICE_PROBE);
|
||||
|
||||
alcDefaultAllDeviceSpecifier = alcAllDeviceList;
|
||||
}
|
||||
|
||||
static void ProbeCaptureDeviceList()
|
||||
{
|
||||
ALint i;
|
||||
|
||||
free(alcCaptureDeviceList); alcCaptureDeviceList = NULL;
|
||||
alcCaptureDeviceListSize = 0;
|
||||
|
||||
for(i = 0;BackendList[i].Probe;i++)
|
||||
BackendList[i].Probe(CAPTURE_DEVICE_PROBE);
|
||||
|
||||
alcCaptureDefaultDeviceSpecifier = alcCaptureDeviceList;
|
||||
}
|
||||
|
||||
static void InitAL(void)
|
||||
{
|
||||
if(!init_done)
|
||||
@@ -312,8 +352,14 @@ static void InitAL(void)
|
||||
}
|
||||
|
||||
for(i = 0;BackendList[i].Init;i++)
|
||||
{
|
||||
BackendList[i].Init(&BackendList[i].Funcs);
|
||||
|
||||
BackendList[i].Probe(DEVICE_PROBE);
|
||||
BackendList[i].Probe(ALL_DEVICE_PROBE);
|
||||
BackendList[i].Probe(CAPTURE_DEVICE_PROBE);
|
||||
}
|
||||
|
||||
/* Default is always the first in the list */
|
||||
alcDefaultDeviceSpecifier = alcDeviceList;
|
||||
alcDefaultAllDeviceSpecifier = alcAllDeviceList;
|
||||
@@ -360,6 +406,7 @@ static void InitAL(void)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#define DECL_APPEND_LIST_FUNC(type) \
|
||||
void Append##type##List(const ALCchar *name) \
|
||||
{ \
|
||||
@@ -764,10 +811,14 @@ ALCAPI const ALCchar* ALCAPIENTRY alcGetString(ALCdevice *pDevice,ALCenum param)
|
||||
if(IsDevice(pDevice))
|
||||
value = pDevice->szDeviceName;
|
||||
else
|
||||
{
|
||||
ProbeDeviceList();
|
||||
value = alcDeviceList;
|
||||
}
|
||||
break;
|
||||
|
||||
case ALC_ALL_DEVICES_SPECIFIER:
|
||||
ProbeAllDeviceList();
|
||||
value = alcAllDeviceList;
|
||||
break;
|
||||
|
||||
@@ -779,7 +830,10 @@ ALCAPI const ALCchar* ALCAPIENTRY alcGetString(ALCdevice *pDevice,ALCenum param)
|
||||
if(IsDevice(pDevice))
|
||||
value = pDevice->szDeviceName;
|
||||
else
|
||||
{
|
||||
ProbeCaptureDeviceList();
|
||||
value = alcCaptureDeviceList;
|
||||
}
|
||||
break;
|
||||
|
||||
case ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER:
|
||||
|
||||
+171
-146
@@ -791,12 +791,6 @@ BackendFuncs alsa_funcs = {
|
||||
|
||||
void alc_alsa_init(BackendFuncs *func_list)
|
||||
{
|
||||
snd_ctl_t *handle;
|
||||
int card, err, dev, idx = 1;
|
||||
snd_ctl_card_info_t *info;
|
||||
snd_pcm_info_t *pcminfo;
|
||||
snd_pcm_stream_t stream = SND_PCM_STREAM_PLAYBACK;
|
||||
char name[128];
|
||||
char *str;
|
||||
|
||||
*func_list = alsa_funcs;
|
||||
@@ -878,145 +872,6 @@ LOAD_FUNC(snd_ctl_card_info_get_name);
|
||||
LOAD_FUNC(snd_card_next);
|
||||
|
||||
#undef LOAD_FUNC
|
||||
|
||||
psnd_ctl_card_info_malloc(&info);
|
||||
psnd_pcm_info_malloc(&pcminfo);
|
||||
|
||||
card = -1;
|
||||
if(psnd_card_next(&card) < 0 || card < 0)
|
||||
AL_PRINT("no playback cards found...\n");
|
||||
|
||||
AppendDeviceList(alsaDevice);
|
||||
allDevNameMap = malloc(sizeof(DevMap) * 1);
|
||||
allDevNameMap[0].name = strdup("ALSA Software on default");
|
||||
AppendAllDeviceList(allDevNameMap[0].name);
|
||||
|
||||
while (card >= 0) {
|
||||
sprintf(name, "hw:%d", card);
|
||||
if ((err = psnd_ctl_open(&handle, name, 0)) < 0) {
|
||||
AL_PRINT("control open (%i): %s\n", card, psnd_strerror(err));
|
||||
goto next_card;
|
||||
}
|
||||
if ((err = psnd_ctl_card_info(handle, info)) < 0) {
|
||||
AL_PRINT("control hardware info (%i): %s\n", card, psnd_strerror(err));
|
||||
psnd_ctl_close(handle);
|
||||
goto next_card;
|
||||
}
|
||||
|
||||
dev = -1;
|
||||
while(1) {
|
||||
const char *cname, *dname;
|
||||
void *temp;
|
||||
|
||||
if (psnd_ctl_pcm_next_device(handle, &dev)<0)
|
||||
AL_PRINT("snd_ctl_pcm_next_device failed\n");
|
||||
if (dev < 0)
|
||||
break;
|
||||
|
||||
psnd_pcm_info_set_device(pcminfo, dev);
|
||||
psnd_pcm_info_set_subdevice(pcminfo, 0);
|
||||
psnd_pcm_info_set_stream(pcminfo, stream);
|
||||
if ((err = psnd_ctl_pcm_info(handle, pcminfo)) < 0) {
|
||||
if (err != -ENOENT)
|
||||
AL_PRINT("control digital audio info (%i): %s\n", card, psnd_strerror(err));
|
||||
continue;
|
||||
}
|
||||
|
||||
temp = realloc(allDevNameMap, sizeof(DevMap) * (idx+1));
|
||||
if(temp)
|
||||
{
|
||||
allDevNameMap = temp;
|
||||
cname = psnd_ctl_card_info_get_name(info);
|
||||
dname = psnd_pcm_info_get_name(pcminfo);
|
||||
snprintf(name, sizeof(name), "ALSA Software on %s [%s] (hw:%d,%d)",
|
||||
cname, dname, card, dev);
|
||||
AppendAllDeviceList(name);
|
||||
allDevNameMap[idx].name = strdup(name);
|
||||
allDevNameMap[idx].card = card;
|
||||
allDevNameMap[idx].dev = dev;
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
psnd_ctl_close(handle);
|
||||
next_card:
|
||||
if(psnd_card_next(&card) < 0) {
|
||||
AL_PRINT("snd_card_next failed\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
numDevNames = idx;
|
||||
|
||||
|
||||
stream = SND_PCM_STREAM_CAPTURE;
|
||||
|
||||
card = -1;
|
||||
if(psnd_card_next(&card) < 0 || card < 0) {
|
||||
AL_PRINT("no capture cards found...\n");
|
||||
psnd_pcm_info_free(pcminfo);
|
||||
psnd_ctl_card_info_free(info);
|
||||
return;
|
||||
}
|
||||
|
||||
allCaptureDevNameMap = malloc(sizeof(DevMap) * 1);
|
||||
allCaptureDevNameMap[0].name = strdup("ALSA Capture on default");
|
||||
AppendCaptureDeviceList(allCaptureDevNameMap[0].name);
|
||||
|
||||
idx = 1;
|
||||
while (card >= 0) {
|
||||
sprintf(name, "hw:%d", card);
|
||||
handle = NULL;
|
||||
if ((err = psnd_ctl_open(&handle, name, 0)) < 0) {
|
||||
AL_PRINT("control open (%i): %s\n", card, psnd_strerror(err));
|
||||
}
|
||||
if (err >= 0 && (err = psnd_ctl_card_info(handle, info)) < 0) {
|
||||
AL_PRINT("control hardware info (%i): %s\n", card, psnd_strerror(err));
|
||||
}
|
||||
else if (err >= 0)
|
||||
{
|
||||
dev = -1;
|
||||
while(1) {
|
||||
const char *cname, *dname;
|
||||
void *temp;
|
||||
|
||||
if (psnd_ctl_pcm_next_device(handle, &dev)<0)
|
||||
AL_PRINT("snd_ctl_pcm_next_device failed\n");
|
||||
if (dev < 0)
|
||||
break;
|
||||
psnd_pcm_info_set_device(pcminfo, dev);
|
||||
psnd_pcm_info_set_subdevice(pcminfo, 0);
|
||||
psnd_pcm_info_set_stream(pcminfo, stream);
|
||||
if ((err = psnd_ctl_pcm_info(handle, pcminfo)) < 0) {
|
||||
if (err != -ENOENT)
|
||||
AL_PRINT("control digital audio info (%i): %s\n", card, psnd_strerror(err));
|
||||
continue;
|
||||
}
|
||||
|
||||
temp = realloc(allCaptureDevNameMap, sizeof(DevMap) * (idx+1));
|
||||
if(temp)
|
||||
{
|
||||
allCaptureDevNameMap = temp;
|
||||
cname = psnd_ctl_card_info_get_name(info);
|
||||
dname = psnd_pcm_info_get_name(pcminfo);
|
||||
snprintf(name, sizeof(name), "ALSA Capture on %s [%s] (hw:%d,%d)",
|
||||
cname, dname, card, dev);
|
||||
AppendCaptureDeviceList(name);
|
||||
allCaptureDevNameMap[idx].name = strdup(name);
|
||||
allCaptureDevNameMap[idx].card = card;
|
||||
allCaptureDevNameMap[idx].dev = dev;
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(handle) psnd_ctl_close(handle);
|
||||
if(psnd_card_next(&card) < 0) {
|
||||
AL_PRINT("snd_card_next failed\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
numCaptureDevNames = idx;
|
||||
|
||||
psnd_pcm_info_free(pcminfo);
|
||||
psnd_ctl_card_info_free(info);
|
||||
}
|
||||
|
||||
void alc_alsa_deinit(void)
|
||||
@@ -1036,7 +891,177 @@ void alc_alsa_deinit(void)
|
||||
numCaptureDevNames = 0;
|
||||
|
||||
#ifdef HAVE_DLFCN_H
|
||||
dlclose(alsa_handle);
|
||||
if(alsa_handle)
|
||||
dlclose(alsa_handle);
|
||||
alsa_handle = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
void alc_alsa_probe(int type)
|
||||
{
|
||||
snd_ctl_t *handle;
|
||||
int card, err, dev, idx;
|
||||
snd_ctl_card_info_t *info;
|
||||
snd_pcm_info_t *pcminfo;
|
||||
snd_pcm_stream_t stream;
|
||||
char name[128];
|
||||
ALuint i;
|
||||
|
||||
if(!alsa_handle)
|
||||
return;
|
||||
|
||||
psnd_ctl_card_info_malloc(&info);
|
||||
psnd_pcm_info_malloc(&pcminfo);
|
||||
|
||||
if(type == DEVICE_PROBE)
|
||||
AppendDeviceList(alsaDevice);
|
||||
else if(type == ALL_DEVICE_PROBE)
|
||||
{
|
||||
stream = SND_PCM_STREAM_PLAYBACK;
|
||||
card = -1;
|
||||
if(psnd_card_next(&card) < 0 || card < 0) {
|
||||
AL_PRINT("no playback cards found...\n");
|
||||
psnd_pcm_info_free(pcminfo);
|
||||
psnd_ctl_card_info_free(info);
|
||||
return;
|
||||
}
|
||||
|
||||
for(i = 0;i < numDevNames;++i)
|
||||
free(allDevNameMap[i].name);
|
||||
|
||||
allDevNameMap = realloc(allDevNameMap, sizeof(DevMap) * 1);
|
||||
allDevNameMap[0].name = strdup("ALSA Software on default");
|
||||
AppendAllDeviceList(allDevNameMap[0].name);
|
||||
|
||||
idx = 1;
|
||||
while(card >= 0) {
|
||||
sprintf(name, "hw:%d", card);
|
||||
if ((err = psnd_ctl_open(&handle, name, 0)) < 0) {
|
||||
AL_PRINT("control open (%i): %s\n", card, psnd_strerror(err));
|
||||
goto next_card;
|
||||
}
|
||||
if ((err = psnd_ctl_card_info(handle, info)) < 0) {
|
||||
AL_PRINT("control hardware info (%i): %s\n", card, psnd_strerror(err));
|
||||
psnd_ctl_close(handle);
|
||||
goto next_card;
|
||||
}
|
||||
|
||||
dev = -1;
|
||||
while(1) {
|
||||
const char *cname, *dname;
|
||||
void *temp;
|
||||
|
||||
if (psnd_ctl_pcm_next_device(handle, &dev)<0)
|
||||
AL_PRINT("snd_ctl_pcm_next_device failed\n");
|
||||
if (dev < 0)
|
||||
break;
|
||||
|
||||
psnd_pcm_info_set_device(pcminfo, dev);
|
||||
psnd_pcm_info_set_subdevice(pcminfo, 0);
|
||||
psnd_pcm_info_set_stream(pcminfo, stream);
|
||||
if ((err = psnd_ctl_pcm_info(handle, pcminfo)) < 0) {
|
||||
if (err != -ENOENT)
|
||||
AL_PRINT("control digital audio info (%i): %s\n", card, psnd_strerror(err));
|
||||
continue;
|
||||
}
|
||||
|
||||
temp = realloc(allDevNameMap, sizeof(DevMap) * (idx+1));
|
||||
if(temp)
|
||||
{
|
||||
allDevNameMap = temp;
|
||||
cname = psnd_ctl_card_info_get_name(info);
|
||||
dname = psnd_pcm_info_get_name(pcminfo);
|
||||
snprintf(name, sizeof(name), "ALSA Software on %s [%s] (hw:%d,%d)",
|
||||
cname, dname, card, dev);
|
||||
AppendAllDeviceList(name);
|
||||
allDevNameMap[idx].name = strdup(name);
|
||||
allDevNameMap[idx].card = card;
|
||||
allDevNameMap[idx].dev = dev;
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
psnd_ctl_close(handle);
|
||||
next_card:
|
||||
if(psnd_card_next(&card) < 0) {
|
||||
AL_PRINT("snd_card_next failed\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
numDevNames = idx;
|
||||
}
|
||||
else if(type == CAPTURE_DEVICE_PROBE)
|
||||
{
|
||||
stream = SND_PCM_STREAM_CAPTURE;
|
||||
card = -1;
|
||||
if(psnd_card_next(&card) < 0 || card < 0) {
|
||||
AL_PRINT("no capture cards found...\n");
|
||||
psnd_pcm_info_free(pcminfo);
|
||||
psnd_ctl_card_info_free(info);
|
||||
return;
|
||||
}
|
||||
|
||||
for(i = 0;i < numCaptureDevNames;++i)
|
||||
free(allCaptureDevNameMap[i].name);
|
||||
|
||||
allCaptureDevNameMap = realloc(allCaptureDevNameMap, sizeof(DevMap) * 1);
|
||||
allCaptureDevNameMap[0].name = strdup("ALSA Capture on default");
|
||||
AppendCaptureDeviceList(allCaptureDevNameMap[0].name);
|
||||
|
||||
idx = 1;
|
||||
while (card >= 0) {
|
||||
sprintf(name, "hw:%d", card);
|
||||
handle = NULL;
|
||||
if ((err = psnd_ctl_open(&handle, name, 0)) < 0) {
|
||||
AL_PRINT("control open (%i): %s\n", card, psnd_strerror(err));
|
||||
}
|
||||
if (err >= 0 && (err = psnd_ctl_card_info(handle, info)) < 0) {
|
||||
AL_PRINT("control hardware info (%i): %s\n", card, psnd_strerror(err));
|
||||
}
|
||||
else if (err >= 0)
|
||||
{
|
||||
dev = -1;
|
||||
while(1) {
|
||||
const char *cname, *dname;
|
||||
void *temp;
|
||||
|
||||
if (psnd_ctl_pcm_next_device(handle, &dev)<0)
|
||||
AL_PRINT("snd_ctl_pcm_next_device failed\n");
|
||||
if (dev < 0)
|
||||
break;
|
||||
psnd_pcm_info_set_device(pcminfo, dev);
|
||||
psnd_pcm_info_set_subdevice(pcminfo, 0);
|
||||
psnd_pcm_info_set_stream(pcminfo, stream);
|
||||
if ((err = psnd_ctl_pcm_info(handle, pcminfo)) < 0) {
|
||||
if (err != -ENOENT)
|
||||
AL_PRINT("control digital audio info (%i): %s\n", card, psnd_strerror(err));
|
||||
continue;
|
||||
}
|
||||
|
||||
temp = realloc(allCaptureDevNameMap, sizeof(DevMap) * (idx+1));
|
||||
if(temp)
|
||||
{
|
||||
allCaptureDevNameMap = temp;
|
||||
cname = psnd_ctl_card_info_get_name(info);
|
||||
dname = psnd_pcm_info_get_name(pcminfo);
|
||||
snprintf(name, sizeof(name), "ALSA Capture on %s [%s] (hw:%d,%d)",
|
||||
cname, dname, card, dev);
|
||||
AppendCaptureDeviceList(name);
|
||||
allCaptureDevNameMap[idx].name = strdup(name);
|
||||
allCaptureDevNameMap[idx].card = card;
|
||||
allCaptureDevNameMap[idx].dev = dev;
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(handle) psnd_ctl_close(handle);
|
||||
if(psnd_card_next(&card) < 0) {
|
||||
AL_PRINT("snd_card_next failed\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
numCaptureDevNames = idx;
|
||||
}
|
||||
|
||||
psnd_pcm_info_free(pcminfo);
|
||||
psnd_ctl_card_info_free(info);
|
||||
}
|
||||
|
||||
+29
-17
@@ -69,6 +69,8 @@ typedef struct {
|
||||
ALCchar *name;
|
||||
GUID guid;
|
||||
} DevMap;
|
||||
|
||||
static const ALCchar dsDevice[] = "DirectSound Software";
|
||||
static DevMap *DeviceList;
|
||||
static ALuint NumDevices;
|
||||
|
||||
@@ -158,24 +160,23 @@ static ALCboolean DSoundOpenPlayback(ALCdevice *device, const ALCchar *deviceNam
|
||||
if(ds_handle == NULL)
|
||||
return ALC_FALSE;
|
||||
|
||||
if(deviceName)
|
||||
if(deviceName && strcmp(deviceName, dsDevice) != 0)
|
||||
{
|
||||
int i;
|
||||
for(i = 0;DeviceList[i].name;i++)
|
||||
ALuint i;
|
||||
for(i = 0;i < NumDevices;i++)
|
||||
{
|
||||
if(strcmp(deviceName, DeviceList[i].name) == 0)
|
||||
{
|
||||
devName = DeviceList[i].name;
|
||||
if(i > 0)
|
||||
guid = &DeviceList[i].guid;
|
||||
guid = &DeviceList[i].guid;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!DeviceList[i].name)
|
||||
if(i == NumDevices)
|
||||
return ALC_FALSE;
|
||||
}
|
||||
else
|
||||
devName = DeviceList[0].name;
|
||||
devName = dsDevice;
|
||||
|
||||
//Initialise requested device
|
||||
|
||||
@@ -510,16 +511,6 @@ LOAD_FUNC(DirectSoundEnumerateA);
|
||||
|
||||
num_frags = GetConfigValueInt("dsound", "periods", 4);
|
||||
if(num_frags < 2) num_frags = 2;
|
||||
|
||||
DeviceList = malloc(sizeof(DevMap) * 1);
|
||||
DeviceList[0].name = strdup("DirectSound Software");
|
||||
NumDevices = 1;
|
||||
|
||||
AppendDeviceList(DeviceList[0].name);
|
||||
|
||||
hr = pDirectSoundEnumerateA(DSoundEnumDevices, NULL);
|
||||
if(FAILED(hr))
|
||||
AL_PRINT("Error enumerating DirectSound devices (%#x)!\n", (unsigned int)hr);
|
||||
}
|
||||
|
||||
void alcDSoundDeinit(void)
|
||||
@@ -537,3 +528,24 @@ void alcDSoundDeinit(void)
|
||||
ds_handle = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
void alcDSoundProbe(int type)
|
||||
{
|
||||
if(!dsound_handle)
|
||||
return;
|
||||
|
||||
if(type == DEVICE_PROBE)
|
||||
AppendDeviceList(DeviceList[0].name);
|
||||
else if(type == ALL_DEVICE_PROBE)
|
||||
{
|
||||
for(i = 0;i < NumDevices;++i)
|
||||
free(DeviceList[i].name);
|
||||
free(DeviceList);
|
||||
DeviceList = NULL;
|
||||
NumDevices = 0;
|
||||
|
||||
hr = pDirectSoundEnumerateA(DSoundEnumDevices, NULL);
|
||||
if(FAILED(hr))
|
||||
AL_PRINT("Error enumerating DirectSound devices (%#x)!\n", (unsigned int)hr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -473,13 +473,18 @@ BackendFuncs oss_funcs = {
|
||||
void alc_oss_init(BackendFuncs *func_list)
|
||||
{
|
||||
*func_list = oss_funcs;
|
||||
|
||||
AppendDeviceList(oss_device);
|
||||
AppendAllDeviceList(oss_device);
|
||||
|
||||
AppendCaptureDeviceList(oss_device_capture);
|
||||
}
|
||||
|
||||
void alc_oss_deinit(void)
|
||||
{
|
||||
}
|
||||
|
||||
void alc_oss_probe(int type)
|
||||
{
|
||||
if(type == DEVICE_PROBE)
|
||||
AppendDeviceList(oss_device);
|
||||
else if(type == ALL_DEVICE_PROBE)
|
||||
AppendAllDeviceList(oss_device);
|
||||
else if(type == CAPTURE_DEVICE_PROBE)
|
||||
AppendCaptureDeviceList(oss_device_capture);
|
||||
}
|
||||
|
||||
+14
-4
@@ -244,17 +244,27 @@ void alc_pa_init(BackendFuncs *func_list)
|
||||
if((err=pPa_Initialize()) != paNoError)
|
||||
{
|
||||
AL_PRINT("Pa_Initialize() returned an error: %s\n", pPa_GetErrorText(err));
|
||||
alc_pa_deinit();
|
||||
return;
|
||||
}
|
||||
|
||||
AppendDeviceList(pa_device);
|
||||
AppendAllDeviceList(pa_device);
|
||||
}
|
||||
|
||||
void alc_pa_deinit(void)
|
||||
{
|
||||
#ifdef HAVE_DLFCN_H
|
||||
dlclose(pa_handle);
|
||||
if(pa_handle)
|
||||
dlclose(pa_handle);
|
||||
pa_handle = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
void alc_pa_probe(int type)
|
||||
{
|
||||
if(!pa_handle)
|
||||
return;
|
||||
|
||||
if(type == DEVICE_PROBE)
|
||||
AppendDeviceList(pa_device);
|
||||
else if(type == ALL_DEVICE_PROBE)
|
||||
AppendAllDeviceList(pa_device);
|
||||
}
|
||||
|
||||
+18
-7
@@ -695,20 +695,31 @@ LOAD_FUNC(pa_stream_disconnect);
|
||||
LOAD_FUNC(pa_threaded_mainloop_lock);
|
||||
|
||||
#undef LOAD_FUNC
|
||||
|
||||
AppendDeviceList(pulse_device);
|
||||
AppendAllDeviceList(pulse_device);
|
||||
|
||||
AppendCaptureDeviceList(pulse_capture_device);
|
||||
} //}}}
|
||||
|
||||
void alc_pulse_deinit(void) //{{{
|
||||
{
|
||||
if(pa_handle)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
FreeLibrary(pa_handle);
|
||||
FreeLibrary(pa_handle);
|
||||
#elif defined (HAVE_DLFCN_H)
|
||||
dlclose(pa_handle);
|
||||
dlclose(pa_handle);
|
||||
#endif
|
||||
}
|
||||
pa_handle = NULL;
|
||||
} //}}}
|
||||
|
||||
void alc_pulse_probe(int type) //{{{
|
||||
{
|
||||
if(!pa_handle)
|
||||
return;
|
||||
|
||||
if(type == DEVICE_PROBE)
|
||||
AppendDeviceList(pulse_device);
|
||||
else if(type == ALL_DEVICE_PROBE)
|
||||
AppendAllDeviceList(pulse_device);
|
||||
else if(type == CAPTURE_DEVICE_PROBE)
|
||||
AppendCaptureDeviceList(pulse_capture_device);
|
||||
} //}}}
|
||||
//}}}
|
||||
|
||||
+8
-3
@@ -278,11 +278,16 @@ BackendFuncs solaris_funcs = {
|
||||
void alc_solaris_init(BackendFuncs *func_list)
|
||||
{
|
||||
*func_list = solaris_funcs;
|
||||
|
||||
AppendDeviceList(solaris_device);
|
||||
AppendAllDeviceList(solaris_device);
|
||||
}
|
||||
|
||||
void alc_solaris_deinit(void)
|
||||
{
|
||||
}
|
||||
|
||||
void alc_solaris_probe(ALCboolean capture)
|
||||
{
|
||||
if(type == DEVICE_PROBE)
|
||||
AppendDeviceList(solaris_device);
|
||||
else if(type == ALL_DEVICE_PROBE)
|
||||
AppendAllDeviceList(solaris_device);
|
||||
}
|
||||
|
||||
+8
-3
@@ -366,11 +366,16 @@ BackendFuncs wave_funcs = {
|
||||
void alc_wave_init(BackendFuncs *func_list)
|
||||
{
|
||||
*func_list = wave_funcs;
|
||||
|
||||
AppendDeviceList(waveDevice);
|
||||
AppendAllDeviceList(waveDevice);
|
||||
}
|
||||
|
||||
void alc_wave_deinit(void)
|
||||
{
|
||||
}
|
||||
|
||||
void alc_wave_probe(int type)
|
||||
{
|
||||
if(type == DEVICE_PROBE)
|
||||
AppendDeviceList(waveDevice);
|
||||
else if(type == ALL_DEVICE_PROBE)
|
||||
AppendAllDeviceList(waveDevice);
|
||||
}
|
||||
|
||||
+28
-18
@@ -425,25 +425,7 @@ BackendFuncs WinMMFuncs = {
|
||||
|
||||
void alcWinMMInit(BackendFuncs *FuncList)
|
||||
{
|
||||
ALuint lLoop;
|
||||
|
||||
*FuncList = WinMMFuncs;
|
||||
|
||||
NumCaptureDevices = waveInGetNumDevs();
|
||||
CaptureDeviceList = malloc(sizeof(ALCchar*) * NumCaptureDevices);
|
||||
for(lLoop = 0; lLoop < NumCaptureDevices; lLoop++)
|
||||
{
|
||||
WAVEINCAPS WaveInCaps;
|
||||
|
||||
CaptureDeviceList[lLoop] = strdup("");
|
||||
if(waveInGetDevCaps(lLoop, &WaveInCaps, sizeof(WAVEINCAPS)) == MMSYSERR_NOERROR)
|
||||
{
|
||||
char name[128];
|
||||
snprintf(name, sizeof(name), "WaveIn on %s", WaveInCaps.szPname);
|
||||
AppendCaptureDeviceList(name);
|
||||
CaptureDeviceList[lLoop] = strdup(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void alcWinMMDeinit()
|
||||
@@ -457,3 +439,31 @@ void alcWinMMDeinit()
|
||||
|
||||
NumCaptureDevices = 0;
|
||||
}
|
||||
|
||||
void alcWinMMProbe(ALCboolean capture)
|
||||
{
|
||||
ALuint lLoop;
|
||||
|
||||
if(type != CAPTURE_DEVICE_PROBE)
|
||||
return;
|
||||
|
||||
for(lLoop = 0; lLoop < NumCaptureDevices; lLoop++)
|
||||
free(CaptureDeviceList[lLoop]);
|
||||
|
||||
NumCaptureDevices = waveInGetNumDevs();
|
||||
CaptureDeviceList = realloc(CaptureDeviceList, sizeof(ALCchar*) * NumCaptureDevices);
|
||||
for(lLoop = 0; lLoop < NumCaptureDevices; lLoop++)
|
||||
{
|
||||
WAVEINCAPS WaveInCaps;
|
||||
|
||||
if(waveInGetDevCaps(lLoop, &WaveInCaps, sizeof(WAVEINCAPS)) == MMSYSERR_NOERROR)
|
||||
{
|
||||
char name[128];
|
||||
snprintf(name, sizeof(name), "WaveIn on %s", WaveInCaps.szPname);
|
||||
AppendCaptureDeviceList(name);
|
||||
CaptureDeviceList[lLoop] = strdup(name);
|
||||
}
|
||||
else
|
||||
CaptureDeviceList[lLoop] = strdup("");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,22 +159,36 @@ typedef struct {
|
||||
ALCuint (*AvailableSamples)(ALCdevice*);
|
||||
} BackendFuncs;
|
||||
|
||||
enum {
|
||||
DEVICE_PROBE,
|
||||
ALL_DEVICE_PROBE,
|
||||
CAPTURE_DEVICE_PROBE
|
||||
};
|
||||
|
||||
void alc_alsa_init(BackendFuncs *func_list);
|
||||
void alc_alsa_deinit(void);
|
||||
void alc_alsa_probe(int type);
|
||||
void alc_oss_init(BackendFuncs *func_list);
|
||||
void alc_oss_deinit(void);
|
||||
void alc_oss_probe(int type);
|
||||
void alc_solaris_init(BackendFuncs *func_list);
|
||||
void alc_solaris_deinit(void);
|
||||
void alc_solarise_probe(int type);
|
||||
void alcDSoundInit(BackendFuncs *func_list);
|
||||
void alcDSoundDeinit(void);
|
||||
void alcDSoundProbe(int type);
|
||||
void alcWinMMInit(BackendFuncs *FuncList);
|
||||
void alcWinMMDeinit(void);
|
||||
void alcWinMMProbe(int type);
|
||||
void alc_pa_init(BackendFuncs *func_list);
|
||||
void alc_pa_deinit(void);
|
||||
void alc_pa_probe(int type);
|
||||
void alc_wave_init(BackendFuncs *func_list);
|
||||
void alc_wave_deinit(void);
|
||||
void alc_wave_probe(int type);
|
||||
void alc_pulse_init(BackendFuncs *func_list);
|
||||
void alc_pulse_deinit(void);
|
||||
void alc_pulse_probe(int type);
|
||||
|
||||
|
||||
struct ALCdevice_struct
|
||||
|
||||
Reference in New Issue
Block a user