Commit d113c071 authored by Max Kellermann's avatar Max Kellermann

pulse_mixer: moved code to pulse_mixer_setup()

Prepare for adding proper error handling.
parent 3be18507
......@@ -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)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment