aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/mixer/pulse_mixer.c41
1 files 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)
{