From 7558cca5c0bd954dc3db559c0d58ae6e497b13c0 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sun, 8 Apr 2007 23:13:18 +0000 Subject: Add generic audio service init --- audio/main.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 2 deletions(-) (limited to 'audio/main.c') 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 #endif -#include -#include +#include +#include +#include + +#include + +#include + +#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; } -- cgit