diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2007-01-21 21:01:01 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2007-01-21 21:01:01 +0000 |
commit | b7506049ed9fc1704b2b422af3dedd22f8a5b066 (patch) | |
tree | e221f85b27f762d2d202255b9dac78837aa1d3b0 /audio | |
parent | 5dfe8c66b395c74fd6b6b3cdcb3eb54f7a9bfc18 (diff) |
Fix setup routine for headset
Diffstat (limited to 'audio')
-rw-r--r-- | audio/headset.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/audio/headset.c b/audio/headset.c index 0be529ec..c5d17315 100644 --- a/audio/headset.c +++ b/audio/headset.c @@ -964,7 +964,11 @@ static void create_server_socket(void) return; } + g_io_channel_set_close_on_unref(server_sk, TRUE); + g_io_add_watch(server_sk, G_IO_IN, (GIOFunc) server_io_cb, NULL); + + g_io_channel_unref(server_sk); } static DBusHandlerResult hs_message(DBusConnection *conn, @@ -1007,13 +1011,9 @@ static const DBusObjectPathVTable hs_table = { .message_function = hs_message, }; -int headset_dbus_init(char *bda) +int setup_dbus(DBusConnection *conn) { - connection = init_dbus(NULL, NULL, NULL); - if (!connection) - return -1; - - if (!dbus_connection_register_object_path(connection, hs_path, + if (!dbus_connection_register_object_path(conn, hs_path, &hs_table, NULL)) { error("D-Bus failed to register %s path", hs_path); return -1; @@ -1492,6 +1492,7 @@ static DBusHandlerResult hs_stop(DBusConnection *conn, DBusMessage *msg) int main(int argc, char *argv[]) { + DBusConnection *system_bus; struct sigaction sa; int opt; @@ -1534,8 +1535,17 @@ int main(int argc, char *argv[]) main_loop = g_main_loop_new(NULL, FALSE); - if (headset_dbus_init(NULL) < 0) { - error("Unable to get on D-Bus"); + system_bus = init_dbus(NULL, NULL, NULL); + if (!system_bus) { + error("Connection to system bus failed"); + g_main_loop_unref(main_loop); + exit(1); + } + + if (setup_dbus(system_bus) < 0) { + error("Connection setup failed"); + dbus_connection_unref(system_bus); + g_main_loop_unref(main_loop); exit(1); } @@ -1543,5 +1553,9 @@ int main(int argc, char *argv[]) g_main_loop_run(main_loop); + dbus_connection_unref(system_bus); + + g_main_loop_unref(main_loop); + return 0; } |