From d113c07190c620c9b6c79786eb8c441b839d28fd Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 26 Mar 2009 19:49:39 +0100 Subject: pulse_mixer: moved code to pulse_mixer_setup() Prepare for adding proper error handling. --- src/mixer/pulse_mixer.c | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/src/mixer/pulse_mixer.c b/src/mixer/pulse_mixer.c index a300a29fa..5d458b18f 100644 --- a/src/mixer/pulse_mixer.c +++ b/src/mixer/pulse_mixer.c @@ -192,22 +192,8 @@ pulse_mixer_finish(struct mixer *data) } static bool -pulse_mixer_open(G_GNUC_UNUSED struct mixer *data) +pulse_mixer_setup(struct pulse_mixer *pm) { - struct pulse_mixer *pm = (struct pulse_mixer *) data; - g_debug("pulse mixer open"); - - if(!(pm->mainloop = pa_threaded_mainloop_new())) { - g_debug("failed mainloop"); - return false; - } - - if(!(pm->context = pa_context_new(pa_threaded_mainloop_get_api(pm->mainloop), - "Mixer mpd"))) { - g_debug("failed context"); - return false; - } - pa_context_set_state_callback(pm->context, context_state_cb, pm); if (pa_context_connect(pm->context, pm->server, @@ -217,6 +203,7 @@ pulse_mixer_open(G_GNUC_UNUSED struct mixer *data) } pa_threaded_mainloop_lock(pm->mainloop); + if (pa_threaded_mainloop_start(pm->mainloop) < 0) { g_debug("error start mainloop"); return false; @@ -234,6 +221,30 @@ pulse_mixer_open(G_GNUC_UNUSED struct mixer *data) return true; } +static bool +pulse_mixer_open(G_GNUC_UNUSED struct mixer *data) +{ + struct pulse_mixer *pm = (struct pulse_mixer *) data; + g_debug("pulse mixer open"); + + if(!(pm->mainloop = pa_threaded_mainloop_new())) { + g_debug("failed mainloop"); + return false; + } + + if(!(pm->context = pa_context_new(pa_threaded_mainloop_get_api(pm->mainloop), + "Mixer mpd"))) { + g_debug("failed context"); + return false; + } + + if (!pulse_mixer_setup(pm)) { + return false; + } + + return true; +} + static void pulse_mixer_close(G_GNUC_UNUSED struct mixer *data) { -- cgit v1.2.3