aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2010-08-04 04:21:39 -0700
committerChris Robinson <[email protected]>2010-08-04 04:21:39 -0700
commit7f9bcfbc7d84caccce6647b197b55e57b0b0892f (patch)
tree093abdcfe25ec2640930f7cfe7e48bc8fbb315cc
parent22cc5af1fe1227af67807c8b1928f69fe97488b3 (diff)
Do not enumerate PulseAudio devices if a context fails to connect
-rw-r--r--Alc/pulseaudio.c53
1 files changed, 37 insertions, 16 deletions
diff --git a/Alc/pulseaudio.c b/Alc/pulseaudio.c
index ee1499cf..2104d8c1 100644
--- a/Alc/pulseaudio.c
+++ b/Alc/pulseaudio.c
@@ -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;