aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2009-08-27 06:09:33 -0700
committerChris Robinson <[email protected]>2009-08-27 06:09:33 -0700
commitbb121e68a618d1881a6e35c47938ce0650d07afb (patch)
tree620e024aa067cc96d36a91e2210beffc2115220e
parent1ec26fd789ddfcbabbeae003f286cc01062721c0 (diff)
Rebuild device lists when retrieving them
-rw-r--r--Alc/ALc.c72
-rw-r--r--Alc/alsa.c269
-rw-r--r--Alc/dsound.c46
-rw-r--r--Alc/oss.c15
-rw-r--r--Alc/portaudio.c18
-rw-r--r--Alc/pulseaudio.c25
-rw-r--r--Alc/solaris.c11
-rw-r--r--Alc/wave.c11
-rw-r--r--Alc/winmm.c40
-rw-r--r--OpenAL32/Include/alMain.h14
10 files changed, 336 insertions, 185 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 25922e4b..f7bce12e 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -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:
diff --git a/Alc/alsa.c b/Alc/alsa.c
index 9c5bf3cd..7731f4ed 100644
--- a/Alc/alsa.c
+++ b/Alc/alsa.c
@@ -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,101 +872,80 @@ 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);
+void alc_alsa_deinit(void)
+{
+ ALuint i;
- card = -1;
- if(psnd_card_next(&card) < 0 || card < 0)
- AL_PRINT("no playback cards found...\n");
+ for(i = 0;i < numDevNames;++i)
+ free(allDevNameMap[i].name);
+ free(allDevNameMap);
+ allDevNameMap = NULL;
+ numDevNames = 0;
- AppendDeviceList(alsaDevice);
- allDevNameMap = malloc(sizeof(DevMap) * 1);
- allDevNameMap[0].name = strdup("ALSA Software on default");
- AppendAllDeviceList(allDevNameMap[0].name);
+ for(i = 0;i < numCaptureDevNames;++i)
+ free(allCaptureDevNameMap[i].name);
+ free(allCaptureDevNameMap);
+ allCaptureDevNameMap = NULL;
+ numCaptureDevNames = 0;
- 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;
- }
+#ifdef HAVE_DLFCN_H
+ if(alsa_handle)
+ dlclose(alsa_handle);
+ alsa_handle = NULL;
+#endif
+}
- dev = -1;
- while(1) {
- const char *cname, *dname;
- void *temp;
+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 (psnd_ctl_pcm_next_device(handle, &dev)<0)
- AL_PRINT("snd_ctl_pcm_next_device failed\n");
- if (dev < 0)
- break;
+ if(!alsa_handle)
+ return;
- 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;
- }
+ psnd_ctl_card_info_malloc(&info);
+ psnd_pcm_info_malloc(&pcminfo);
- 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;
+ 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;
}
- }
- numDevNames = idx;
+ for(i = 0;i < numDevNames;++i)
+ free(allDevNameMap[i].name);
- stream = SND_PCM_STREAM_CAPTURE;
+ allDevNameMap = realloc(allDevNameMap, sizeof(DevMap) * 1);
+ allDevNameMap[0].name = strdup("ALSA Software on default");
+ AppendAllDeviceList(allDevNameMap[0].name);
- 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);
+ 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;
+ }
- 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;
@@ -982,6 +955,7 @@ next_card:
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);
@@ -991,52 +965,103 @@ next_card:
continue;
}
- temp = realloc(allCaptureDevNameMap, sizeof(DevMap) * (idx+1));
+ temp = realloc(allDevNameMap, sizeof(DevMap) * (idx+1));
if(temp)
{
- allCaptureDevNameMap = temp;
+ allDevNameMap = 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)",
+ snprintf(name, sizeof(name), "ALSA Software 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;
+ 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;
+ }
}
- if(handle) psnd_ctl_close(handle);
- if(psnd_card_next(&card) < 0) {
- AL_PRINT("snd_card_next failed\n");
- break;
- }
+ numDevNames = idx;
}
- numCaptureDevNames = idx;
-
- psnd_pcm_info_free(pcminfo);
- psnd_ctl_card_info_free(info);
-}
+ 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;
+ }
-void alc_alsa_deinit(void)
-{
- ALuint i;
+ for(i = 0;i < numCaptureDevNames;++i)
+ free(allCaptureDevNameMap[i].name);
- for(i = 0;i < numDevNames;++i)
- free(allDevNameMap[i].name);
- free(allDevNameMap);
- allDevNameMap = NULL;
- numDevNames = 0;
+ allCaptureDevNameMap = realloc(allCaptureDevNameMap, sizeof(DevMap) * 1);
+ allCaptureDevNameMap[0].name = strdup("ALSA Capture on default");
+ AppendCaptureDeviceList(allCaptureDevNameMap[0].name);
- for(i = 0;i < numCaptureDevNames;++i)
- free(allCaptureDevNameMap[i].name);
- free(allCaptureDevNameMap);
- allCaptureDevNameMap = NULL;
- numCaptureDevNames = 0;
+ 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;
+ }
-#ifdef HAVE_DLFCN_H
- dlclose(alsa_handle);
- alsa_handle = NULL;
-#endif
+ psnd_pcm_info_free(pcminfo);
+ psnd_ctl_card_info_free(info);
}
diff --git a/Alc/dsound.c b/Alc/dsound.c
index 8f5d3b11..bbd9bf0b 100644
--- a/Alc/dsound.c
+++ b/Alc/dsound.c
@@ -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);
+ }
+}
diff --git a/Alc/oss.c b/Alc/oss.c
index 6b476ee4..8e0cd8ec 100644
--- a/Alc/oss.c
+++ b/Alc/oss.c
@@ -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);
+}
diff --git a/Alc/portaudio.c b/Alc/portaudio.c
index 20bb2d7b..a8a8ceb5 100644
--- a/Alc/portaudio.c
+++ b/Alc/portaudio.c
@@ -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);
+}
diff --git a/Alc/pulseaudio.c b/Alc/pulseaudio.c
index 88f381b9..8275033b 100644
--- a/Alc/pulseaudio.c
+++ b/Alc/pulseaudio.c
@@ -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);
+} //}}}
//}}}
diff --git a/Alc/solaris.c b/Alc/solaris.c
index 63f92bf4..e6421c2d 100644
--- a/Alc/solaris.c
+++ b/Alc/solaris.c
@@ -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);
+}
diff --git a/Alc/wave.c b/Alc/wave.c
index 47f43b66..d960588c 100644
--- a/Alc/wave.c
+++ b/Alc/wave.c
@@ -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);
+}
diff --git a/Alc/winmm.c b/Alc/winmm.c
index 1f62f5a1..67865f26 100644
--- a/Alc/winmm.c
+++ b/Alc/winmm.c
@@ -425,17 +425,37 @@ BackendFuncs WinMMFuncs = {
void alcWinMMInit(BackendFuncs *FuncList)
{
+ *FuncList = WinMMFuncs;
+}
+
+void alcWinMMDeinit()
+{
ALuint lLoop;
- *FuncList = WinMMFuncs;
+ for(lLoop = 0; lLoop < NumCaptureDevices; lLoop++)
+ free(CaptureDeviceList[lLoop]);
+ free(CaptureDeviceList);
+ CaptureDeviceList = NULL;
+
+ 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 = malloc(sizeof(ALCchar*) * NumCaptureDevices);
+ CaptureDeviceList = realloc(CaptureDeviceList, 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];
@@ -443,17 +463,7 @@ void alcWinMMInit(BackendFuncs *FuncList)
AppendCaptureDeviceList(name);
CaptureDeviceList[lLoop] = strdup(name);
}
+ else
+ CaptureDeviceList[lLoop] = strdup("");
}
}
-
-void alcWinMMDeinit()
-{
- ALuint lLoop;
-
- for(lLoop = 0; lLoop < NumCaptureDevices; lLoop++)
- free(CaptureDeviceList[lLoop]);
- free(CaptureDeviceList);
- CaptureDeviceList = NULL;
-
- NumCaptureDevices = 0;
-}
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index 696eda86..eba91d14 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -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