rename daemon/dbus_iface_control to daemon/control
[ladish.git] / daemon / jack.c
blobe22f88526f32b3eb770f1a7ac089be6030d37571
1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
2 /*
3 * LADI Session Handler (ladish)
5 * Copyright (C) 2009 Nedko Arnaudov <nedko@arnaudov.name>
7 **************************************************************************
8 * This file contains code for JACK server monitor and control
9 **************************************************************************
11 * LADI Session Handler is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * LADI Session Handler is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with LADI Session Handler. If not, see <http://www.gnu.org/licenses/>
23 * or write to the Free Software Foundation, Inc.,
24 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
27 #include "jack.h"
28 #include "../jack_proxy.h"
29 #include "studio.h"
30 #include "control.h"
32 void
33 on_jack_server_started(
34 void)
36 lash_info("JACK server start detected.");
38 if (g_studio == NULL)
40 if (!studio_create(&g_studio))
42 lash_error("failed to create studio object");
43 return;
47 if (!studio_fetch_jack_settings(g_studio))
49 lash_error("studio_fetch_jack_settings() failed.");
51 if (!studio_is_persisted(g_studio))
53 emit_studio_disappeared();
54 studio_destroy(g_studio);
55 g_studio = NULL;
56 return;
60 lash_info("jack conf successfully retrieved");
61 studio_activate(g_studio);
62 emit_studio_appeared();
63 studio_save(g_studio, NULL); /* XXX - to test save functionality, we should not save unless requested by user */
64 return;
67 void
68 on_jack_server_stopped(
69 void)
71 lash_info("JACK server stop detected.");
73 if (g_studio == NULL)
75 return;
78 if (!studio_is_persisted(g_studio))
80 emit_studio_disappeared();
81 studio_destroy(g_studio);
82 g_studio = NULL;
83 return;
86 /* TODO: if user wants, restart jack server and reconnect all jack apps to it */
89 void
90 on_jack_server_appeared(
91 void)
93 lash_info("JACK controller appeared.");
96 void
97 on_jack_server_disappeared(
98 void)
100 lash_info("JACK controller disappeared.");
103 bool
104 jack_init(
105 void)
107 bool started;
109 if (!jack_proxy_init(
110 on_jack_server_started,
111 on_jack_server_stopped,
112 on_jack_server_appeared,
113 on_jack_server_disappeared))
115 return false;
118 if (jack_proxy_is_started(&started) && started)
120 on_jack_server_started();
123 return true;
126 void
127 jack_uninit(
128 void)
130 jack_proxy_uninit();