From 02aea2b550f3e0efb2dc0a9d8c76806500eee1eb Mon Sep 17 00:00:00 2001 From: inhyeok Date: Wed, 15 Jul 2015 16:20:12 +0900 Subject: [PATCH] Launch a new daemon for Audio Stream Focus [Version] Release 0.9.240 [Profile] Common [Issue Type] Refactoring Separage Focus Server from Sound Server Change-Id: I9d1f57eb3ce0e0451c437e787fc8d7d36cbf5388 --- Makefile.am | 3 +- configure.ac | 1 + focus_server/Makefile.am | 33 + .../include/mm_sound_mgr_focus.h | 2 +- focus_server/include/mm_sound_mgr_focus_dbus.h | 17 + focus_server/include/mm_sound_mgr_focus_ipc.h | 57 ++ focus_server/mm_sound_focus_server.c | 240 +++++++ {server => focus_server}/mm_sound_mgr_focus.c | 5 +- focus_server/mm_sound_mgr_focus_dbus.c | 760 +++++++++++++++++++++ focus_server/mm_sound_mgr_focus_ipc.c | 178 +++++ mm_sound_client_dbus.c | 21 +- mm_sound_focus.c | 2 +- packaging/focus-server.conf | 26 + packaging/focus-server.path | 5 + packaging/focus-server.service | 13 + packaging/libmm-sound.spec | 15 +- server/Makefile.am | 4 - server/include/mm_sound_mgr_ipc.h | 21 - server/mm_sound_mgr_ipc.c | 145 ---- server/mm_sound_mgr_ipc_dbus.c | 311 --------- server/mm_sound_server.c | 10 +- server/mm_sound_thread_pool.c | 20 +- 22 files changed, 1377 insertions(+), 512 deletions(-) create mode 100644 focus_server/Makefile.am rename {server => focus_server}/include/mm_sound_mgr_focus.h (98%) create mode 100644 focus_server/include/mm_sound_mgr_focus_dbus.h create mode 100644 focus_server/include/mm_sound_mgr_focus_ipc.h create mode 100644 focus_server/mm_sound_focus_server.c rename {server => focus_server}/mm_sound_mgr_focus.c (99%) create mode 100644 focus_server/mm_sound_mgr_focus_dbus.c create mode 100644 focus_server/mm_sound_mgr_focus_ipc.c create mode 100644 packaging/focus-server.conf create mode 100644 packaging/focus-server.path create mode 100644 packaging/focus-server.service diff --git a/Makefile.am b/Makefile.am index 6f946c9..2c3bfde 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,7 +2,8 @@ SUBDIRS = common \ pkgconfig \ . \ server \ - testsuite + testsuite \ + focus_server lib_LTLIBRARIES = libmmfsound.la diff --git a/configure.ac b/configure.ac index 06b99ee..df9dd47 100644 --- a/configure.ac +++ b/configure.ac @@ -146,6 +146,7 @@ server/plugin/wav/Makefile server/plugin/ogg/Makefile server/plugin/keytone/Makefile server/plugin/tone/Makefile +focus_server/Makefile pkgconfig/Makefile pkgconfig/mm-sound.pc pkgconfig/mm-keysound.pc diff --git a/focus_server/Makefile.am b/focus_server/Makefile.am new file mode 100644 index 0000000..c732436 --- /dev/null +++ b/focus_server/Makefile.am @@ -0,0 +1,33 @@ +bin_PROGRAMS = focus_server +focus_server_SOURCES = mm_sound_mgr_focus_ipc.c \ + mm_sound_mgr_focus_dbus.c \ + mm_sound_focus_server.c \ + mm_sound_mgr_focus.c + +focus_server_CFLAGS = -I$(srcdir)/../include \ + -I$(srcdir)/include \ + $(MMCOMMON_CFLAGS) \ + $(MMLOGSVR_CFLAGS) \ + -DMMF_LOG_OWNER=0x004 \ + -DMMF_DEBUG_PREFIX=\"MMF-SOUND\" \ + -D__DEBUG_MODE__ -DUSE_VCONF -D__USE_LOGMANAGER__ \ + $(VCONF_CFLAGS) \ + $(GLIB2_CFLAGS) \ + $(GIO_CFLAGS) + +focus_server_LDADD = $(MMLOGSVR_LIBS) \ + -ldl -lrt \ + $(MMCOMMON_LIBS) \ + $(GLIB2_LIBS) \ + $(GIO_LIBS) \ + $(VCONF_LIBS) \ + $(srcdir)/../libmmfsound.la \ + $(srcdir)/../common/libmmfsoundcommon.la + +if USE_SECURITY +focus_server_CFLAGS += $(SECURITY_CFLAGS) -DUSE_SECURITY +focus_server_LDADD += $(SECURITY_LIBS) +endif + +focus_server_DEPENDENCIES = $(srcdir)/../common/libmmfsoundcommon.la +focus_server_CFLAGS += -fPIC -pie diff --git a/server/include/mm_sound_mgr_focus.h b/focus_server/include/mm_sound_mgr_focus.h similarity index 98% rename from server/include/mm_sound_mgr_focus.h rename to focus_server/include/mm_sound_mgr_focus.h index 941d056..75eb45f 100644 --- a/server/include/mm_sound_mgr_focus.h +++ b/focus_server/include/mm_sound_mgr_focus.h @@ -26,7 +26,7 @@ #include "../include/mm_sound_focus.h" #include "../include/mm_sound_stream.h" #include "../include/mm_ipc.h" -#include "mm_sound_mgr_ipc.h" +#include "mm_sound_mgr_focus_ipc.h" typedef enum { diff --git a/focus_server/include/mm_sound_mgr_focus_dbus.h b/focus_server/include/mm_sound_mgr_focus_dbus.h new file mode 100644 index 0000000..37a879a --- /dev/null +++ b/focus_server/include/mm_sound_mgr_focus_dbus.h @@ -0,0 +1,17 @@ +#ifndef __MM_SOUND_MGR_FOCUS_DBUS_H__ +#define __MM_SOUND_MGR_FOCUS_DBUS_H__ + +#include +#include "../include/mm_sound_device.h" +#include "../include/mm_sound_stream.h" + + +int mm_sound_mgr_focus_dbus_send_signal_freeze (char* command, int pid); + +int __mm_sound_mgr_focus_dbus_get_stream_list(stream_list_t* stream_list); + +int MMSoundMgrFocusDbusInit(void); +void MMSoundMgrFocusDbusFini(void); + + +#endif /* __MM_SOUND_MGR_FOCUS_DBUS_H__ */ diff --git a/focus_server/include/mm_sound_mgr_focus_ipc.h b/focus_server/include/mm_sound_mgr_focus_ipc.h new file mode 100644 index 0000000..46cc7ba --- /dev/null +++ b/focus_server/include/mm_sound_mgr_focus_ipc.h @@ -0,0 +1,57 @@ +/* + * libmm-sound + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Seungbae Shin + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef __MM_SOUND_MGR_FOCUS_IPC_H__ +#define __MM_SOUND_MGR_FOCUS_IPC_H__ + +#include "../../include/mm_sound_msg.h" + +#ifdef SUPPORT_CONTAINER +typedef struct container_info +{ + int pid; + char name[64]; +} container_info_t; +#endif + +//int __mm_sound_mgr_ipc_create_focus_node(mm_ipc_msg_t *msg); +#ifdef SUPPORT_CONTAINER +int __mm_sound_mgr_focus_ipc_register_focus(int client_pid, int handle_id, char* stream_type ,const char* container_name, int container_pid); +#else +int __mm_sound_mgr_focus_ipc_register_focus(int client_pid, int handle_id, char* stream_type); +#endif +//int __mm_sound_mgr_ipc_destroy_focus_node(mm_ipc_msg_t *msg); +int __mm_sound_mgr_focus_ipc_unregister_focus(int pid, int handle_id); + +int __mm_sound_mgr_focus_ipc_acquire_focus(int pid, int handle_id, int focus_type, const char* name ); + +int __mm_sound_mgr_focus_ipc_release_focus(int pid, int handle_id, int focus_type, const char* name); +//int __mm_sound_mgr_ipc_set_focus_watch_cb(mm_ipc_msg_t *msg); +#ifdef SUPPORT_CONTAINER +int __mm_sound_mgr_focus_ipc_watch_focus(int pid, int handle_id, int focus_type, const char* container_name, int container_pid); +#else +int __mm_sound_mgr_focus_ipc_watch_focus(int pid, int handle_id, int focus_type); +#endif +//int __mm_sound_mgr_ipc_unset_focus_watch_cb(mm_ipc_msg_t *msg); +int __mm_sound_mgr_focus_ipc_unwatch_focus(int pid, int handle_id); + +#endif /* __MM_SOUND_MGR_FOCUS_IPC_H__ */ + diff --git a/focus_server/mm_sound_focus_server.c b/focus_server/mm_sound_focus_server.c new file mode 100644 index 0000000..ea7aff4 --- /dev/null +++ b/focus_server/mm_sound_focus_server.c @@ -0,0 +1,240 @@ +/* + * libmm-sound + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Seungbae Shin + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include + + +#include "../include/mm_sound_common.h" +#include "../include/mm_sound_utils.h" +#include "include/mm_sound_mgr_focus_ipc.h" +#include "include/mm_sound_mgr_focus_dbus.h" + +#include + +#define USE_SYSTEM_SERVER_PROCESS_MONITORING + +typedef struct { + int startserver; + int printlist; + int testmode; +} server_arg; + +static int getOption(int argc, char **argv, server_arg *arg); +static int usage(int argc, char **argv); + +static struct sigaction sigint_action; /* Backup pointer of SIGINT handler */ +static struct sigaction sigabrt_action; /* Backup pointer of SIGABRT signal handler */ +static struct sigaction sigsegv_action; /* Backup pointer of SIGSEGV fault signal handler */ +static struct sigaction sigterm_action; /* Backup pointer of SIGTERM signal handler */ +static struct sigaction sigsys_action; /* Backup pointer of SIGSYS signal handler */ +static void _exit_handler(int sig); + +GMainLoop *g_mainloop; + +void* pulse_handle; + +void mainloop_run() +{ + g_mainloop = g_main_loop_new(NULL, TRUE); + if(g_mainloop == NULL) { + debug_error("g_main_loop_new() failed\n"); + } + g_main_loop_run(g_mainloop); +} + +int main(int argc, char **argv) +{ + server_arg serveropt; + struct sigaction action; +#if !defined(USE_SYSTEM_SERVER_PROCESS_MONITORING) + int pid; +#endif + + action.sa_handler = _exit_handler; + action.sa_flags = 0; + sigemptyset(&action.sa_mask); + + if (getOption(argc, argv, &serveropt)) + return 1; + + debug_warning("focus_server [%d] init \n", getpid()); + + /* Daemon process create */ + if (!serveropt.testmode && serveropt.startserver) { +#if !defined(USE_SYSTEM_SERVER_PROCESS_MONITORING) + daemon(0,0); //chdir to ("/"), and close stdio +#endif + } + + /* focus Server Starts!!!*/ + debug_warning("focus_server [%d] start \n", getpid()); + + signal(SIGPIPE, SIG_IGN); //ignore SIGPIPE + +#if !defined(USE_SYSTEM_SERVER_PROCESS_MONITORING) + while(1) + { + if ((pid = fork()) < 0) + { + fprintf(stderr, "Sub Fork Error\n"); + return 2; + } + else if(pid == 0) + { + break; + } + else if(pid > 0) + { + wait(&ret); + fprintf(stderr, "Killed by signal [%05X]\n", ret); + fprintf(stderr, "Daemon is run againg\n"); + } + } +#endif + sigaction(SIGABRT, &action, &sigabrt_action); + sigaction(SIGSEGV, &action, &sigsegv_action); + sigaction(SIGTERM, &action, &sigterm_action); + sigaction(SIGSYS, &action, &sigsys_action); + + if (serveropt.startserver) { + MMSoundMgrFocusDbusInit(); + MMSoundMgrFocusInit(); + } + + debug_warning("focus_server [%d] initialization complete...now, start running!!\n", getpid()); + + if (serveropt.startserver) { +// unlink(PA_READY); // remove pa_ready file after focus-server init. + + mainloop_run(); + } + + debug_warning("focus_server [%d] terminating \n", getpid()); + + if (serveropt.startserver) { + MMSoundMgrFocusDbusFini(); + MMSoundMgrFocusFini(); + } + + debug_warning("focus_server [%d] exit ----------------- END \n", getpid()); + + return 0; +} + +static int getOption(int argc, char **argv, server_arg *arg) +{ + int c; + static struct option long_options[] = { + {"start", 0, 0, 'S'}, + {"help", 0, 0, 'H'}, + {"testmode", 0, 0, 'T'}, + {0, 0, 0, 0} + }; + memset(arg, 0, sizeof(server_arg)); + + arg->testmode = 0; + + while (1) + { + int opt_idx = 0; + + c = getopt_long (argc, argv, "SFLHRUP:Tiurd", long_options, &opt_idx); + if (c == -1) + break; + switch (c) + { + case 'S': /* Start daemon */ + arg->startserver = 1; + break; + case 'T': /* Test mode */ + arg->testmode = 1; + break; + case 'H': /* help msg */ + default: + return usage(argc, argv); + } + } + if (argc == 1) + return usage(argc, argv); + return 0; +} + +//__attribute__ ((destructor)) +static void _exit_handler(int sig) +{ + int ret = MM_ERROR_NONE; + + switch(sig) + { + case SIGINT: + sigaction(SIGINT, &sigint_action, NULL); + debug_error("signal(SIGINT) error"); + break; + case SIGABRT: + sigaction(SIGABRT, &sigabrt_action, NULL); + debug_error("signal(SIGABRT) error"); + break; + case SIGSEGV: + sigaction(SIGSEGV, &sigsegv_action, NULL); + debug_error("signal(SIGSEGV) error"); + break; + case SIGTERM: + sigaction(SIGTERM, &sigterm_action, NULL); + debug_error("signal(SIGTERM) error"); + break; + case SIGSYS: + sigaction(SIGSYS, &sigsys_action, NULL); + debug_error("signal(SIGSYS) error"); + break; + default: + break; + } + raise(sig); +} + +static int usage(int argc, char **argv) +{ + fprintf(stderr, "Usage: %s [Options]\n", argv[0]); + fprintf(stderr, "\t%-20s: start focus server.\n", "--start,-S"); + fprintf(stderr, "\t%-20s: help message.\n", "--help,-H"); + + return 1; +} + diff --git a/server/mm_sound_mgr_focus.c b/focus_server/mm_sound_mgr_focus.c similarity index 99% rename from server/mm_sound_mgr_focus.c rename to focus_server/mm_sound_mgr_focus.c index 9da72f6..c0faa40 100644 --- a/server/mm_sound_mgr_focus.c +++ b/focus_server/mm_sound_mgr_focus.c @@ -22,7 +22,6 @@ #include #include "include/mm_sound_mgr_focus.h" -#include "include/mm_sound_thread_pool.h" #include "../include/mm_sound_common.h" #include "../include/mm_sound_stream.h" @@ -32,7 +31,7 @@ #include #include -#include "include/mm_sound_mgr_ipc.h" +#include "include/mm_sound_mgr_focus_ipc.h" #include "../include/mm_sound_utils.h" #include #include @@ -933,7 +932,7 @@ int MMSoundMgrFocusInit(void) int ret = MM_ERROR_NONE; debug_fenter(); - ret = __mm_sound_mgr_ipc_dbus_get_stream_list(&g_stream_list); + ret = __mm_sound_mgr_focus_dbus_get_stream_list(&g_stream_list); if (ret) debug_error("failed to __mm_sound_mgr_ipc_dbus_get_stream_list()\n"); diff --git a/focus_server/mm_sound_mgr_focus_dbus.c b/focus_server/mm_sound_mgr_focus_dbus.c new file mode 100644 index 0000000..4f11963 --- /dev/null +++ b/focus_server/mm_sound_mgr_focus_dbus.c @@ -0,0 +1,760 @@ + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#ifdef USE_SECURITY +#include +#define COOKIE_SIZE 20 +#endif + +#include "include/mm_sound_mgr_focus_dbus.h" +#include "include/mm_sound_mgr_focus_ipc.h" + + +#define BUS_NAME_FOCUS_SERVER "org.tizen.FocusServer" +#define OBJECT_FOCUS_SERVER "/org/tizen/FocusServer1" +#define INTERFACE_FOCUS_SERVER "org.tizen.FocusServer1" + +/* Introspection data for the service we are exporting */ + static const gchar introspection_xml[] = + "" + " " + " " +#ifdef SUPPORT_CONTAINER +#ifdef USE_SECURITY + " " +#else + " " +#endif +#endif + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " +#ifdef SUPPORT_CONTAINER +#ifdef USE_SECURITY + " " +#else + " " +#endif +#endif + " " + " " + " " + " " + " " + " " + " " + " " + " " + ""; +GDBusConnection* conn_g; + +typedef void (*dbus_method_handler)(GDBusMethodInvocation *invocation); +typedef int (*dbus_signal_sender)(GDBusConnection *conn, GVariant *parameter); + +struct mm_sound_mgr_focus_dbus_method{ + struct mm_sound_dbus_method_info info; + dbus_method_handler handler; +}; + +struct mm_sound_mgr_focus_dbus_signal{ + struct mm_sound_dbus_signal_info info; + dbus_signal_sender sender; +}; + +static void handle_method_register_focus(GDBusMethodInvocation* invocation); +static void handle_method_unregister_focus(GDBusMethodInvocation* invocation); +static void handle_method_acquire_focus(GDBusMethodInvocation* invocation); +static void handle_method_release_focus(GDBusMethodInvocation* invocation); +static void handle_method_watch_focus(GDBusMethodInvocation* invocation); +static void handle_method_unwatch_focus(GDBusMethodInvocation* invocation); + +/* Currently , Just using method's name and handler */ +/* TODO : generate introspection xml automatically, with these value include argument and reply */ +/* TODO : argument check with these information */ +/* TODO : divide object and interface with features (ex. play, path, device, focus, asm) */ +struct mm_sound_mgr_focus_dbus_method methods[METHOD_CALL_MAX] = { + [METHOD_CALL_REGISTER_FOCUS] = { + .info = { + .name = "RegisterFocus", + }, + .handler = handle_method_register_focus + }, + [METHOD_CALL_UNREGISTER_FOCUS] = { + .info = { + .name = "UnregisterFocus", + }, + .handler = handle_method_unregister_focus + }, + [METHOD_CALL_ACQUIRE_FOCUS] = { + .info = { + .name = "AcquireFocus", + }, + .handler = handle_method_acquire_focus + }, + [METHOD_CALL_RELEASE_FOCUS] = { + .info = { + .name = "ReleaseFocus", + }, + .handler = handle_method_release_focus + }, + [METHOD_CALL_WATCH_FOCUS] = { + .info = { + .name = "WatchFocus", + }, + .handler = handle_method_watch_focus + }, + [METHOD_CALL_UNWATCH_FOCUS] = { + .info = { + .name = "UnwatchFocus", + }, + .handler = handle_method_unwatch_focus + }, +}; + + +struct mm_sound_mgr_focus_dbus_signal signals[SIGNAL_MAX] = { + [SIGNAL_TEST] = { + .info = { + .name = "SignalTest1", + }, + }, + [SIGNAL_FOCUS_CHANGED] = { + .info = { + .name = "FocusChanged", + }, + }, + [SIGNAL_FOCUS_WATCH] = { + .info = { + .name = "FocusWatch", + }, + } +}; + + +static GDBusNodeInfo *introspection_data = NULL; +guint focus_server_owner_id ; + +/* + For pass error code with 'g_dbus_method_invocation_return_error' + We have to use some glib features like GError, GQuark +*/ +/* Only For error types which is currently being used in server-side */ +static const GDBusErrorEntry mm_sound_error_entries[] = +{ + {MM_ERROR_OUT_OF_MEMORY, "org.tizen.multimedia.OutOfMemory"}, + {MM_ERROR_OUT_OF_STORAGE, "org.tizen.multimedia.OutOfStorage"}, + {MM_ERROR_INVALID_ARGUMENT, "org.tizen.multimedia.InvalidArgument"}, + {MM_ERROR_POLICY_INTERNAL, "org.tizen.multimedia.PolicyInternal"}, + {MM_ERROR_NOT_SUPPORT_API, "org.tizen.multimedia.NotSupportAPI"}, + {MM_ERROR_POLICY_BLOCKED, "org.tizen.multimedia.PolicyBlocked"}, + {MM_ERROR_END_OF_FILE, "org.tizen.multimedia.EndOfFile"}, + {MM_ERROR_COMMON_OUT_OF_RANGE, "org.tizen.multimedia.common.OutOfRange"}, + {MM_ERROR_COMMON_UNKNOWN, "org.tizen.multimedia.common.Unknown"}, + {MM_ERROR_COMMON_NO_FREE_SPACE, "org.tizen.multimedia.common.NoFreeSpace"}, + {MM_ERROR_SOUND_INTERNAL, "org.tizen.multimedia.audio.Internal"}, + {MM_ERROR_SOUND_INVALID_STATE, "org.tizen.multimedia.audio.InvalidState"}, + {MM_ERROR_SOUND_NO_FREE_SPACE, "org.tizen.multimedia.audio.NoFreeSpace"}, + {MM_ERROR_SOUND_UNSUPPORTED_MEDIA_TYPE, "org.tizen.multimedia.audio.UnsupportedMediaType"}, + {MM_ERROR_SOUND_INVALID_POINTER, "org.tizen.multimedia.audio.InvalidPointer"}, + {MM_ERROR_SOUND_INVALID_FILE, "org.tizen.multimedia.audio.InvalidFile"}, + {MM_ERROR_SOUND_FILE_NOT_FOUND, "org.tizen.multimedia.audio.FileNotFound"}, + {MM_ERROR_SOUND_NO_DATA, "org.tizen.multimedia.audio.NoData"}, + {MM_ERROR_SOUND_INVALID_PATH, "org.tizen.multimedia.audio.InvalidPath"}, +}; + +static const char* _convert_error_code(int err_code) +{ + int i = 0; + + for (i = 0; i < G_N_ELEMENTS(mm_sound_error_entries); i++) { + if (err_code == mm_sound_error_entries[i].error_code) { + return mm_sound_error_entries[i].dbus_error_name; + } + } + + return "org.tizen.multimedia.common.Unknown"; +} + + +static int mm_sound_mgr_focus_dbus_send_signal(int signal_type, GVariant *parameter) +{ + int ret = MM_ERROR_NONE; + GDBusConnection *conn = NULL; + GError* err = NULL; + gboolean emit_success = FALSE; + + if (signal_type < 0 || signal_type >= SIGNAL_MAX || !parameter) { + debug_error("Invalid Argument"); + return MM_ERROR_SOUND_INTERNAL; + } + + debug_log("Signal Emit : %s", signals[signal_type].info.name); + + if (!conn_g) { + conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err); + if (!conn && err) { + debug_error ("g_bus_get_sync() error (%s) ", err->message); + g_error_free (err); + return MM_ERROR_SOUND_INTERNAL; + } + conn_g = conn; + } +/* + if (!g_variant_is_of_type(parameter, G_VARIANT_TYPE(signals[signal_type].info.argument))) { + debug_error("Invalid Signal Parameter"); + return MM_ERROR_INVALID_ARGUMENT; + } + */ + + emit_success = g_dbus_connection_emit_signal(conn_g, NULL, OBJECT_FOCUS_SERVER, INTERFACE_FOCUS_SERVER, + signals[signal_type].info.name, parameter, &err); + if (!emit_success && err) { + debug_error("Emit signal (%s) failed, (%s)", signals[signal_type].info.name, err->message); + g_error_free(err); + return MM_ERROR_SOUND_INTERNAL; + } + + return ret; +} + +static int _get_sender_pid(GDBusMethodInvocation* invocation) +{ + GVariant* value; + guint pid; + const gchar* sender; + GDBusConnection * connection = NULL; + GError* err = NULL; + + connection = g_dbus_method_invocation_get_connection(invocation); + sender = g_dbus_method_invocation_get_sender(invocation); + + debug_error ("connection = %p, sender = %s", connection, sender); + + value = g_dbus_connection_call_sync (connection, "org.freedesktop.DBus", "/org/freedesktop/DBus", + "org.freedesktop.DBus", "GetConnectionUnixProcessID", + g_variant_new("(s)", sender, NULL), NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err); + if (value) { + g_variant_get(value, "(u)", &pid); + debug_error ("Sender PID = [%d]", pid); + } else { + debug_error ("err code = %d, err msg = %s", err->code, err->message); + } + return pid; +} + +static void _method_call_return_value(GDBusMethodInvocation *invocation, GVariant *params) +{ + const char *method_name; + method_name = g_dbus_method_invocation_get_method_name(invocation); + debug_error("Method Call '%s' success", method_name); + g_dbus_method_invocation_return_value(invocation, params); +} +static void _method_call_return_error(GDBusMethodInvocation *invocation, int ret) +{ + const char *err_name, *method_name; + err_name = _convert_error_code(ret); + method_name = g_dbus_method_invocation_get_method_name(invocation); + debug_error("Method Call '%s' failed, err '%s(%X)'", method_name, err_name, ret); + g_dbus_method_invocation_return_dbus_error(invocation, err_name, "failed"); +} + + +static void handle_method_register_focus(GDBusMethodInvocation* invocation) +{ + int ret = MM_ERROR_NONE; + int pid = 0, handle_id = 0; + const char* stream_type = NULL; + GVariant *params = NULL; +#ifdef SUPPORT_CONTAINER + int container_pid = -1; + char* container = NULL; +#ifdef USE_SECURITY + GVariant* cookie_data; +#endif /* USE_SECURITY */ +#endif /* SUPPORT_CONTAINER */ + + + debug_fenter(); + + if (!(params = g_dbus_method_invocation_get_parameters(invocation))) { + debug_error("Parameter for Method is NULL"); + ret = MM_ERROR_SOUND_INTERNAL; + goto send_reply; + } + +#ifdef SUPPORT_CONTAINER +#ifdef USE_SECURITY + g_variant_get(params, "(@ayiis)", &cookie_data, &container_pid, &handle_id, &stream_type); + container = _get_container_from_cookie(cookie_data); + ret = __mm_sound_mgr_focus_ipc_register_focus(_get_sender_pid(invocation), handle_id, stream_type, container, container_pid); + + if (container) + free(container); +#else /* USE_SECURITY */ + g_variant_get(params, "(siis)", &container, &container_pid, &handle_id, &stream_type); + ret = __mm_sound_mgr_focus_ipc_register_focus(_get_sender_pid(invocation), handle_id, stream_type, container, container_pid); + +#endif /* USE_SECURITY */ +#else /* SUPPORT_CONTAINER */ + g_variant_get(params, "(iis)", &pid, &handle_id, &stream_type); + ret = __mm_sound_mgr_focus_ipc_register_focus(_get_sender_pid(invocation), handle_id, stream_type); + +#endif /* SUPPORT_CONTAINER */ + +send_reply: + if (ret == MM_ERROR_NONE) { + _method_call_return_value(invocation, g_variant_new("()")); + } else { + _method_call_return_error(invocation, ret); + } + + debug_fleave(); +} + +static void handle_method_unregister_focus(GDBusMethodInvocation* invocation) +{ + + int ret = MM_ERROR_NONE; + int pid = 0, handle_id = 0; + GVariant *params = NULL; + + debug_fenter(); + + if (!(params = g_dbus_method_invocation_get_parameters(invocation))) { + debug_error("Parameter for Method is NULL"); + ret = MM_ERROR_SOUND_INTERNAL; + goto send_reply; + } + + g_variant_get(params, "(ii)", &pid, &handle_id); + ret = __mm_sound_mgr_focus_ipc_unregister_focus(_get_sender_pid(invocation), handle_id); + +send_reply: + if (ret == MM_ERROR_NONE) { + _method_call_return_value(invocation, g_variant_new("()")); + } else { + _method_call_return_error(invocation, ret); + } + + debug_fleave(); +} + +static void handle_method_acquire_focus(GDBusMethodInvocation* invocation) +{ + int ret = MM_ERROR_NONE; + int pid = 0, handle_id = 0, focus_type = 0; + const char* name = NULL; + GVariant *params = NULL; + + debug_fenter(); + + if (!(params = g_dbus_method_invocation_get_parameters(invocation))) { + debug_error("Parameter for Method is NULL"); + ret = MM_ERROR_SOUND_INTERNAL; + goto send_reply; + } + + g_variant_get(params, "(iiis)", &pid, &handle_id, &focus_type, &name); + ret = __mm_sound_mgr_focus_ipc_acquire_focus(_get_sender_pid(invocation), handle_id, focus_type, name); + +send_reply: + if (ret == MM_ERROR_NONE) { + _method_call_return_value(invocation, g_variant_new("()")); + } else { + _method_call_return_error(invocation, ret); + } + + debug_fleave(); +} + +static void handle_method_release_focus(GDBusMethodInvocation* invocation) +{ + int ret = MM_ERROR_NONE; + int pid = 0, handle_id = 0, focus_type = 0; + const char* name = NULL; + GVariant *params = NULL; + + debug_fenter(); + + if (!(params = g_dbus_method_invocation_get_parameters(invocation))) { + debug_error("Parameter for Method is NULL"); + ret = MM_ERROR_SOUND_INTERNAL; + goto send_reply; + } + + g_variant_get(params, "(iiis)", &pid, &handle_id, &focus_type, &name); + ret = __mm_sound_mgr_focus_ipc_release_focus(_get_sender_pid(invocation), handle_id, focus_type, name); + +send_reply: + if (ret == MM_ERROR_NONE) { + _method_call_return_value(invocation, g_variant_new("()")); + } else { + _method_call_return_error(invocation, ret); + } + + debug_fleave(); +} + +static void handle_method_watch_focus(GDBusMethodInvocation* invocation) +{ + int ret = MM_ERROR_NONE; + int pid = 0, handle_id = 0, focus_type = 0; + GVariant *params = NULL; +#ifdef SUPPORT_CONTAINER + int container_pid = -1; + char* container = NULL; +#ifdef USE_SECURITY + GVariant* cookie_data; +#endif /* USE_SECURITY */ +#endif /* SUPPORT_CONTAINER */ + + debug_fenter(); + + if (!(params = g_dbus_method_invocation_get_parameters(invocation))) { + debug_error("Parameter for Method is NULL"); + ret = MM_ERROR_SOUND_INTERNAL; + goto send_reply; + } + +#ifdef SUPPORT_CONTAINER +#ifdef USE_SECURITY + g_variant_get(params, "(@ayiii)", &cookie_data, &container_pid, &handle_id, &focus_type); + container = _get_container_from_cookie(cookie_data); + ret = __mm_sound_mgr_focus_ipc_watch_focus(_get_sender_pid(invocation), handle_id, focus_type, container, container_pid); + + if (container) + free(container); +#else /* USE_SECURITY */ + g_variant_get(params, "(siii)", &container, &container_pid, &handle_id, &focus_type); + ret = __mm_sound_mgr_focus_ipc_watch_focus(_get_sender_pid(invocation), handle_id, focus_type, container, container_pid); + +#endif /* USE_SECURITY */ +#else /* SUPPORT_CONTAINER */ + g_variant_get(params, "(iii)", &pid, &handle_id, &focus_type); + ret = __mm_sound_mgr_focus_ipc_watch_focus(_get_sender_pid(invocation), handle_id, focus_type); + +#endif /* SUPPORT_CONTAINER */ + +send_reply: + if (ret == MM_ERROR_NONE) { + _method_call_return_value(invocation, g_variant_new("()")); + } else { + _method_call_return_error(invocation, ret); + } + + debug_fleave(); +} + +static void handle_method_unwatch_focus (GDBusMethodInvocation* invocation) +{ + int ret = MM_ERROR_NONE; + int pid = 0; + int handle_id = 0; + GVariant *params = NULL; + + debug_fenter(); + + if (!(params = g_dbus_method_invocation_get_parameters(invocation))) { + debug_error("Parameter for Method is NULL"); + ret = MM_ERROR_SOUND_INTERNAL; + goto send_reply; + } + + g_variant_get(params, "(ii)", &pid, &handle_id); + ret = __mm_sound_mgr_focus_ipc_unwatch_focus(_get_sender_pid(invocation), handle_id); + +send_reply: + if (ret == MM_ERROR_NONE) { + _method_call_return_value(invocation, g_variant_new("()")); + } else { + _method_call_return_error(invocation, ret); + } + + debug_fleave(); +} + +/**********************************************************************************/ +static void handle_method_call(GDBusConnection *connection, + const gchar *sender, + const gchar *object_path, + const gchar *interface_name, + const gchar *method_name, + GVariant *parameters, + GDBusMethodInvocation *invocation, + gpointer userdata) +{ + int method_idx = 0; + + if (!parameters) { + debug_error("Parameter Null"); + return; + } + debug_log("Method Call, obj : %s, intf : %s, method : %s", object_path, interface_name, method_name); + + for (method_idx = METHOD_CALL_REGISTER_FOCUS; method_idx < METHOD_CALL_MAX; method_idx++) { + if (!g_strcmp0(method_name, methods[method_idx].info.name)) { + methods[method_idx].handler(invocation); + } + } +} + + +static GVariant* handle_get_property(GDBusConnection *connection, + const gchar *sender, + const gchar *object_path, + const gchar *interface_name, + const gchar *property_name, + GError **error, + gpointer userdata) +{ + debug_log("Get Property, obj : %s, intf : %s, prop : %s", object_path, interface_name, property_name); + return NULL; +} + +static gboolean handle_set_property(GDBusConnection *connection, + const gchar *sender, + const gchar *object_path, + const gchar *interface_name, + const gchar *property_name, + GVariant *value, + GError **error, + gpointer userdata) +{ + debug_log("Set Property, obj : %s, intf : %s, prop : %s", object_path, interface_name, property_name); + return TRUE; +} + +static const GDBusInterfaceVTable interface_vtable = +{ + handle_method_call, + handle_get_property, + handle_set_property +}; + +#if 0 +static void handle_signal(GDBusConnection *connection, + const gchar *sender_name, + const gchar *object_path, + const gchar *interface_name, + const gchar *signal_name, + GVariant *params, + gpointer user_data) +{ + if (!object_path || !interface_name || !signal_name) { + debug_error("Invalid Parameters"); + return; + } + + debug_log("Got Signal : Object '%s, Interface '%s', Signal '%s'", object_path, interface_name, signal_name); + + if (!g_strcmp0(object_path, OBJECT_ASM)) { + if (!g_strcmp0(interface_name, INTERFACE_ASM) && !g_strcmp0(signal_name, "EmergentExit")) { + debug_log("handle signal '%s.%s'", interface_name, signal_name); + handle_signal_asm_emergent_exit(params, user_data); + } else { + debug_log("Unknown Signal '%s.%s'", interface_name, signal_name); + } + } else { + debug_log("Unknown Object '%s'", object_path); + } + +} +#endif + +static void on_bus_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data) +{ + guint reg_id; + guint subs_id; + debug_log("Bus Acquired (%s)", name); + + conn_g = connection; + reg_id = g_dbus_connection_register_object(connection, + OBJECT_FOCUS_SERVER, + introspection_data->interfaces[0], + &interface_vtable, + NULL, + NULL, + NULL); + if (!reg_id) { + debug_error("Register object(%s) failed", OBJECT_FOCUS_SERVER); + return ; + } +#if 0 + subs_id = g_dbus_connection_signal_subscribe(connection, NULL, INTERFACE_ASM, "EmergentExit", OBJECT_ASM, \ + NULL, G_DBUS_SIGNAL_FLAGS_NONE, handle_signal, NULL, NULL ); + + if (!subs_id) { + debug_error ("g_dbus_connection_signal_subscribe() failed "); + return; + } +#endif +} + +static void on_name_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data) +{ + debug_log("Name Acquired (%s)", name); +} + +static void on_name_lost(GDBusConnection *connection, const gchar *name, gpointer user_data) +{ + debug_log("Name Lost (%s)", name); +} + +static int _mm_sound_mgr_focus_dbus_own_name(GBusType bus_type, const char* wellknown_name, guint* owner_id) +{ + guint oid; + + debug_log("Own name (%s) for focus-server", wellknown_name); + + oid = g_bus_own_name(bus_type, wellknown_name , G_BUS_NAME_OWNER_FLAGS_NONE, + on_bus_acquired, on_name_acquired, on_name_lost, NULL, NULL); + if (oid <= 0) { + debug_error("Dbus own name failed"); + return MM_ERROR_SOUND_INTERNAL; + } else { + *owner_id = oid; + } + + return MM_ERROR_NONE; +} + +static void _mm_sound_mgr_focus_dbus_unown_name(guint oid) +{ + debug_log("Unown name for focus-server"); + if (oid > 0) { + g_bus_unown_name(oid); + } +} + +#define PA_BUS_NAME "org.pulseaudio.Server" +#define PA_STREAM_MANAGER_OBJECT_PATH "/org/pulseaudio/StreamManager" +#define PA_STREAM_MANAGER_INTERFACE "org.pulseaudio.StreamManager" +#define PA_STREAM_MANAGER_METHOD_NAME_GET_STREAM_LIST "GetStreamList" +int __mm_sound_mgr_focus_dbus_get_stream_list(stream_list_t* stream_list) +{ + int ret = MM_ERROR_NONE; + GVariant *result = NULL; + GVariant *child = NULL; + GDBusConnection *conn = NULL; + GError *err = NULL; + int i = 0; + + g_type_init(); + + conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err); + if (!conn && err) { + LOGE("g_bus_get_sync() error (%s)", err->message); + g_error_free (err); + ret = MM_ERROR_SOUND_INTERNAL; + return ret; + } + result = g_dbus_connection_call_sync (conn, + PA_BUS_NAME, + PA_STREAM_MANAGER_OBJECT_PATH, + PA_STREAM_MANAGER_INTERFACE, + PA_STREAM_MANAGER_METHOD_NAME_GET_STREAM_LIST, + NULL, + G_VARIANT_TYPE("(vv)"), + G_DBUS_CALL_FLAGS_NONE, + 2000, + NULL, + &err); + if (!result && err) { + debug_error("g_dbus_connection_call_sync() error (%s)", err->message); + ret = MM_ERROR_SOUND_INTERNAL; + } else { + GVariantIter iter; + GVariant *item = NULL; + child = g_variant_get_child_value(result, 0); + item = g_variant_get_variant(child); + gchar *name; + i = 0; + g_variant_iter_init(&iter, item); + while ((i < AVAIL_STREAMS_MAX) && g_variant_iter_loop(&iter, "&s", &name)) { + debug_log ("name : %s", name); + stream_list->stream_types[i++] = strdup(name); + } + g_variant_iter_free (&iter); + g_variant_unref (item); + g_variant_unref (child); + + child = g_variant_get_child_value(result, 1); + item = g_variant_get_variant(child); + gint32 priority; + i = 0; + g_variant_iter_init(&iter, item); + while ((i < AVAIL_STREAMS_MAX) && g_variant_iter_loop(&iter, "i", &priority)) { + debug_log ("priority : %d", priority); + stream_list->priorities[i++] = priority; + } + g_variant_iter_free (&iter); + g_variant_unref (item); + g_variant_unref (child); + + g_variant_unref(result); + } + g_object_unref(conn); + + return ret; +} + + +int MMSoundMgrFocusDbusInit(void) +{ + debug_enter(); + + introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL); + if (!introspection_data) + return MM_ERROR_SOUND_INTERNAL; + + if (_mm_sound_mgr_focus_dbus_own_name(G_BUS_TYPE_SYSTEM, BUS_NAME_FOCUS_SERVER, &focus_server_owner_id) != MM_ERROR_NONE) { + debug_error ("dbus own name for focus-server error\n"); + return MM_ERROR_SOUND_INTERNAL; + } + + debug_leave(); + + return MM_ERROR_NONE; +} + +void MMSoundMgrFocusDbusFini(void) +{ + debug_enter("\n"); + + _mm_sound_mgr_focus_dbus_unown_name(focus_server_owner_id); + g_dbus_node_info_unref (introspection_data); + + debug_leave("\n"); +} + + + diff --git a/focus_server/mm_sound_mgr_focus_ipc.c b/focus_server/mm_sound_mgr_focus_ipc.c new file mode 100644 index 0000000..df6214f --- /dev/null +++ b/focus_server/mm_sound_mgr_focus_ipc.c @@ -0,0 +1,178 @@ +/* + * libmm-sound + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Seungbae Shin + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include "include/mm_sound_mgr_focus_ipc.h" +#include "include/mm_sound_mgr_focus_dbus.h" + +#include "../include/mm_sound_common.h" +#include "../include/mm_sound_msg.h" +#include "include/mm_sound_mgr_focus.h" +#include +#include + +#include + +#ifdef USE_FOCUS + +#ifdef SUPPORT_CONTAINER +// method + add callback +int __mm_sound_mgr_focus_ipc_register_focus(int client_pid, int handle_id, char* stream_type, const char* container_name, int container_pid) +{ + _mm_sound_mgr_focus_param_t param; + int ret = MM_ERROR_NONE; + + memset(¶m, 0x00, sizeof(_mm_sound_mgr_focus_param_t)); + param.pid = client_pid; + param.handle_id = handle_id; + memcpy(param.stream_type, stream_type, MAX_STREAM_TYPE_LEN); + + ret = mm_sound_mgr_focus_create_node(¶m); + + _mm_sound_mgr_focus_update_container_data(client_pid, handle_id, container_name, container_pid); + + return ret; +} +#else +int __mm_sound_mgr_focus_ipc_register_focus(int client_pid, int handle_id, char* stream_type) +{ + _mm_sound_mgr_focus_param_t param; + int ret = MM_ERROR_NONE; + + memset(¶m, 0x00, sizeof(_mm_sound_mgr_focus_param_t)); + param.pid = client_pid; + param.handle_id = handle_id; + memcpy(param.stream_type, stream_type, MAX_STREAM_TYPE_LEN); + + ret = mm_sound_mgr_focus_create_node(¶m); + + return ret; +} +#endif + +// method + remove callback +int __mm_sound_mgr_focus_ipc_unregister_focus(int pid, int handle_id) +{ + _mm_sound_mgr_focus_param_t param; + int ret = MM_ERROR_NONE; + + memset(¶m, 0x00, sizeof(_mm_sound_mgr_focus_param_t)); + param.pid = pid; + param.handle_id = handle_id; + + ret = mm_sound_mgr_focus_destroy_node(¶m); + + return ret; +} + +// method -> callback +int __mm_sound_mgr_focus_ipc_acquire_focus(int pid, int handle_id, int focus_type, const char* name ) +{ + _mm_sound_mgr_focus_param_t param; + int ret = MM_ERROR_NONE; + + memset(¶m, 0x00, sizeof(_mm_sound_mgr_focus_param_t)); + param.pid = pid; + param.handle_id = handle_id; + param.request_type = focus_type; + memcpy(param.option, name, MM_SOUND_NAME_NUM); + ret = mm_sound_mgr_focus_request_acquire(¶m); + + return ret; +} + +// method -> callback +int __mm_sound_mgr_focus_ipc_release_focus(int pid, int handle_id, int focus_type, const char* name) +{ + _mm_sound_mgr_focus_param_t param; + int ret = MM_ERROR_NONE; + + memset(¶m, 0x00, sizeof(_mm_sound_mgr_focus_param_t)); + param.pid = pid; + param.handle_id = handle_id; + param.request_type = focus_type; + memcpy(param.option, name, MM_SOUND_NAME_NUM); + + ret = mm_sound_mgr_focus_request_release(¶m); + + return ret; +} + +#ifdef SUPPORT_CONTAINER +// method + add callback +int __mm_sound_mgr_focus_ipc_watch_focus(int pid, int handle_id, int focus_type, const char* container_name, int container_pid) +{ + _mm_sound_mgr_focus_param_t param; + int ret = MM_ERROR_NONE; + + memset(¶m, 0x00, sizeof(_mm_sound_mgr_focus_param_t)); + param.pid = pid; + param.handle_id = handle_id; + param.request_type = focus_type; + + ret = mm_sound_mgr_focus_set_watch_cb(¶m); + _mm_sound_mgr_focus_update_container_data(pid, -1, container_name, container_pid); + + return ret; +} +#else +int __mm_sound_mgr_focus_ipc_watch_focus(int pid, int handle_id, int focus_type) +{ + _mm_sound_mgr_focus_param_t param; + int ret = MM_ERROR_NONE; + + memset(¶m, 0x00, sizeof(_mm_sound_mgr_focus_param_t)); + param.pid = pid; + param.handle_id = handle_id; + param.request_type = focus_type; + + ret = mm_sound_mgr_focus_set_watch_cb(¶m); + + return ret; +} +#endif + +// method + remove callback +int __mm_sound_mgr_focus_ipc_unwatch_focus(int pid, int handle_id) +{ + _mm_sound_mgr_focus_param_t param; + int ret = MM_ERROR_NONE; + + memset(¶m, 0x00, sizeof(_mm_sound_mgr_focus_param_t)); + param.pid = pid; + param.handle_id = handle_id; + + ret = mm_sound_mgr_focus_unset_watch_cb(¶m); + + return ret; +} +#endif + diff --git a/mm_sound_client_dbus.c b/mm_sound_client_dbus.c index c7e7a17..ff68dfa 100644 --- a/mm_sound_client_dbus.c +++ b/mm_sound_client_dbus.c @@ -33,6 +33,10 @@ #define OBJECT_SOUND_SERVER "/org/tizen/SoundServer1" #define INTERFACE_SOUND_SERVER "org.tizen.SoundServer1" +#define BUS_NAME_FOCUS_SERVER "org.tizen.FocusServer" +#define OBJECT_FOCUS_SERVER "/org/tizen/FocusServer1" +#define INTERFACE_FOCUS_SERVER "org.tizen.FocusServer1" + #define INTERFACE_DBUS "org.freedesktop.DBus.Properties" #define SIGNAL_PROP_CHANGED "PropertiesChanged" #define METHOD_GET "Get" @@ -51,6 +55,7 @@ enum { DBUS_TO_PULSE_MODULE_DEVICE_MANAGER, DBUS_TO_PULSE_MODULE_STREAM_MANAGER, DBUS_TO_PULSE_MODULE_POLICY, + DBUS_TO_FOCUS_SERVER, }; @@ -560,6 +565,10 @@ static int _dbus_method_call_to(int dbus_to, int method_type, GVariant *args, GV bus_name = BUS_NAME_PULSEAUDIO; object = OBJECT_PULSE_MODULE_POLICY; interface = INTERFACE_PULSE_MODULE_POLICY; + } else if (dbus_to == DBUS_TO_FOCUS_SERVER) { + bus_name = BUS_NAME_FOCUS_SERVER; + object = OBJECT_FOCUS_SERVER; + interface = INTERFACE_FOCUS_SERVER; } else { debug_error("Invalid case, dbus_to %d", dbus_to); return MM_ERROR_SOUND_INTERNAL; @@ -2040,7 +2049,7 @@ int mm_sound_client_dbus_register_focus(int id, const char *stream_type, mm_soun #endif /* SUPPORT_CONTAINER */ if (params) { - if ((ret = _dbus_method_call_to(DBUS_TO_SOUND_SERVER, METHOD_CALL_REGISTER_FOCUS, params, &result)) != MM_ERROR_NONE) { + if ((ret = _dbus_method_call_to(DBUS_TO_FOCUS_SERVER, METHOD_CALL_REGISTER_FOCUS, params, &result)) != MM_ERROR_NONE) { debug_error("dbus register focus failed"); goto cleanup; } @@ -2110,7 +2119,7 @@ int mm_sound_client_dbus_unregister_focus(int id) params = g_variant_new("(ii)", instance, id); if (params) { - if ((ret = _dbus_method_call_to(DBUS_TO_SOUND_SERVER, METHOD_CALL_UNREGISTER_FOCUS, params, &result)) != MM_ERROR_NONE) { + if ((ret = _dbus_method_call_to(DBUS_TO_FOCUS_SERVER, METHOD_CALL_UNREGISTER_FOCUS, params, &result)) != MM_ERROR_NONE) { debug_error("dbus unregister focus failed"); goto cleanup; } @@ -2162,7 +2171,7 @@ int mm_sound_client_dbus_acquire_focus(int id, mm_sound_focus_type_e type, const params = g_variant_new("(iiis)", instance, id, type, option); if (params) { - if ((ret = _dbus_method_call_to(DBUS_TO_SOUND_SERVER, METHOD_CALL_ACQUIRE_FOCUS, params, &result)) != MM_ERROR_NONE) { + if ((ret = _dbus_method_call_to(DBUS_TO_FOCUS_SERVER, METHOD_CALL_ACQUIRE_FOCUS, params, &result)) != MM_ERROR_NONE) { debug_error("dbus acquire focus failed"); goto cleanup; } @@ -2202,7 +2211,7 @@ int mm_sound_client_dbus_release_focus(int id, mm_sound_focus_type_e type, const params = g_variant_new("(iiis)", instance, id, type, option); if (params) { - if ((ret = _dbus_method_call_to(DBUS_TO_SOUND_SERVER, METHOD_CALL_RELEASE_FOCUS, params, &result)) != MM_ERROR_NONE) { + if ((ret = _dbus_method_call_to(DBUS_TO_FOCUS_SERVER, METHOD_CALL_RELEASE_FOCUS, params, &result)) != MM_ERROR_NONE) { debug_error("dbus release focus failed"); goto cleanup; } @@ -2274,7 +2283,7 @@ int mm_sound_client_dbus_set_focus_watch_callback(mm_sound_focus_type_e type, mm #endif /* SUPPORT_CONTAINER */ if (params) { - if ((ret = _dbus_method_call_to(DBUS_TO_SOUND_SERVER, METHOD_CALL_WATCH_FOCUS, params, &result)) != MM_ERROR_NONE) { + if ((ret = _dbus_method_call_to(DBUS_TO_FOCUS_SERVER, METHOD_CALL_WATCH_FOCUS, params, &result)) != MM_ERROR_NONE) { debug_error("dbus set watch focus failed"); goto cleanup; } @@ -2344,7 +2353,7 @@ int mm_sound_client_dbus_unset_focus_watch_callback(int id) params = g_variant_new("(ii)", g_focus_sound_handle[index].focus_tid, g_focus_sound_handle[index].handle); if (params) { - if ((ret = _dbus_method_call_to(DBUS_TO_SOUND_SERVER, METHOD_CALL_UNWATCH_FOCUS, params, &result)) != MM_ERROR_NONE) { + if ((ret = _dbus_method_call_to(DBUS_TO_FOCUS_SERVER, METHOD_CALL_UNWATCH_FOCUS, params, &result)) != MM_ERROR_NONE) { debug_error("dbus unset watch focus failed"); goto cleanup; } diff --git a/mm_sound_focus.c b/mm_sound_focus.c index c1ee81d..2bbff1f 100644 --- a/mm_sound_focus.c +++ b/mm_sound_focus.c @@ -28,7 +28,7 @@ #include "include/mm_sound.h" #include "include/mm_sound_focus.h" -#include "server/include/mm_sound_mgr_focus.h" +#include "focus_server/include/mm_sound_mgr_focus.h" EXPORT_API int mm_sound_focus_get_id(int *id) diff --git a/packaging/focus-server.conf b/packaging/focus-server.conf new file mode 100644 index 0000000..24ffdf4 --- /dev/null +++ b/packaging/focus-server.conf @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packaging/focus-server.path b/packaging/focus-server.path new file mode 100644 index 0000000..1bcc261 --- /dev/null +++ b/packaging/focus-server.path @@ -0,0 +1,5 @@ +[Unit] +Description=Path activation for the "focus-server" programme + +[Path] +PathExists=/tmp/.pa_ready diff --git a/packaging/focus-server.service b/packaging/focus-server.service new file mode 100644 index 0000000..ef6ab5b --- /dev/null +++ b/packaging/focus-server.service @@ -0,0 +1,13 @@ +[Unit] +Description=Start the focus profile service + +[Service] +User=system +Group=system +ExecStart=/usr/bin/focus_server -S +Restart=always +RestartSec=0 +MemoryLimit=50M + +[Install] +WantedBy=tizen-system.target diff --git a/packaging/libmm-sound.spec b/packaging/libmm-sound.spec index 08df73f..de36e7d 100644 --- a/packaging/libmm-sound.spec +++ b/packaging/libmm-sound.spec @@ -1,6 +1,6 @@ Name: libmm-sound Summary: MMSound Package contains client lib and sound_server binary -Version: 0.9.239 +Version: 0.9.240 Release: 0 Group: System/Libraries License: Apache-2.0 @@ -8,6 +8,9 @@ Source0: %{name}-%{version}.tar.gz Source1: sound-server.service Source2: sound-server.path Source3: sound-server.conf +Source4: focus-server.service +Source5: focus-server.path +Source6: focus-server.conf Requires(post): /sbin/ldconfig Requires(post): /usr/bin/vconftool Requires(postun): /sbin/ldconfig @@ -102,12 +105,16 @@ mkdir -p %{buildroot}/opt/etc/dump.d/module.d/ cp dump_audio.sh %{buildroot}/opt/etc/dump.d/module.d/dump_audio.sh mkdir -p %{buildroot}/etc/dbus-1/system.d/ cp %{SOURCE3} %{buildroot}/etc/dbus-1/system.d/sound-server.conf +cp %{SOURCE6} %{buildroot}/etc/dbus-1/system.d/focus-server.conf %make_install install -d %{buildroot}%{_unitdir}/multi-user.target.wants install -m0644 %{SOURCE1} %{buildroot}%{_unitdir}/ install -m0644 %{SOURCE2} %{buildroot}%{_unitdir}/ +install -m0644 %{SOURCE4} %{buildroot}%{_unitdir}/ +install -m0644 %{SOURCE5} %{buildroot}%{_unitdir}/ ln -sf ../sound-server.path %{buildroot}%{_unitdir}/multi-user.target.wants/sound-server.path +ln -sf ../focus-server.path %{buildroot}%{_unitdir}/multi-user.target.wants/focus-server.path %post /sbin/ldconfig @@ -135,6 +142,8 @@ ln -sf ../sound-server.path %{buildroot}%{_unitdir}/multi-user.target.wants/soun %manifest libmm-sound.manifest %defattr(-,root,root,-) %caps(cap_chown,cap_dac_override,cap_fowner,cap_mac_override,cap_lease=eip) %{_bindir}/sound_server +%caps(cap_chown,cap_dac_override,cap_fowner,cap_mac_override,cap_lease=eip) %{_bindir}/focus_server +%{_bindir}/focus_server %{_libdir}/libmmfsound.so.* %{_libdir}/libmmfsoundcommon.so.* %{_libdir}/libmmfkeysound.so.* @@ -152,14 +161,18 @@ ln -sf ../sound-server.path %{buildroot}%{_unitdir}/multi-user.target.wants/soun %{_libdir}/soundplugins/libsoundplugintremoloogg.so %endif %{_unitdir}/multi-user.target.wants/sound-server.path +%{_unitdir}/multi-user.target.wants/focus-server.path %{_unitdir}/sound-server.service %{_unitdir}/sound-server.path +%{_unitdir}/focus-server.service +%{_unitdir}/focus-server.path /usr/share/sounds/sound-server/* %{_datadir}/license/%{name} %{_datadir}/license/libmm-sound-tool /usr/share/sounds/sound-server/* /opt/etc/dump.d/module.d/dump_audio.sh /etc/dbus-1/system.d/sound-server.conf +/etc/dbus-1/system.d/focus-server.conf %files devel %defattr(-,root,root,-) diff --git a/server/Makefile.am b/server/Makefile.am index 405ce50..35914e3 100644 --- a/server/Makefile.am +++ b/server/Makefile.am @@ -53,10 +53,6 @@ sound_server_CFLAGS += $(SECURITY_CFLAGS) -DUSE_SECURITY sound_server_LDADD += $(SECURITY_LIBS) endif -if USE_FOCUS -sound_server_SOURCES += mm_sound_mgr_focus.c -endif - sound_server_DEPENDENCIES = $(srcdir)/../common/libmmfsoundcommon.la sound_server_CFLAGS += -fPIC -pie installsounddir = $(prefix)/share/sounds/sound-server diff --git a/server/include/mm_sound_mgr_ipc.h b/server/include/mm_sound_mgr_ipc.h index ba62808..47614ca 100644 --- a/server/include/mm_sound_mgr_ipc.h +++ b/server/include/mm_sound_mgr_ipc.h @@ -77,28 +77,7 @@ int __mm_sound_mgr_ipc_set_sound_path_for_active_device(mm_sound_device_in _devi int __mm_sound_mgr_ipc_get_audio_path(mm_sound_device_in *device_in, mm_sound_device_out *device_out); //int __mm_sound_mgr_ipc_get_current_connected_device_list(mm_ipc_msg_t *msg, GList **device_list, int *total_num); int __mm_sound_mgr_ipc_get_current_connected_device_list(int device_flags, mm_sound_device_t **device_list, int *total_num); -#ifdef USE_FOCUS -//int __mm_sound_mgr_ipc_create_focus_node(mm_ipc_msg_t *msg); -#ifdef SUPPORT_CONTAINER -int __mm_sound_mgr_ipc_register_focus(int client_pid, int handle_id, char* stream_type ,const char* container_name, int container_pid); -#else -int __mm_sound_mgr_ipc_register_focus(int client_pid, int handle_id, char* stream_type); -#endif -//int __mm_sound_mgr_ipc_destroy_focus_node(mm_ipc_msg_t *msg); -int __mm_sound_mgr_ipc_unregister_focus(int pid, int handle_id); - -int __mm_sound_mgr_ipc_acquire_focus(int pid, int handle_id, int focus_type, const char* name ); -int __mm_sound_mgr_ipc_release_focus(int pid, int handle_id, int focus_type, const char* name); -//int __mm_sound_mgr_ipc_set_focus_watch_cb(mm_ipc_msg_t *msg); -#ifdef SUPPORT_CONTAINER -int __mm_sound_mgr_ipc_watch_focus(int pid, int handle_id, int focus_type, const char* container_name, int container_pid); -#else -int __mm_sound_mgr_ipc_watch_focus(int pid, int handle_id, int focus_type); -#endif -//int __mm_sound_mgr_ipc_unset_focus_watch_cb(mm_ipc_msg_t *msg); -int __mm_sound_mgr_ipc_unwatch_focus(int pid, int handle_id); -#endif int __mm_sound_mgr_ipc_asm_register_sound(int pid, int handle, int sound_event, int request_id, int sound_state, int resource, #ifdef SUPPORT_CONTAINER const char* container_name, int container_pid, diff --git a/server/mm_sound_mgr_ipc.c b/server/mm_sound_mgr_ipc.c index 4a5c3cc..5f97f1d 100644 --- a/server/mm_sound_mgr_ipc.c +++ b/server/mm_sound_mgr_ipc.c @@ -41,9 +41,6 @@ #include "include/mm_sound_mgr_codec.h" #include "include/mm_sound_mgr_device.h" #include "include/mm_sound_mgr_asm.h" -#ifdef USE_FOCUS -#include "include/mm_sound_mgr_focus.h" -#endif #include #include @@ -356,148 +353,6 @@ int __mm_sound_mgr_ipc_get_current_connected_device_list(int device_flags, mm_so return ret; } -#ifdef USE_FOCUS - -#ifdef SUPPORT_CONTAINER -// method + add callback -int __mm_sound_mgr_ipc_register_focus(int client_pid, int handle_id, char* stream_type, const char* container_name, int container_pid) -{ - _mm_sound_mgr_focus_param_t param; - int ret = MM_ERROR_NONE; - - memset(¶m, 0x00, sizeof(_mm_sound_mgr_focus_param_t)); - param.pid = client_pid; - param.handle_id = handle_id; -// param.callback = msg->sound_msg.callback; -// param.cbdata = msg->sound_msg.cbdata; - memcpy(param.stream_type, stream_type, MAX_STREAM_TYPE_LEN); - - ret = mm_sound_mgr_focus_create_node(¶m); - - _mm_sound_mgr_focus_update_container_data(client_pid, handle_id, container_name, container_pid); - - return ret; -} -#else -int __mm_sound_mgr_ipc_register_focus(int client_pid, int handle_id, char* stream_type) -{ - _mm_sound_mgr_focus_param_t param; - int ret = MM_ERROR_NONE; - - memset(¶m, 0x00, sizeof(_mm_sound_mgr_focus_param_t)); - param.pid = client_pid; - param.handle_id = handle_id; -// param.callback = msg->sound_msg.callback; -// param.cbdata = msg->sound_msg.cbdata; - memcpy(param.stream_type, stream_type, MAX_STREAM_TYPE_LEN); - - ret = mm_sound_mgr_focus_create_node(¶m); - - return ret; -} -#endif - -// method + remove callback -int __mm_sound_mgr_ipc_unregister_focus(int pid, int handle_id) -{ - _mm_sound_mgr_focus_param_t param; - int ret = MM_ERROR_NONE; - - memset(¶m, 0x00, sizeof(_mm_sound_mgr_focus_param_t)); - param.pid = pid; - param.handle_id = handle_id; - - ret = mm_sound_mgr_focus_destroy_node(¶m); - - return ret; -} - -// method -> callback -int __mm_sound_mgr_ipc_acquire_focus(int pid, int handle_id, int focus_type, const char* name ) -{ - _mm_sound_mgr_focus_param_t param; - int ret = MM_ERROR_NONE; - - memset(¶m, 0x00, sizeof(_mm_sound_mgr_focus_param_t)); - param.pid = pid; - param.handle_id = handle_id; - param.request_type = focus_type; - memcpy(param.option, name, MM_SOUND_NAME_NUM); - ret = mm_sound_mgr_focus_request_acquire(¶m); - - return ret; -} - -// method -> callback -int __mm_sound_mgr_ipc_release_focus(int pid, int handle_id, int focus_type, const char* name) -{ - _mm_sound_mgr_focus_param_t param; - int ret = MM_ERROR_NONE; - - memset(¶m, 0x00, sizeof(_mm_sound_mgr_focus_param_t)); - param.pid = pid; - param.handle_id = handle_id; - param.request_type = focus_type; - memcpy(param.option, name, MM_SOUND_NAME_NUM); - - ret = mm_sound_mgr_focus_request_release(¶m); - - return ret; -} - -#ifdef SUPPORT_CONTAINER -// method + add callback -int __mm_sound_mgr_ipc_watch_focus(int pid, int handle_id, int focus_type, const char* container_name, int container_pid) -{ - _mm_sound_mgr_focus_param_t param; - int ret = MM_ERROR_NONE; - - memset(¶m, 0x00, sizeof(_mm_sound_mgr_focus_param_t)); - param.pid = pid; - param.handle_id = handle_id; - param.request_type = focus_type; -// param.callback = msg->sound_msg.callback; -// param.cbdata = msg->sound_msg.cbdata; - - ret = mm_sound_mgr_focus_set_watch_cb(¶m); - _mm_sound_mgr_focus_update_container_data(pid, -1, container_name, container_pid); - - return ret; -} -#else -int __mm_sound_mgr_ipc_watch_focus(int pid, int handle_id, int focus_type) -{ - _mm_sound_mgr_focus_param_t param; - int ret = MM_ERROR_NONE; - - memset(¶m, 0x00, sizeof(_mm_sound_mgr_focus_param_t)); - param.pid = pid; - param.handle_id = handle_id; - param.request_type = focus_type; -// param.callback = msg->sound_msg.callback; -// param.cbdata = msg->sound_msg.cbdata; - - ret = mm_sound_mgr_focus_set_watch_cb(¶m); - - return ret; -} -#endif - -// method + remove callback -int __mm_sound_mgr_ipc_unwatch_focus(int pid, int handle_id) -{ - _mm_sound_mgr_focus_param_t param; - int ret = MM_ERROR_NONE; - - memset(¶m, 0x00, sizeof(_mm_sound_mgr_focus_param_t)); - param.pid = pid; - param.handle_id = handle_id; - - ret = mm_sound_mgr_focus_unset_watch_cb(¶m); - - return ret; -} -#endif /************************************** ASM ***************************************/ int __mm_sound_mgr_ipc_asm_register_sound(int pid, int handle, int sound_event, int request_id, int sound_state, int resource, diff --git a/server/mm_sound_mgr_ipc_dbus.c b/server/mm_sound_mgr_ipc_dbus.c index c0a11d3..e3407a5 100644 --- a/server/mm_sound_mgr_ipc_dbus.c +++ b/server/mm_sound_mgr_ipc_dbus.c @@ -109,50 +109,6 @@ " " " " " " - " " -#ifdef SUPPORT_CONTAINER -#ifdef USE_SECURITY - " " -#else - " " -#endif -#endif - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " -#ifdef SUPPORT_CONTAINER -#ifdef USE_SECURITY - " " -#else - " " -#endif -#endif - " " - " " - " " - " " - " " - " " - " " - " " " " #ifdef SUPPORT_CONTAINER #ifdef USE_SECURITY @@ -382,13 +338,6 @@ static void handle_method_set_sound_path_for_active_device(GDBusMethodInvocation static void handle_method_get_audio_path(GDBusMethodInvocation* invocation); static void handle_method_get_connected_device_list(GDBusMethodInvocation* invocation); -static void handle_method_register_focus(GDBusMethodInvocation* invocation); -static void handle_method_unregister_focus(GDBusMethodInvocation* invocation); -static void handle_method_acquire_focus(GDBusMethodInvocation* invocation); -static void handle_method_release_focus(GDBusMethodInvocation* invocation); -static void handle_method_watch_focus(GDBusMethodInvocation* invocation); -static void handle_method_unwatch_focus(GDBusMethodInvocation* invocation); - static void handle_method_asm_register_sound(GDBusMethodInvocation* invocation); static void handle_method_asm_unregister_sound(GDBusMethodInvocation* invocation); static void handle_method_asm_register_watcher(GDBusMethodInvocation* invocation); @@ -470,42 +419,6 @@ struct mm_sound_dbus_method methods[METHOD_CALL_MAX] = { }, .handler = handle_method_get_connected_device_list }, - [METHOD_CALL_REGISTER_FOCUS] = { - .info = { - .name = "RegisterFocus", - }, - .handler = handle_method_register_focus - }, - [METHOD_CALL_UNREGISTER_FOCUS] = { - .info = { - .name = "UnregisterFocus", - }, - .handler = handle_method_unregister_focus - }, - [METHOD_CALL_ACQUIRE_FOCUS] = { - .info = { - .name = "AcquireFocus", - }, - .handler = handle_method_acquire_focus - }, - [METHOD_CALL_RELEASE_FOCUS] = { - .info = { - .name = "ReleaseFocus", - }, - .handler = handle_method_release_focus - }, - [METHOD_CALL_WATCH_FOCUS] = { - .info = { - .name = "WatchFocus", - }, - .handler = handle_method_watch_focus - }, - [METHOD_CALL_UNWATCH_FOCUS] = { - .info = { - .name = "UnwatchFocus", - }, - .handler = handle_method_unwatch_focus - }, [METHOD_CALL_ASM_REGISTER_SOUND] = { .info = { .name = "ASMRegisterSound", @@ -624,16 +537,6 @@ struct mm_sound_dbus_signal signals[SIGNAL_MAX] = { .name = "DeviceInfoChanged", }, }, - [SIGNAL_FOCUS_CHANGED] = { - .info = { - .name = "FocusChanged", - }, - }, - [SIGNAL_FOCUS_WATCH] = { - .info = { - .name = "FocusWatch", - }, - } }; @@ -1065,220 +968,6 @@ send_reply: } } -static void handle_method_register_focus(GDBusMethodInvocation* invocation) -{ - int ret = MM_ERROR_NONE; - int pid = 0, handle_id = 0; - const char* stream_type = NULL; - GVariant *params = NULL; -#ifdef SUPPORT_CONTAINER - int container_pid = -1; - char* container = NULL; -#ifdef USE_SECURITY - GVariant* cookie_data; -#endif /* USE_SECURITY */ -#endif /* SUPPORT_CONTAINER */ - - - debug_fenter(); - - if (!(params = g_dbus_method_invocation_get_parameters(invocation))) { - debug_error("Parameter for Method is NULL"); - ret = MM_ERROR_SOUND_INTERNAL; - goto send_reply; - } - -#ifdef SUPPORT_CONTAINER -#ifdef USE_SECURITY - g_variant_get(params, "(@ayiis)", &cookie_data, &container_pid, &handle_id, &stream_type); - container = _get_container_from_cookie(cookie_data); - ret = __mm_sound_mgr_ipc_register_focus(_get_sender_pid(invocation), handle_id, stream_type, container, container_pid); - - if (container) - free(container); -#else /* USE_SECURITY */ - g_variant_get(params, "(siis)", &container, &container_pid, &handle_id, &stream_type); - ret = __mm_sound_mgr_ipc_register_focus(_get_sender_pid(invocation), handle_id, stream_type, container, container_pid); - -#endif /* USE_SECURITY */ -#else /* SUPPORT_CONTAINER */ - g_variant_get(params, "(iis)", &pid, &handle_id, &stream_type); - ret = __mm_sound_mgr_ipc_register_focus(_get_sender_pid(invocation), handle_id, stream_type); - -#endif /* SUPPORT_CONTAINER */ - -send_reply: - if (ret == MM_ERROR_NONE) { - _method_call_return_value(invocation, g_variant_new("()")); - } else { - _method_call_return_error(invocation, ret); - } - - debug_fleave(); -} - -static void handle_method_unregister_focus(GDBusMethodInvocation* invocation) -{ - - int ret = MM_ERROR_NONE; - int pid = 0, handle_id = 0; - GVariant *params = NULL; - - debug_fenter(); - - if (!(params = g_dbus_method_invocation_get_parameters(invocation))) { - debug_error("Parameter for Method is NULL"); - ret = MM_ERROR_SOUND_INTERNAL; - goto send_reply; - } - - g_variant_get(params, "(ii)", &pid, &handle_id); - ret = __mm_sound_mgr_ipc_unregister_focus(_get_sender_pid(invocation), handle_id); - -send_reply: - if (ret == MM_ERROR_NONE) { - _method_call_return_value(invocation, g_variant_new("()")); - } else { - _method_call_return_error(invocation, ret); - } - - debug_fleave(); -} - -static void handle_method_acquire_focus(GDBusMethodInvocation* invocation) -{ - int ret = MM_ERROR_NONE; - int pid = 0, handle_id = 0, focus_type = 0; - const char* name = NULL; - GVariant *params = NULL; - - debug_fenter(); - - if (!(params = g_dbus_method_invocation_get_parameters(invocation))) { - debug_error("Parameter for Method is NULL"); - ret = MM_ERROR_SOUND_INTERNAL; - goto send_reply; - } - - g_variant_get(params, "(iiis)", &pid, &handle_id, &focus_type, &name); - ret = __mm_sound_mgr_ipc_acquire_focus(_get_sender_pid(invocation), handle_id, focus_type, name); - -send_reply: - if (ret == MM_ERROR_NONE) { - _method_call_return_value(invocation, g_variant_new("()")); - } else { - _method_call_return_error(invocation, ret); - } - - debug_fleave(); -} - -static void handle_method_release_focus(GDBusMethodInvocation* invocation) -{ - int ret = MM_ERROR_NONE; - int pid = 0, handle_id = 0, focus_type = 0; - const char* name = NULL; - GVariant *params = NULL; - - debug_fenter(); - - if (!(params = g_dbus_method_invocation_get_parameters(invocation))) { - debug_error("Parameter for Method is NULL"); - ret = MM_ERROR_SOUND_INTERNAL; - goto send_reply; - } - - g_variant_get(params, "(iiis)", &pid, &handle_id, &focus_type, &name); - ret = __mm_sound_mgr_ipc_release_focus(_get_sender_pid(invocation), handle_id, focus_type, name); - -send_reply: - if (ret == MM_ERROR_NONE) { - _method_call_return_value(invocation, g_variant_new("()")); - } else { - _method_call_return_error(invocation, ret); - } - - debug_fleave(); -} - -static void handle_method_watch_focus(GDBusMethodInvocation* invocation) -{ - int ret = MM_ERROR_NONE; - int pid = 0, handle_id = 0, focus_type = 0; - GVariant *params = NULL; -#ifdef SUPPORT_CONTAINER - int container_pid = -1; - char* container = NULL; -#ifdef USE_SECURITY - GVariant* cookie_data; -#endif /* USE_SECURITY */ -#endif /* SUPPORT_CONTAINER */ - - debug_fenter(); - - if (!(params = g_dbus_method_invocation_get_parameters(invocation))) { - debug_error("Parameter for Method is NULL"); - ret = MM_ERROR_SOUND_INTERNAL; - goto send_reply; - } - -#ifdef SUPPORT_CONTAINER -#ifdef USE_SECURITY - g_variant_get(params, "(@ayiii)", &cookie_data, &container_pid, &handle_id, &focus_type); - container = _get_container_from_cookie(cookie_data); - ret = __mm_sound_mgr_ipc_watch_focus(_get_sender_pid(invocation), handle_id, focus_type, container, container_pid); - - if (container) - free(container); -#else /* USE_SECURITY */ - g_variant_get(params, "(siii)", &container, &container_pid, &handle_id, &focus_type); - ret = __mm_sound_mgr_ipc_watch_focus(_get_sender_pid(invocation), handle_id, focus_type, container, container_pid); - -#endif /* USE_SECURITY */ -#else /* SUPPORT_CONTAINER */ - g_variant_get(params, "(iii)", &pid, &handle_id, &focus_type); - ret = __mm_sound_mgr_ipc_watch_focus(_get_sender_pid(invocation), handle_id, focus_type); - -#endif /* SUPPORT_CONTAINER */ - -send_reply: - if (ret == MM_ERROR_NONE) { - _method_call_return_value(invocation, g_variant_new("()")); - } else { - _method_call_return_error(invocation, ret); - } - - debug_fleave(); -} - -static void handle_method_unwatch_focus (GDBusMethodInvocation* invocation) -{ - int ret = MM_ERROR_NONE; - int pid = 0; - int handle_id = 0; - GVariant *params = NULL; - - debug_fenter(); - - if (!(params = g_dbus_method_invocation_get_parameters(invocation))) { - debug_error("Parameter for Method is NULL"); - ret = MM_ERROR_SOUND_INTERNAL; - goto send_reply; - } - - g_variant_get(params, "(ii)", &pid, &handle_id); - ret = __mm_sound_mgr_ipc_unwatch_focus(_get_sender_pid(invocation), handle_id); - -send_reply: - if (ret == MM_ERROR_NONE) { - _method_call_return_value(invocation, g_variant_new("()")); - } else { - _method_call_return_error(invocation, ret); - } - - debug_fleave(); -} - /*********************** ASM METHODS ****************************/ #ifdef SUPPORT_CONTAINER diff --git a/server/mm_sound_server.c b/server/mm_sound_server.c index 2c88eea..b0c1a65 100644 --- a/server/mm_sound_server.c +++ b/server/mm_sound_server.c @@ -238,7 +238,7 @@ int main(int argc, char **argv) else if(pid > 0) { wait(&ret); - fprintf(stderr, "Killed by signal [%05X]\n", ret); + fprintf(stderr, "Killed by signal [%05X]\n", ret); fprintf(stderr, "Daemon is run againg\n"); } } @@ -260,9 +260,6 @@ int main(int argc, char **argv) /* Wait for ASM Ready */ __wait_for_vconfkey_ready(ASM_READY_KEY); debug_warning("sound_server [%d] asm ready...now, initialize devices!!!\n", getpid()); -#ifdef USE_FOCUS - MMSoundMgrFocusInit(); -#endif // _mm_sound_mgr_device_init(); // MMSoundMgrHeadsetInit(); @@ -307,9 +304,6 @@ int main(int argc, char **argv) // MMSoundMgrHeadsetFini(); // MMSoundMgrSessionFini(); // _mm_sound_mgr_device_fini(); -#ifdef USE_FOCUS - MMSoundMgrFocusFini(); -#endif MMSoundMgrASMFini(); // MMSoundMgrPulseFini(pulse_handle); #ifdef USE_HIBERNATION @@ -347,7 +341,7 @@ static int getOption(int argc, char **argv, server_arg *arg) } else { MMSOUND_STRNCPY(arg->plugdir, PLUGIN_DIR, MAX_PLUGIN_DIR_PATH_LEN); } - + arg->testmode = 0; while (1) diff --git a/server/mm_sound_thread_pool.c b/server/mm_sound_thread_pool.c index bd00952..257f5e3 100644 --- a/server/mm_sound_thread_pool.c +++ b/server/mm_sound_thread_pool.c @@ -58,7 +58,7 @@ static void __ThreadWork(gpointer data, gpointer user_data) debug_warning ("No func to call....\n"); } - /* Info was allocated by MMSoundThreadPoolRun(). + /* Info was allocated by MMSoundThreadPoolRun(). The actual content of info should be freed whether inside func or outside (if handle) */ debug_log ("free [%p]\n", info); free (info); @@ -109,8 +109,8 @@ int MMSoundThreadPoolInit() debug_msg ("thread pool set max unused threads to %d\n", MAX_UNUSED_THREADS_IN_THREADPOOL); g_thread_pool_set_max_unused_threads (MAX_UNUSED_THREADS_IN_THREADPOOL); - /* To reserve unused threads, let's start some threads for beggining - This dummy thread will be remained unused as soon as it started */ + /* To reserve unused threads, let's start some threads for beggining + This dummy thread will be remained unused as soon as it started */ debug_msg ("run threads to reserve minimum thread\n"); for (i=0; i