diff options
author | Chris Robinson <[email protected]> | 2012-02-19 14:07:44 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2012-02-19 14:07:44 -0800 |
commit | e4f14fdc6104c0341bb3c44bf61fc7edd369caa7 (patch) | |
tree | 0ed2fcb28381a11d426681621a227bca71a2cfa5 /Alc | |
parent | 418c76649346876fd99b0d091201bbad61c604fd (diff) |
Check the pulse spawn-server config option before testing a connection to pulseaudio
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/backends/pulseaudio.c | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/Alc/backends/pulseaudio.c b/Alc/backends/pulseaudio.c index 041dfe83..9d7c10b5 100644 --- a/Alc/backends/pulseaudio.c +++ b/Alc/backends/pulseaudio.c @@ -284,11 +284,9 @@ static pa_context *connect_context(pa_threaded_mainloop *loop, ALboolean silent) static ALCboolean pulse_load(void) //{{{ { - ALCboolean ret = ALC_FALSE; + ALCboolean ret = ALC_TRUE; if(!pa_handle) { - pa_threaded_mainloop *loop; - #ifdef HAVE_DYNLOAD #ifdef _WIN32 @@ -305,9 +303,7 @@ static ALCboolean pulse_load(void) //{{{ #define LOAD_FUNC(x) do { \ p##x = GetSymbol(pa_handle, #x); \ if(!(p##x)) { \ - CloseLib(pa_handle); \ - pa_handle = NULL; \ - return ALC_FALSE; \ + ret = ALC_FALSE; \ } \ } while(0) LOAD_FUNC(pa_context_unref); @@ -384,27 +380,7 @@ static ALCboolean pulse_load(void) //{{{ pa_handle = (void*)0xDEADBEEF; #endif - if((loop=pa_threaded_mainloop_new()) && - pa_threaded_mainloop_start(loop) >= 0) - { - pa_context *context; - - pa_threaded_mainloop_lock(loop); - context = connect_context(loop, AL_TRUE); - if(context) - { - ret = ALC_TRUE; - - pa_context_disconnect(context); - pa_context_unref(context); - } - pa_threaded_mainloop_unlock(loop); - pa_threaded_mainloop_stop(loop); - } - if(loop) - pa_threaded_mainloop_free(loop); - - if(!ret) + if(ret == ALC_FALSE) { #ifdef HAVE_DYNLOAD CloseLib(pa_handle); @@ -1320,16 +1296,40 @@ static const BackendFuncs pulse_funcs = { //{{{ ALCboolean alc_pulse_init(BackendFuncs *func_list) //{{{ { - if(!pulse_load()) - return ALC_FALSE; + ALCboolean ret = ALC_FALSE; - *func_list = pulse_funcs; + if(pulse_load()) + { + pa_threaded_mainloop *loop; - pulse_ctx_flags = 0; - if(!GetConfigValueBool("pulse", "spawn-server", 0)) - pulse_ctx_flags |= PA_CONTEXT_NOAUTOSPAWN; + pulse_ctx_flags = 0; + if(!GetConfigValueBool("pulse", "spawn-server", 0)) + pulse_ctx_flags |= PA_CONTEXT_NOAUTOSPAWN; - return ALC_TRUE; + if((loop=pa_threaded_mainloop_new()) && + pa_threaded_mainloop_start(loop) >= 0) + { + pa_context *context; + + pa_threaded_mainloop_lock(loop); + context = connect_context(loop, AL_TRUE); + if(context) + { + ret = ALC_TRUE; + + pa_context_disconnect(context); + pa_context_unref(context); + } + pa_threaded_mainloop_unlock(loop); + pa_threaded_mainloop_stop(loop); + } + if(loop) + pa_threaded_mainloop_free(loop); + } + + if(ret != ALC_FALSE) + *func_list = pulse_funcs; + return ret; } //}}} void alc_pulse_deinit(void) //{{{ |