Fix unused-parameter warnings in plain C code
[ladish.git] / proxies / jmcore_proxy.c
blobece883b28d49631bba7b2573205bb0f5a8617f89
1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
2 /*
3 * LADI Session Handler (ladish)
5 * Copyright (C) 2010,2011,2012 Nedko Arnaudov <nedko@arnaudov.name>
7 **************************************************************************
8 * This file contains code that interfaces the jmcore through D-Bus
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 "jmcore_proxy.h"
28 #include "../dbus_constants.h"
30 int64_t g_jmcore_pid;
32 static void on_jmcore_life_status_changed(bool UNUSED(appeared))
34 g_jmcore_pid = 0;
37 bool jmcore_proxy_init(void)
39 if (!cdbus_register_service_lifetime_hook(cdbus_g_dbus_connection, JMCORE_SERVICE_NAME, on_jmcore_life_status_changed))
41 log_error("dbus_register_service_lifetime_hook() failed for a2j service");
42 return false;
45 return jmcore_proxy_get_pid_noncached(&g_jmcore_pid);
48 void jmcore_proxy_uninit(void)
50 cdbus_unregister_service_lifetime_hook(cdbus_g_dbus_connection, JMCORE_SERVICE_NAME);
53 int64_t jmcore_proxy_get_pid_cached(void)
55 if (g_jmcore_pid == 0)
57 jmcore_proxy_get_pid_noncached(&g_jmcore_pid);
60 return g_jmcore_pid;
63 bool jmcore_proxy_get_pid_noncached(int64_t * pid_ptr)
65 if (!cdbus_call(0, JMCORE_SERVICE_NAME, JMCORE_OBJECT_PATH, JMCORE_IFACE, "get_pid", "", "x", pid_ptr))
67 log_error("jmcore::get_pid() failed.");
68 return false;
71 return true;
74 bool jmcore_proxy_create_link(bool midi, const char * input_port_name, const char * output_port_name)
76 dbus_bool_t dbus_midi = midi;
78 if (!cdbus_call(0, JMCORE_SERVICE_NAME, JMCORE_OBJECT_PATH, JMCORE_IFACE, "create", "bss", &dbus_midi, &input_port_name, &output_port_name, ""))
80 log_error("jmcore::create() failed: %s", cdbus_call_last_error_get_message());
81 return false;
84 return true;
87 bool jmcore_proxy_destroy_link(const char * port_name)
89 if (!cdbus_call(0, JMCORE_SERVICE_NAME, JMCORE_OBJECT_PATH, JMCORE_IFACE, "destroy", "s", &port_name, ""))
91 log_error("jmcore::destroy() failed.");
92 return false;
95 return true;