debug_log("Dbus subscirbe signal with Obj'%s' Intf'%s' sig'%s'", object_name, intf_name, signal_name);
- subs_id = g_dbus_connection_signal_subscribe(conn, NULL, intf_name, signal_name, object_name, \
- NULL , G_DBUS_SIGNAL_FLAGS_NONE , signal_cb, userdata, NULL );
+ subs_id = g_dbus_connection_signal_subscribe(conn, NULL, intf_name, signal_name, object_name,
+ NULL, G_DBUS_SIGNAL_FLAGS_NONE , signal_cb, userdata, freefunc);
if (!subs_id) {
debug_error ("g_dbus_connection_signal_subscribe() failed ");
struct callback_data *cb_data = (struct callback_data*) data;
if (cb_data) {
- if (cb_data->extra_data)
- g_free(cb_data->extra_data);
+ g_free(cb_data->extra_data);
g_free(cb_data);
}
}
return true;
ERROR:
- if (g_src_funcs)
- g_free(g_src_funcs);
- if (g_poll_fd)
- g_free(g_poll_fd);
+ g_free(g_src_funcs);
+ g_free(g_poll_fd);
if (g_src)
g_source_unref(g_src);
return false;
}
-static bool _focus_remove_sound_callback(int index, gushort events)
+static bool _focus_remove_sound_callback(int index)
{
bool ret = true;
+ focus_sound_info_t *h = NULL;
debug_fenter();
- g_mutex_clear(&g_focus_sound_handle[index].focus_lock);
+ h = &g_focus_sound_handle[index];
+ if (h == NULL) {
+ debug_error("g_focus_sound_handle[%d] is NULL", index);
+ return false;
+ }
- GSourceFuncs *g_src_funcs = g_focus_sound_handle[index].g_src_funcs;
- GPollFD *g_poll_fd = g_focus_sound_handle[index].g_poll_fd; /* store file descriptor */
- if (!g_poll_fd) {
- debug_error("g_poll_fd is null..");
+ if (h->focus_src && h->g_poll_fd) {
+ debug_log("g_source_remove_poll : fd(%d), event(0x%x)",
+ h->g_poll_fd->fd, h->g_poll_fd->events);
+ g_source_remove_poll(h->focus_src, h->g_poll_fd);
+ } else {
+ debug_error("[%d] focus_src[%p], g_poll_fd[%p]",
+ index, h->focus_src, h->g_poll_fd);
ret = false;
- goto RELEASE;
}
- g_poll_fd->fd = g_focus_sound_handle[index].focus_fd;
- g_poll_fd->events = events;
- if (!g_focus_sound_handle[index].focus_src) {
- debug_error("g_focus_sound_handle[%d].focus_src is null..", index);
- ret = false;
- goto RELEASE;
+ if (h->focus_src) {
+ g_source_destroy(h->focus_src);
+ g_source_unref(h->focus_src);
+ h->focus_src = NULL;
}
- g_source_remove_poll(g_focus_sound_handle[index].focus_src, g_poll_fd);
- debug_log("g_source_remove_poll : fd(%d), event(%x)", g_poll_fd->fd, g_poll_fd->events);
-RELEASE:
- if (g_focus_sound_handle[index].focus_src)
- g_source_destroy(g_focus_sound_handle[index].focus_src);
+ debug_log("g_free : g_src_funcs(%p), g_poll_fd(%p)",
+ h->g_src_funcs, h->g_poll_fd);
- debug_log("g_free : g_src_funcs(%x), g_poll_fd(%x)", g_src_funcs, g_poll_fd);
- if (g_src_funcs) {
- g_free(g_src_funcs);
- g_src_funcs = NULL;
- }
- if (g_poll_fd) {
- g_free(g_poll_fd);
- g_poll_fd = NULL;
- }
+ g_free(h->g_src_funcs);
+ h->g_src_funcs = NULL;
- g_focus_sound_handle[index].g_src_funcs = NULL;
- g_focus_sound_handle[index].g_poll_fd = NULL;
- g_focus_sound_handle[index].focus_src = NULL;
- g_focus_sound_handle[index].focus_callback = NULL;
- g_focus_sound_handle[index].watch_callback = NULL;
+ g_free(h->g_poll_fd);
+ h->g_poll_fd = NULL;
+
+ h->focus_callback = NULL;
+ h->watch_callback = NULL;
+
+ g_mutex_clear(&h->focus_lock);
debug_fleave();
+
return ret;
}
{
debug_fenter();
if (!is_for_watching) {
- if (!_focus_add_sound_callback(index, g_focus_sound_handle[index].focus_fd, (gushort)POLLIN | POLLPRI, _focus_callback_handler)) {
- debug_error("failed to _focus_add_sound_callback()");
- //return false;
- }
+ if (!_focus_add_sound_callback(index, g_focus_sound_handle[index].focus_fd,
+ (gushort)POLLIN | POLLPRI, _focus_callback_handler))
+ debug_error("failed to _focus_add_sound_callback(%p)", _focus_callback_handler);
} else { // need to check if it's necessary
- if (!_focus_add_sound_callback(index, g_focus_sound_handle[index].focus_fd, (gushort)POLLIN | POLLPRI, _focus_watch_callback_handler)) {
- debug_error("failed to _focus_add_sound_callback()");
- //return false;
- }
+ if (!_focus_add_sound_callback(index, g_focus_sound_handle[index].focus_fd,
+ (gushort)POLLIN | POLLPRI, _focus_watch_callback_handler))
+ debug_error("failed to _focus_add_sound_callback(%p)", _focus_watch_callback_handler);
}
debug_fleave();
}
static void _focus_remove_callback(int index)
{
debug_fenter();
- if (!_focus_remove_sound_callback(index, (gushort)POLLIN | POLLPRI)) {
+ if (!_focus_remove_sound_callback(index))
debug_error("failed to __focus_remove_sound_callback()");
- //return false;
- }
debug_fleave();
}