aboutsummaryrefslogtreecommitdiffstats
path: root/src/mixer
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-03-26 19:49:39 +0100
committerMax Kellermann <max@duempel.org>2009-03-26 19:49:39 +0100
commitd113c07190c620c9b6c79786eb8c441b839d28fd (patch)
tree38d5f5bdc72f0d08f6d1d7ee417e330bbfc59b8a /src/mixer
parent3be1850744c71153ce12abe6cda3a751e714f8fb (diff)
downloadmpd-d113c07190c620c9b6c79786eb8c441b839d28fd.tar.gz
mpd-d113c07190c620c9b6c79786eb8c441b839d28fd.tar.xz
mpd-d113c07190c620c9b6c79786eb8c441b839d28fd.zip
pulse_mixer: moved code to pulse_mixer_setup()
Prepare for adding proper error handling.
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)
{