summaryrefslogtreecommitdiffstats
path: root/audio/main.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2007-04-08 23:13:18 +0000
committerMarcel Holtmann <marcel@holtmann.org>2007-04-08 23:13:18 +0000
commit7558cca5c0bd954dc3db559c0d58ae6e497b13c0 (patch)
tree788dbf1e68739db12abb4bc73a0d15c4d8e66218 /audio/main.c
parentebfe5886d05091a0d2398182a432241435ae2956 (diff)
Add generic audio service init
Diffstat (limited to 'audio/main.c')
-rw-r--r--audio/main.c62
1 files changed, 60 insertions, 2 deletions
diff --git a/audio/main.c b/audio/main.c
index 2f3a1fa0..08194d82 100644
--- a/audio/main.c
+++ b/audio/main.c
@@ -25,16 +25,74 @@
#include <config.h>
#endif
-#include <stdio.h>
-#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <signal.h>
+
+#include <glib.h>
+
+#include <dbus/dbus.h>
+
+#include "dbus.h"
+#include "logging.h"
#include "manager.h"
+#include "headset.h"
+
+static GMainLoop *main_loop = NULL;
+
+static void sig_term(int sig)
+{
+ g_main_loop_quit(main_loop);
+}
int main(int argc, char *argv[])
{
+ DBusConnection *conn;
+ struct sigaction sa;
+
+ start_logging("audio", "Bluetooth Audio daemon");
+
+ memset(&sa, 0, sizeof(sa));
+ sa.sa_flags = SA_NOCLDSTOP;
+ sa.sa_handler = sig_term;
+ sigaction(SIGTERM, &sa, NULL);
+ sigaction(SIGINT, &sa, NULL);
+
+ sa.sa_handler = SIG_IGN;
+ sigaction(SIGCHLD, &sa, NULL);
+ sigaction(SIGPIPE, &sa, NULL);
+
+ enable_debug();
+
+ main_loop = g_main_loop_new(NULL, FALSE);
+
+ conn = dbus_bus_system_setup_with_main_loop(NULL, NULL, NULL);
+ if (!conn) {
+ g_main_loop_unref(main_loop);
+ exit(1);
+ }
+
audio_init();
+ headset_init(conn);
+
+ if (argc > 1 && !strcmp(argv[1], "-s"))
+ register_external_service(conn, "audio", "Audio service", "");
+
+ g_main_loop_run(main_loop);
+
+ headset_exit();
+
audio_exit();
+ dbus_connection_unref(conn);
+
+ g_main_loop_unref(main_loop);
+
+ info("Exit");
+
+ stop_logging();
+
return 0;
}