[AUDIO_METHOD_UNWATCH_FOCUS] = {
.name = "UnwatchFocus",
},
- [AUDIO_METHOD_EMERGENT_EXIT_FOCUS] = {
- .name = "EmergentExitFocus",
- },
};
const mm_sound_dbus_signal_info_t g_events[AUDIO_EVENT_MAX] = {
},
[AUDIO_EVENT_FOCUS_WATCH] = {
.name = "FocusWatch",
+ },
+ [AUDIO_EVENT_EMERGENT_EXIT] = {
+ .name = "EmergentExit",
}
};
debug_log("Signal(%s.%s) Received , Let's call Wrapper-Callback", interface_name, signal_name);
if (!strcmp(signal_name, g_events[AUDIO_EVENT_VOLUME_CHANGED].name)) {
- (cb_data->user_cb)(AUDIO_EVENT_VOLUME_CHANGED, params, cb_data->user_data);
+ (cb_data->user_cb)(AUDIO_EVENT_VOLUME_CHANGED, params, cb_data->user_data);
} else if (!strcmp(signal_name, g_events[AUDIO_EVENT_DEVICE_CONNECTED].name)) {
- (cb_data->user_cb)(AUDIO_EVENT_DEVICE_CONNECTED, params, cb_data->user_data);
+ (cb_data->user_cb)(AUDIO_EVENT_DEVICE_CONNECTED, params, cb_data->user_data);
} else if (!strcmp(signal_name, g_events[AUDIO_EVENT_DEVICE_INFO_CHANGED].name)) {
- (cb_data->user_cb)(AUDIO_EVENT_DEVICE_INFO_CHANGED, params, cb_data->user_data);
+ (cb_data->user_cb)(AUDIO_EVENT_DEVICE_INFO_CHANGED, params, cb_data->user_data);
} else if (!strcmp(signal_name, g_events[AUDIO_EVENT_FOCUS_CHANGED].name)) {
- (cb_data->user_cb)(AUDIO_EVENT_FOCUS_CHANGED, params, cb_data->user_data);
+ (cb_data->user_cb)(AUDIO_EVENT_FOCUS_CHANGED, params, cb_data->user_data);
} else if (!strcmp(signal_name, g_events[AUDIO_EVENT_FOCUS_WATCH].name)) {
- (cb_data->user_cb)(AUDIO_EVENT_FOCUS_WATCH, params, cb_data->user_data);
+ (cb_data->user_cb)(AUDIO_EVENT_FOCUS_WATCH, params, cb_data->user_data);
} else if (!strcmp(signal_name, g_events[AUDIO_EVENT_PLAY_FILE_END].name)) {
- (cb_data->user_cb)(AUDIO_EVENT_PLAY_FILE_END, params, cb_data->user_data);
+ (cb_data->user_cb)(AUDIO_EVENT_PLAY_FILE_END, params, cb_data->user_data);
+ } else if (!strcmp(signal_name, g_events[AUDIO_EVENT_EMERGENT_EXIT].name)) {
+ (cb_data->user_cb)(AUDIO_EVENT_EMERGENT_EXIT, params, cb_data->user_data);
}
}
static void callback_data_free_func(gpointer data)
{
- struct callback_data *cb_data = (struct callback_data *) data;
+ struct callback_data *cb_data = (struct callback_data *) data;
- cb_data->free_func(cb_data->user_data);
- g_free(cb_data);
+ if (cb_data->free_func)
+ cb_data->free_func(cb_data->user_data);
+ g_free(cb_data);
}
EXPORT_API
}
dbus_ret = g_dbus_connection_emit_signal (conn,
- g_paths[provider].bus_name, g_paths[provider].object,
+ NULL, g_paths[provider].object,
g_paths[provider].interface, g_events[event].name,
param, &err);
if (!dbus_ret) {
debug_warning ("list = %p, node = %p, pid=[%d]", x, node, (node)? node->pid : -1); \
if (x && node && (mm_sound_util_is_process_alive(node->pid) == FALSE)) { \
debug_warning("PID:%d does not exist now! remove from device cb list\n", node->pid); \
+ __clear_focus_pipe(node); \
x = g_list_remove (x, node); \
g_free (node); \
} \
return path;
}
-static void _clear_focus_node_list_func (focus_node_t *node, gpointer user_data)
-{
- CLEAR_DEAD_NODE_LIST(g_focus_node_list);
-}
-
static void __clear_focus_pipe(focus_node_t *node)
{
char *filename = NULL;
debug_fleave();
}
+static void _clear_focus_node_list_func (focus_node_t *node, gpointer user_data)
+{
+ CLEAR_DEAD_NODE_LIST(g_focus_node_list);
+}
+
static int _mm_sound_mgr_focus_get_priority_from_stream_type(int *priority, const char *stream_type)
{
int ret = MM_ERROR_NONE;
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_emergent_exit_focus (GDBusMethodInvocation* invocation);
/* Currently , Just using method's name and handler */
/* TODO : generate introspection xml automatically, with these value include argument and reply */
.name = "UnwatchFocus",
},
.handler = handle_method_unwatch_focus
- },
- [AUDIO_METHOD_EMERGENT_EXIT_FOCUS] = {
- .info = {
- .name = "EmergentExitFocus",
- },
- .handler = handle_method_emergent_exit_focus
- },
+ }
};
static GDBusNodeInfo *introspection_data = NULL;
guint focus_server_owner_id ;
+unsigned emergent_exit_subs_id;
/*
For pass error code with 'g_dbus_method_invocation_return_error'
debug_fleave();
}
-static void handle_method_emergent_exit_focus (GDBusMethodInvocation* invocation)
-{
- int ret = MM_ERROR_NONE;
- int pid = 0;
- GVariant *params = NULL;
-
- debug_fenter();
-
- if (!(params = g_dbus_method_invocation_get_parameters(invocation))) {
- debug_error("Parameter for Method is NULL");
- goto send_reply;
- }
-
- g_variant_get(params, "(i)", &pid);
- ret = __mm_sound_mgr_focus_ipc_emergent_exit(_get_sender_pid(invocation));
- if(ret)
- debug_error("__mm_sound_mgr_focus_ipc_emergent_exit faild : 0x%x", ret);
-
-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,
return TRUE;
}
+void emergent_exit_signal_handler(audio_event_t event, GVariant *param, void *userdata)
+{
+ int ret = MM_ERROR_NONE;
+ int pid = 0;
+
+ if (event != AUDIO_EVENT_EMERGENT_EXIT)
+ return;
+
+ debug_fenter();
+
+ g_variant_get(param, "(i)", &pid);
+ debug_log("emergent exit : pid %d", pid);
+ ret = __mm_sound_mgr_focus_ipc_emergent_exit(pid);
+ if (ret)
+ debug_error("__mm_sound_mgr_focus_ipc_emergent_exit faild : 0x%x", ret);
+
+ debug_fleave();
+}
+
static const GDBusInterfaceVTable interface_vtable =
{
handle_method_call,
return ret;
}
-
int MMSoundMgrFocusDbusInit(void)
{
debug_enter();
debug_error ("dbus own name for focus-server error\n");
return MM_ERROR_SOUND_INTERNAL;
}
+ if (mm_sound_dbus_signal_subscribe_to(AUDIO_PROVIDER_AUDIO_CLIENT, AUDIO_EVENT_EMERGENT_EXIT, emergent_exit_signal_handler, NULL, NULL, &emergent_exit_subs_id) != MM_ERROR_NONE) {
+ debug_error ("dbus signal subscribe for emergent exit error\n");
+ return MM_ERROR_SOUND_INTERNAL;
+ }
debug_leave();
void MMSoundMgrFocusDbusFini(void)
{
- debug_enter("\n");
+ debug_enter();
+ if (emergent_exit_subs_id != 0)
+ mm_sound_dbus_signal_unsubscribe(emergent_exit_subs_id);
_mm_sound_mgr_focus_dbus_unown_name(focus_server_owner_id);
g_dbus_node_info_unref (introspection_data);
- debug_leave("\n");
+ debug_leave();
}
AUDIO_METHOD_RELEASE_FOCUS,
AUDIO_METHOD_WATCH_FOCUS,
AUDIO_METHOD_UNWATCH_FOCUS,
- AUDIO_METHOD_EMERGENT_EXIT_FOCUS,
AUDIO_METHOD_MAX
} audio_method_t;
AUDIO_EVENT_DEVICE_INFO_CHANGED,
AUDIO_EVENT_FOCUS_CHANGED,
AUDIO_EVENT_FOCUS_WATCH,
+ AUDIO_EVENT_EMERGENT_EXIT,
AUDIO_EVENT_MAX
} audio_event_t;
int mm_sound_proxy_release_focus(int instance, int id, mm_sound_focus_type_e type, const char *option, bool is_for_session);
int mm_sound_proxy_set_focus_watch_callback(int instance, int handle, mm_sound_focus_type_e type, mm_sound_focus_changed_watch_cb callback, bool is_for_session, void *user_data);
int mm_sound_proxy_unset_focus_watch_callback(int focus_tid, int handle, bool is_for_session);
-int mm_sound_proxy_emergent_exit_focus(int exit_pid);
+int mm_sound_proxy_emergent_exit(int exit_pid);
#endif
int mm_sound_proxy_add_test_callback(mm_sound_test_cb func, void *userdata, mm_sound_proxy_userdata_free freefunc, unsigned *subs_id);
#define VOLUME_TYPE_LEN 64
-struct sigaction FOCUS_int_old_action;
-struct sigaction FOCUS_abrt_old_action;
-struct sigaction FOCUS_segv_old_action;
-struct sigaction FOCUS_term_old_action;
-struct sigaction FOCUS_sys_old_action;
-struct sigaction FOCUS_xcpu_old_action;
+struct sigaction system_int_old_action;
+struct sigaction system_abrt_old_action;
+struct sigaction system_segv_old_action;
+struct sigaction system_term_old_action;
+struct sigaction system_sys_old_action;
+struct sigaction system_xcpu_old_action;
struct callback_data {
void *user_cb;
guint g_focus_signal_handle = 0;
-void _focus_signal_handler(int signo)
+void _system_signal_handler(int signo)
{
int ret = MM_ERROR_NONE;
- int exit_pid = 0;
int index = 0;
sigset_t old_mask, all_mask;
sigfillset(&all_mask);
sigprocmask(SIG_BLOCK, &all_mask, &old_mask);
- exit_pid = getpid();
-
- /* need implementation */
- //send exit pid to focus server and focus server will clear focus or watch if necessary.
-
- for (index = 0; index < FOCUS_HANDLE_MAX; index++) {
- if (g_focus_sound_handle[index].is_used == true && g_focus_sound_handle[index].focus_tid == exit_pid) {
- ret = mm_sound_proxy_emergent_exit_focus(exit_pid);
- break;
- }
- }
-
+ ret = mm_sound_proxy_emergent_exit(getpid());
if (ret == MM_ERROR_NONE)
- debug_msg("[Client] Success to emergnet_exit_focus\n");
+ debug_msg("[Client] Success to emergnet_exit\n");
else
debug_error("[Client] Error occurred : 0x%x \n",ret);
switch (signo) {
case SIGINT:
- sigaction(SIGINT, &FOCUS_int_old_action, NULL);
+ sigaction(SIGINT, &system_int_old_action, NULL);
raise( signo);
break;
case SIGABRT:
- sigaction(SIGABRT, &FOCUS_abrt_old_action, NULL);
+ sigaction(SIGABRT, &system_abrt_old_action, NULL);
raise( signo);
break;
case SIGSEGV:
- sigaction(SIGSEGV, &FOCUS_segv_old_action, NULL);
+ sigaction(SIGSEGV, &system_segv_old_action, NULL);
raise( signo);
break;
case SIGTERM:
- sigaction(SIGTERM, &FOCUS_term_old_action, NULL);
+ sigaction(SIGTERM, &system_term_old_action, NULL);
raise( signo);
break;
case SIGSYS:
- sigaction(SIGSYS, &FOCUS_sys_old_action, NULL);
+ sigaction(SIGSYS, &system_sys_old_action, NULL);
raise( signo);
break;
case SIGXCPU:
- sigaction(SIGXCPU, &FOCUS_xcpu_old_action, NULL);
+ sigaction(SIGXCPU, &system_xcpu_old_action, NULL);
raise( signo);
break;
default:
mm_sound_proxy_initialize();
-#ifdef USE_FOCUS
-
- struct sigaction FOCUS_action;
- FOCUS_action.sa_handler = _focus_signal_handler;
- FOCUS_action.sa_flags = SA_NOCLDSTOP;
- sigemptyset(&FOCUS_action.sa_mask);
+ struct sigaction system_action;
+ system_action.sa_handler = _system_signal_handler;
+ system_action.sa_flags = SA_NOCLDSTOP;
- sigaction(SIGINT, &FOCUS_action, &FOCUS_int_old_action);
- sigaction(SIGABRT, &FOCUS_action, &FOCUS_abrt_old_action);
- sigaction(SIGSEGV, &FOCUS_action, &FOCUS_segv_old_action);
- sigaction(SIGTERM, &FOCUS_action, &FOCUS_term_old_action);
- sigaction(SIGSYS, &FOCUS_action, &FOCUS_sys_old_action);
- sigaction(SIGXCPU, &FOCUS_action, &FOCUS_xcpu_old_action);
+ sigemptyset(&system_action.sa_mask);
-#endif
+ sigaction(SIGINT, &system_action, &system_int_old_action);
+ sigaction(SIGABRT, &system_action, &system_abrt_old_action);
+ sigaction(SIGSEGV, &system_action, &system_segv_old_action);
+ sigaction(SIGTERM, &system_action, &system_term_old_action);
+ sigaction(SIGSYS, &system_action, &system_sys_old_action);
+ sigaction(SIGXCPU, &system_action, &system_xcpu_old_action);
debug_fleave();
return ret;
debug_fenter();
+ ret = mm_sound_proxy_emergent_exit(getpid());
+ if (ret == MM_ERROR_NONE)
+ debug_msg("[Client] Success to emergnet_exit\n");
+ else
+ debug_error("[Client] Error occurred : 0x%x \n",ret);
+
+ sigaction(SIGINT, &system_int_old_action, NULL);
+ sigaction(SIGABRT, &system_abrt_old_action, NULL);
+ sigaction(SIGSEGV, &system_segv_old_action, NULL);
+ sigaction(SIGTERM, &system_term_old_action, NULL);
+ sigaction(SIGSYS, &system_sys_old_action, NULL);
+ sigaction(SIGXCPU, &system_xcpu_old_action, NULL);
+
ret = mm_sound_proxy_finalize();
#ifdef USE_FOCUS
int index = 0;
- int exit_pid = 0;
-
- exit_pid = getpid();
- for (index = 0; index < FOCUS_HANDLE_MAX; index++) {
- if (g_focus_sound_handle[index].is_used == true && g_focus_sound_handle[index].focus_tid == exit_pid) {
- mm_sound_proxy_emergent_exit_focus(exit_pid);
- }
- }
if (g_focus_thread) {
g_main_loop_quit(g_focus_loop);
g_focus_thread = NULL;
}
- /* is it necessary? */
- sigaction(SIGINT, &FOCUS_int_old_action, NULL);
- sigaction(SIGABRT, &FOCUS_abrt_old_action, NULL);
- sigaction(SIGSEGV, &FOCUS_segv_old_action, NULL);
- sigaction(SIGTERM, &FOCUS_term_old_action, NULL);
- sigaction(SIGSYS, &FOCUS_sys_old_action, NULL);
- sigaction(SIGXCPU, &FOCUS_xcpu_old_action, NULL);
-
#endif
debug_fleave();
return ret;
}
+int mm_sound_proxy_emergent_exit(int exit_pid)
+{
+ int ret = MM_ERROR_NONE;
+ GVariant* params = NULL;
+
+ debug_fenter();
+
+ params = g_variant_new("(i)", exit_pid);
+ if (params) {
+ if ((ret = mm_sound_dbus_emit_signal(AUDIO_PROVIDER_AUDIO_CLIENT, AUDIO_EVENT_EMERGENT_EXIT, params)) != MM_ERROR_NONE) {
+ debug_error("dbus emergent exit failed");
+ goto cleanup;
+ }
+ } else {
+ debug_error("Construct Param for emergent exit signal failed");
+ ret = MM_ERROR_SOUND_INTERNAL;
+ }
+
+cleanup:
+
+ debug_fleave();
+ return ret;
+}
+
/*------------------------------------------ FOCUS --------------------------------------------------*/
#ifdef USE_FOCUS
return ret;
}
-int mm_sound_proxy_emergent_exit_focus(int exit_pid)
-{
- int ret = MM_ERROR_NONE;
- GVariant* params = NULL, *result = NULL;
-
- debug_fenter();
-
- params = g_variant_new("(i)", exit_pid);
- if (params) {
- if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_FOCUS_SERVER, AUDIO_METHOD_EMERGENT_EXIT_FOCUS, params, &result)) != MM_ERROR_NONE) {
- debug_error("dbus emergent exit focus failed");
- goto cleanup;
- }
- } else {
- debug_error("Construct Param for method call failed");
- }
-
-cleanup:
- if (ret != MM_ERROR_NONE)
- g_variant_get(result, "(i)", &ret);
- if (result)
- g_variant_unref(result);
-
- debug_fleave();
- return ret;
-}
-
#endif /* USE_FOCUS */
/*------------------------------------------ FOCUS --------------------------------------------------*/
Name: libmm-sound
Summary: MMSound Package contains client lib and sound_server binary
-Version: 0.10.8
+Version: 0.10.9
Release: 0
Group: System/Libraries
License: Apache-2.0