Do not enumerate PulseAudio devices if a context fails to connect

This commit is contained in:
Chris Robinson 2010-08-04 04:21:39 -07:00
parent 22cc5af1fe
commit 7f9bcfbc7d

View File

@ -666,21 +666,6 @@ static void probe_devices(ALboolean capture)
{
pa_threaded_mainloop *loop;
if(capture == AL_FALSE)
{
allDevNameMap = malloc(sizeof(DevMap) * 1);
allDevNameMap[0].name = strdup("PulseAudio Default");
allDevNameMap[0].device_name = NULL;
numDevNames = 1;
}
else
{
allCaptureDevNameMap = malloc(sizeof(DevMap) * 1);
allCaptureDevNameMap[0].name = strdup("PulseAudio Default");
allCaptureDevNameMap[0].device_name = NULL;
numCaptureDevNames = 1;
}
if((loop=ppa_threaded_mainloop_new()) &&
ppa_threaded_mainloop_start(loop) >= 0)
{
@ -693,9 +678,23 @@ static void probe_devices(ALboolean capture)
pa_operation *o;
if(capture == AL_FALSE)
{
allDevNameMap = malloc(sizeof(DevMap) * 1);
allDevNameMap[0].name = strdup("PulseAudio Default");
allDevNameMap[0].device_name = NULL;
numDevNames = 1;
o = ppa_context_get_sink_info_list(context, sink_device_callback, loop);
}
else
{
allCaptureDevNameMap = malloc(sizeof(DevMap) * 1);
allCaptureDevNameMap[0].name = strdup("PulseAudio Default");
allCaptureDevNameMap[0].device_name = NULL;
numCaptureDevNames = 1;
o = ppa_context_get_source_info_list(context, source_device_callback, loop);
}
while(ppa_operation_get_state(o) == PA_OPERATION_RUNNING)
ppa_threaded_mainloop_wait(loop);
ppa_operation_unref(o);
@ -1316,7 +1315,29 @@ void alc_pulse_probe(int type) //{{{
if(!pulse_load()) return;
if(type == DEVICE_PROBE)
AppendDeviceList(pulse_device);
{
pa_threaded_mainloop *loop;
if((loop=ppa_threaded_mainloop_new()) &&
ppa_threaded_mainloop_start(loop) >= 0)
{
pa_context *context;
ppa_threaded_mainloop_lock(loop);
context = connect_context(loop);
if(context)
{
AppendDeviceList(pulse_device);
ppa_context_disconnect(context);
ppa_context_unref(context);
}
ppa_threaded_mainloop_unlock(loop);
ppa_threaded_mainloop_stop(loop);
}
if(loop)
ppa_threaded_mainloop_free(loop);
}
else if(type == ALL_DEVICE_PROBE)
{
ALuint i;