aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-10-23 10:56:25 +0200
committerMax Kellermann <max@duempel.org>2009-10-23 10:56:25 +0200
commitac830468bf5bad039dd7198bdbd3b73ceb6c7b32 (patch)
tree5a0b1b94f9335bf2fb60228cab006e7df1d34074 /src
parent7547b1170bbdcdf394891c5a7c8a23dbd686f483 (diff)
downloadmpd-ac830468bf5bad039dd7198bdbd3b73ceb6c7b32.tar.gz
mpd-ac830468bf5bad039dd7198bdbd3b73ceb6c7b32.tar.xz
mpd-ac830468bf5bad039dd7198bdbd3b73ceb6c7b32.zip
output/jack: implement methods enable()/disable()
Don't connect to JACK before MPD has daemonized.
Diffstat (limited to '')
-rw-r--r--src/output/jack_output_plugin.c40
1 files changed, 24 insertions, 16 deletions
diff --git a/src/output/jack_output_plugin.c b/src/output/jack_output_plugin.c
index 628594a15..fba921e04 100644
--- a/src/output/jack_output_plugin.c
+++ b/src/output/jack_output_plugin.c
@@ -210,7 +210,6 @@ mpd_jack_init(G_GNUC_UNUSED const struct audio_format *audio_format,
{
struct jack_data *jd;
const char *value;
- GError *error = NULL;
jd = g_new(struct jack_data, 1);
jd->name = config_get_block_string(param, "name", "mpd_jack");
@@ -240,22 +239,12 @@ mpd_jack_init(G_GNUC_UNUSED const struct audio_format *audio_format,
jd->ringbuffer_size =
config_get_block_unsigned(param, "ringbuffer_size", 32768);
- for (unsigned i = 0; i < G_N_ELEMENTS(jd->ringbuffer); ++i)
- jd->ringbuffer[i] = NULL;
-
jack_set_error_function(mpd_jack_error);
#ifdef HAVE_JACK_SET_INFO_FUNCTION
jack_set_info_function(mpd_jack_info);
#endif
- if (!mpd_jack_connect(jd, &error)) {
- /* this is non-fatal - it's enough to connect when
- playback starts */
- g_warning("%s", error->message);
- g_error_free(error);
- }
-
return jd;
}
@@ -264,6 +253,28 @@ mpd_jack_finish(void *data)
{
struct jack_data *jd = data;
+ for (unsigned i = 0; i < G_N_ELEMENTS(jd->output_ports); ++i)
+ g_free(jd->output_ports[i]);
+
+ g_free(jd);
+}
+
+static bool
+mpd_jack_enable(void *data, GError **error_r)
+{
+ struct jack_data *jd = (struct jack_data *)data;
+
+ for (unsigned i = 0; i < G_N_ELEMENTS(jd->ringbuffer); ++i)
+ jd->ringbuffer[i] = NULL;
+
+ return mpd_jack_connect(jd, error_r);
+}
+
+static void
+mpd_jack_disable(void *data)
+{
+ struct jack_data *jd = (struct jack_data *)data;
+
if (jd->client != NULL)
mpd_jack_disconnect(jd);
@@ -273,11 +284,6 @@ mpd_jack_finish(void *data)
jd->ringbuffer[i] = NULL;
}
}
-
- for (unsigned i = 0; i < G_N_ELEMENTS(jd->output_ports); ++i)
- g_free(jd->output_ports[i]);
-
- g_free(jd);
}
/**
@@ -528,6 +534,8 @@ const struct audio_output_plugin jack_output_plugin = {
.test_default_device = mpd_jack_test_default_device,
.init = mpd_jack_init,
.finish = mpd_jack_finish,
+ .enable = mpd_jack_enable,
+ .disable = mpd_jack_disable,
.open = mpd_jack_open,
.play = mpd_jack_play,
.pause = mpd_jack_pause,