diff options
author | Haejeong Kim <backto.kim@samsung.com> | 2017-09-21 17:16:37 +0900 |
---|---|---|
committer | Haejeong Kim <backto.kim@samsung.com> | 2017-09-21 17:17:33 +0900 |
commit | da9ed176b29970ec7d745183392b2e409fb52c3c (patch) | |
tree | b63c06d05191968d4a8570edba1faad1b0c0d1b2 | |
parent | 85f0a53a28c5d701ccdb5c2408d0ebfa5409f1c4 (diff) | |
download | media-controller-da9ed176b29970ec7d745183392b2e409fb52c3c.tar.gz media-controller-da9ed176b29970ec7d745183392b2e409fb52c3c.tar.bz2 media-controller-da9ed176b29970ec7d745183392b2e409fb52c3c.zip |
Crash issue fix. Fix wrong listener list management and remove empty listener
Change-Id: I6fa61669504dfc61690a1c88cc74b7f8a864e30e
-rwxr-xr-x | include/media_controller_private.h | 6 | ||||
-rwxr-xr-x | packaging/capi-media-controller.spec | 2 | ||||
-rwxr-xr-x | src/media_controller_client.c | 50 | ||||
-rwxr-xr-x | src/media_controller_ipc.c | 35 | ||||
-rwxr-xr-x | src/media_controller_server.c | 20 |
5 files changed, 49 insertions, 64 deletions
diff --git a/include/media_controller_private.h b/include/media_controller_private.h index d28007d..b42019d 100755 --- a/include/media_controller_private.h +++ b/include/media_controller_private.h @@ -238,9 +238,9 @@ int mc_util_get_command_availabe(const char *name, const char *command_type, con /* for d-bus IPC */ int mc_ipc_get_dbus_connection(GDBusConnection **conn, int *dref_count); int mc_ipc_unref_dbus_connection(GDBusConnection *conn, int *dref_count); -int mc_ipc_register_listener(GList *manage_list, GDBusConnection *connection, const char *interface_name, const char *signal_name, mc_signal_received_cb callback, void *user_data); -int mc_ipc_unregister_listener(GList *manage_list, GDBusConnection *connection, const char *interface_name, const char *signal_name); -int mc_ipc_unregister_all_listener(GList *manage_list, GDBusConnection *connection); +int mc_ipc_register_listener(GList **manage_list, GDBusConnection *connection, const char *interface_name, const char *signal_name, mc_signal_received_cb callback, void *user_data); +int mc_ipc_unregister_listener(GList **manage_list, GDBusConnection *connection, const char *interface_name, const char *signal_name); +int mc_ipc_unregister_all_listener(GList **manage_list, GDBusConnection *connection); int mc_ipc_send_message(GDBusConnection *connection, const char *dbus_name, const char *interface_name, const char* signal_name, const char* message, int flags); int mc_ipc_send_message_to_server(mc_msg_type_e msg_type, const int type, const char *request_msg); int mc_ipc_service_connect(const int type); diff --git a/packaging/capi-media-controller.spec b/packaging/capi-media-controller.spec index c690a38..a23d8cf 100755 --- a/packaging/capi-media-controller.spec +++ b/packaging/capi-media-controller.spec @@ -1,6 +1,6 @@ Name: capi-media-controller Summary: A media controller library in Tizen Native API -Version: 0.1.48 +Version: 0.1.49 Release: 1 Group: Multimedia/API License: Apache-2.0 diff --git a/src/media_controller_client.c b/src/media_controller_client.c index d5742dd..edbd83e 100755 --- a/src/media_controller_client.c +++ b/src/media_controller_client.c @@ -186,13 +186,6 @@ static int __mc_client_create(media_controller_client_s **mc_client) goto Error; } - _client->listeners = g_list_alloc(); - if (_client->listeners == NULL) { - ret = MEDIA_CONTROLLER_ERROR_OUT_OF_MEMORY; - mc_error("Error allocation list %d", ret); - goto Error; - } - *mc_client = _client; return MEDIA_CONTROLLER_ERROR_NONE; @@ -203,9 +196,6 @@ Error: if (_client->db_handle) mc_db_disconnect(_client->db_handle); - if (_client->listeners) - g_list_free(_client->listeners); - MC_SAFE_FREE(_client->client_name); MC_SAFE_FREE(_client); @@ -249,7 +239,7 @@ static int __mc_client_register_filter_listener(media_controller_client_s *mc_cl ret = mc_util_make_filter_interface_name(MC_DBUS_UPDATE_INTERFACE, server_name, &filter_interface_name); mc_retvm_if(ret != MEDIA_CONTROLLER_ERROR_NONE, ret, "Fail mc_util_make_filter_interface_name"); - ret = mc_ipc_register_listener(mc_client->listeners, mc_client->dconn, filter_interface_name, signal_name, callback, user_data); + ret = mc_ipc_register_listener(&mc_client->listeners, mc_client->dconn, filter_interface_name, signal_name, callback, user_data); if (ret == MEDIA_CONTROLLER_ERROR_NONE) *filter_list = g_list_append(*filter_list, strdup(filter_interface_name)); @@ -284,7 +274,7 @@ static int __mc_client_unregister_filter_listener(media_controller_client_s *mc_ } /*Unregister listener*/ - ret = mc_ipc_unregister_listener(mc_client->listeners, mc_client->dconn, filter_interface_name, signal_name); + ret = mc_ipc_unregister_listener(&mc_client->listeners, mc_client->dconn, filter_interface_name, signal_name); if (ret != MEDIA_CONTROLLER_ERROR_NONE) { MC_SAFE_FREE(filter_interface_name); return ret; @@ -316,7 +306,7 @@ static int __mc_client_unregister_filter_listener(media_controller_client_s *mc_ mc_debug("[%d][%s]", idx, interface_name); /*Unregister listener*/ - ret = mc_ipc_unregister_listener(mc_client->listeners, mc_client->dconn, interface_name, signal_name); + ret = mc_ipc_unregister_listener(&mc_client->listeners, mc_client->dconn, interface_name, signal_name); if (ret != MEDIA_CONTROLLER_ERROR_NONE) mc_error("Fail mc_ipc_unregister_listener"); @@ -383,7 +373,7 @@ int mc_client_set_server_update_cb(mc_client_h client, mc_server_state_updated_c mc_client->server_state_cb.callback = callback; mc_client->server_state_cb.user_data = user_data; - ret = mc_ipc_register_listener(mc_client->listeners, mc_client->dconn, MC_DBUS_UPDATE_INTERFACE, MC_DBUS_SIGNAL_NAME_SERVER_STATE, + ret = mc_ipc_register_listener(&mc_client->listeners, mc_client->dconn, MC_DBUS_UPDATE_INTERFACE, MC_DBUS_SIGNAL_NAME_SERVER_STATE, __client_server_cb, (void *)&(mc_client->server_state_cb)); return ret; @@ -396,7 +386,7 @@ int mc_client_unset_server_update_cb(mc_client_h client) mc_retvm_if(mc_client == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL"); - ret = mc_ipc_unregister_listener(mc_client->listeners, mc_client->dconn, MC_DBUS_UPDATE_INTERFACE, MC_DBUS_SIGNAL_NAME_SERVER_STATE); + ret = mc_ipc_unregister_listener(&mc_client->listeners, mc_client->dconn, MC_DBUS_UPDATE_INTERFACE, MC_DBUS_SIGNAL_NAME_SERVER_STATE); ret = __mc_client_unregister_filter_listener(mc_client, &mc_client->server_state_cb.filter_list, NULL, MC_DBUS_SIGNAL_NAME_SERVER_STATE); @@ -419,7 +409,7 @@ int mc_client_set_playback_update_cb(mc_client_h client, mc_playback_updated_cb mc_client->playback_cb.callback = callback; mc_client->playback_cb.user_data = user_data; - ret = mc_ipc_register_listener(mc_client->listeners, mc_client->dconn, MC_DBUS_UPDATE_INTERFACE, MC_DBUS_SIGNAL_NAME_PLAY_BACK, + ret = mc_ipc_register_listener(&mc_client->listeners, mc_client->dconn, MC_DBUS_UPDATE_INTERFACE, MC_DBUS_SIGNAL_NAME_PLAY_BACK, __client_playback_cb, (void *)&(mc_client->playback_cb)); return ret; @@ -432,7 +422,7 @@ int mc_client_unset_playback_update_cb(mc_client_h client) mc_retvm_if(mc_client == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL"); - ret = mc_ipc_unregister_listener(mc_client->listeners, mc_client->dconn, MC_DBUS_UPDATE_INTERFACE, MC_DBUS_SIGNAL_NAME_PLAY_BACK); + ret = mc_ipc_unregister_listener(&mc_client->listeners, mc_client->dconn, MC_DBUS_UPDATE_INTERFACE, MC_DBUS_SIGNAL_NAME_PLAY_BACK); ret = __mc_client_unregister_filter_listener(mc_client, &mc_client->playback_cb.filter_list, NULL, MC_DBUS_SIGNAL_NAME_PLAY_BACK); @@ -455,7 +445,7 @@ int mc_client_set_metadata_update_cb(mc_client_h client, mc_metadata_updated_cb mc_client->metadata_cb.callback = callback; mc_client->metadata_cb.user_data = user_data; - ret = mc_ipc_register_listener(mc_client->listeners, mc_client->dconn, MC_DBUS_UPDATE_INTERFACE, MC_DBUS_SIGNAL_NAME_METADATA, + ret = mc_ipc_register_listener(&mc_client->listeners, mc_client->dconn, MC_DBUS_UPDATE_INTERFACE, MC_DBUS_SIGNAL_NAME_METADATA, __client_metadata_cb, (void *)(mc_client)); return ret; @@ -468,7 +458,7 @@ int mc_client_unset_metadata_update_cb(mc_client_h client) mc_retvm_if(mc_client == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL"); - ret = mc_ipc_unregister_listener(mc_client->listeners, mc_client->dconn, MC_DBUS_UPDATE_INTERFACE, MC_DBUS_SIGNAL_NAME_METADATA); + ret = mc_ipc_unregister_listener(&mc_client->listeners, mc_client->dconn, MC_DBUS_UPDATE_INTERFACE, MC_DBUS_SIGNAL_NAME_METADATA); ret = __mc_client_unregister_filter_listener(mc_client, &mc_client->metadata_cb.filter_list, NULL, MC_DBUS_SIGNAL_NAME_METADATA); @@ -491,7 +481,7 @@ int mc_client_set_shuffle_mode_update_cb(mc_client_h client, mc_shuffle_mode_cha mc_client->shuffle_cb.callback = callback; mc_client->shuffle_cb.user_data = user_data; - ret = mc_ipc_register_listener(mc_client->listeners, mc_client->dconn, MC_DBUS_UPDATE_INTERFACE, MC_DBUS_SIGNAL_NAME_PLAYBACK_SHUFFLE, + ret = mc_ipc_register_listener(&mc_client->listeners, mc_client->dconn, MC_DBUS_UPDATE_INTERFACE, MC_DBUS_SIGNAL_NAME_PLAYBACK_SHUFFLE, __client_shuffle_cb, (void *)&(mc_client->shuffle_cb)); return ret; @@ -504,7 +494,7 @@ int mc_client_unset_shuffle_mode_update_cb(mc_client_h client) mc_retvm_if(mc_client == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL"); - ret = mc_ipc_unregister_listener(mc_client->listeners, mc_client->dconn, MC_DBUS_UPDATE_INTERFACE, MC_DBUS_SIGNAL_NAME_PLAYBACK_SHUFFLE); + ret = mc_ipc_unregister_listener(&mc_client->listeners, mc_client->dconn, MC_DBUS_UPDATE_INTERFACE, MC_DBUS_SIGNAL_NAME_PLAYBACK_SHUFFLE); ret = __mc_client_unregister_filter_listener(mc_client, &mc_client->shuffle_cb.filter_list, NULL, MC_DBUS_SIGNAL_NAME_PLAYBACK_SHUFFLE); @@ -528,7 +518,7 @@ int mc_client_set_repeat_mode_update_cb(mc_client_h client, mc_repeat_mode_chang mc_client->repeat_cb.callback = callback; mc_client->repeat_cb.user_data = user_data; - ret = mc_ipc_register_listener(mc_client->listeners, mc_client->dconn, MC_DBUS_UPDATE_INTERFACE, MC_DBUS_SIGNAL_NAME_PLAYBACK_REPEAT, + ret = mc_ipc_register_listener(&mc_client->listeners, mc_client->dconn, MC_DBUS_UPDATE_INTERFACE, MC_DBUS_SIGNAL_NAME_PLAYBACK_REPEAT, __client_repeat_cb, (void *)&(mc_client->repeat_cb)); return ret; @@ -541,7 +531,7 @@ int mc_client_unset_repeat_mode_update_cb(mc_client_h client) mc_retvm_if(mc_client == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL"); - ret = mc_ipc_unregister_listener(mc_client->listeners, mc_client->dconn, MC_DBUS_UPDATE_INTERFACE, MC_DBUS_SIGNAL_NAME_PLAYBACK_REPEAT); + ret = mc_ipc_unregister_listener(&mc_client->listeners, mc_client->dconn, MC_DBUS_UPDATE_INTERFACE, MC_DBUS_SIGNAL_NAME_PLAYBACK_REPEAT); ret = __mc_client_unregister_filter_listener(mc_client, &mc_client->repeat_cb.filter_list, NULL, MC_DBUS_SIGNAL_NAME_PLAYBACK_REPEAT); @@ -564,35 +554,35 @@ int mc_client_subscribe(mc_client_h client, const mc_subscription_type_e subscri case MC_SUBSCRIPTION_TYPE_SERVER_STATE: mc_retvm_if(mc_client->server_state_cb.callback == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Invalid callback"); - ret = mc_ipc_unregister_listener(mc_client->listeners, mc_client->dconn, MC_DBUS_UPDATE_INTERFACE, MC_DBUS_SIGNAL_NAME_SERVER_STATE); + ret = mc_ipc_unregister_listener(&mc_client->listeners, mc_client->dconn, MC_DBUS_UPDATE_INTERFACE, MC_DBUS_SIGNAL_NAME_SERVER_STATE); ret = __mc_client_register_filter_listener(mc_client, &mc_client->server_state_cb.filter_list, server_name, MC_DBUS_SIGNAL_NAME_SERVER_STATE, __client_server_cb, (void *)&(mc_client->server_state_cb)); break; case MC_SUBSCRIPTION_TYPE_PLAYBACK: mc_retvm_if(mc_client->playback_cb.callback == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Invalid callback"); - ret = mc_ipc_unregister_listener(mc_client->listeners, mc_client->dconn, MC_DBUS_UPDATE_INTERFACE, MC_DBUS_SIGNAL_NAME_PLAY_BACK); + ret = mc_ipc_unregister_listener(&mc_client->listeners, mc_client->dconn, MC_DBUS_UPDATE_INTERFACE, MC_DBUS_SIGNAL_NAME_PLAY_BACK); ret = __mc_client_register_filter_listener(mc_client, &mc_client->playback_cb.filter_list, server_name, MC_DBUS_SIGNAL_NAME_PLAY_BACK, __client_playback_cb, (void *)&(mc_client->playback_cb)); break; case MC_SUBSCRIPTION_TYPE_METADATA: mc_retvm_if(mc_client->metadata_cb.callback == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Invalid callback"); - ret = mc_ipc_unregister_listener(mc_client->listeners, mc_client->dconn, MC_DBUS_UPDATE_INTERFACE, MC_DBUS_SIGNAL_NAME_METADATA); + ret = mc_ipc_unregister_listener(&mc_client->listeners, mc_client->dconn, MC_DBUS_UPDATE_INTERFACE, MC_DBUS_SIGNAL_NAME_METADATA); ret = __mc_client_register_filter_listener(mc_client, &mc_client->metadata_cb.filter_list, server_name, MC_DBUS_SIGNAL_NAME_METADATA, __client_metadata_cb, (void *)(mc_client)); break; case MC_SUBSCRIPTION_TYPE_SHUFFLE_MODE: mc_retvm_if(mc_client->shuffle_cb.callback == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Invalid callback"); - ret = mc_ipc_unregister_listener(mc_client->listeners, mc_client->dconn, MC_DBUS_UPDATE_INTERFACE, MC_DBUS_SIGNAL_NAME_PLAYBACK_SHUFFLE); + ret = mc_ipc_unregister_listener(&mc_client->listeners, mc_client->dconn, MC_DBUS_UPDATE_INTERFACE, MC_DBUS_SIGNAL_NAME_PLAYBACK_SHUFFLE); ret = __mc_client_register_filter_listener(mc_client, &mc_client->shuffle_cb.filter_list, server_name, MC_DBUS_SIGNAL_NAME_PLAYBACK_SHUFFLE, __client_shuffle_cb, (void *)&(mc_client->shuffle_cb)); break; case MC_SUBSCRIPTION_TYPE_REPEAT_MODE: mc_retvm_if(mc_client->repeat_cb.callback == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Invalid callback"); - ret = mc_ipc_unregister_listener(mc_client->listeners, mc_client->dconn, MC_DBUS_UPDATE_INTERFACE, MC_DBUS_SIGNAL_NAME_PLAYBACK_REPEAT); + ret = mc_ipc_unregister_listener(&mc_client->listeners, mc_client->dconn, MC_DBUS_UPDATE_INTERFACE, MC_DBUS_SIGNAL_NAME_PLAYBACK_REPEAT); ret = __mc_client_register_filter_listener(mc_client, &mc_client->repeat_cb.filter_list, server_name, MC_DBUS_SIGNAL_NAME_PLAYBACK_REPEAT, __client_repeat_cb, (void *)&(mc_client->repeat_cb)); break; @@ -1018,7 +1008,7 @@ int mc_client_send_custom_command(mc_client_h client, const char *server_name, c char *interface_name_for_reply = mc_util_get_interface_name(MC_CLIENT, mc_client->client_name); mc_client->reply_cb.callback = callback; mc_client->reply_cb.user_data = user_data; - mc_ipc_register_listener(mc_client->listeners, mc_client->dconn, interface_name_for_reply, MC_DBUS_SIGNAL_NAME_CMD_REPLY, __client_reply_cb, (void *)&(mc_client->reply_cb)); + mc_ipc_register_listener(&mc_client->listeners, mc_client->dconn, interface_name_for_reply, MC_DBUS_SIGNAL_NAME_CMD_REPLY, __client_reply_cb, (void *)&(mc_client->reply_cb)); MC_SAFE_FREE(interface_name_for_reply); } @@ -1065,7 +1055,7 @@ int mc_client_destroy(mc_client_h client) ret = __mc_client_unregister_filter_listener(mc_client, &mc_client->repeat_cb.filter_list, NULL, MC_DBUS_SIGNAL_NAME_PLAYBACK_REPEAT); /*Unregister all listener*/ - ret = mc_ipc_unregister_all_listener(mc_client->listeners, mc_client->dconn); + ret = mc_ipc_unregister_all_listener(&mc_client->listeners, mc_client->dconn); if (ret != MEDIA_CONTROLLER_ERROR_NONE) mc_error("Error mc_ipc_unregister_all_listener [%d]", ret); diff --git a/src/media_controller_ipc.c b/src/media_controller_ipc.c index 57a5a3d..09ed146 100755 --- a/src/media_controller_ipc.c +++ b/src/media_controller_ipc.c @@ -165,7 +165,7 @@ int mc_ipc_unref_dbus_connection(GDBusConnection *connection, int *dref_count) return MEDIA_CONTROLLER_ERROR_NONE; } -int mc_ipc_register_listener(GList *listener_list, GDBusConnection *connection, const char *interface_name, const char *signal_name, mc_signal_received_cb callback, void *user_data) +int mc_ipc_register_listener(GList **listener_list, GDBusConnection *connection, const char *interface_name, const char *signal_name, mc_signal_received_cb callback, void *user_data) { char *key = NULL; guint handler = 0; @@ -182,7 +182,7 @@ int mc_ipc_register_listener(GList *listener_list, GDBusConnection *connection, return MEDIA_CONTROLLER_ERROR_INVALID_OPERATION; } - if (_mc_ipc_is_listener_duplicated(listener_list, key)) { + if (_mc_ipc_is_listener_duplicated(*listener_list, key)) { mc_error("listener is duplicated"); MC_SAFE_G_FREE(key); @@ -196,7 +196,7 @@ int mc_ipc_register_listener(GList *listener_list, GDBusConnection *connection, return MEDIA_CONTROLLER_ERROR_OUT_OF_MEMORY; } - handler = _mc_ipc_signal_subscribe(connection, interface_name, signal_name, listener_list); + handler = _mc_ipc_signal_subscribe(connection, interface_name, signal_name, *listener_list); listener->dbus_conn = connection; listener->interface_name = strdup(interface_name); @@ -206,16 +206,17 @@ int mc_ipc_register_listener(GList *listener_list, GDBusConnection *connection, listener->handler = handler; listener->key = key; - (listener_list) = g_list_append((listener_list), listener); + (*listener_list) = g_list_append(*listener_list, listener); - mc_debug("listener[%s] is registered. listener_cnt[%d]", key, g_list_length(listener_list)); + mc_debug("listener[%s] is registered. listener_cnt[%d]", key, g_list_length(*listener_list)); return MEDIA_CONTROLLER_ERROR_NONE; } -int mc_ipc_unregister_listener(GList *listener_list, GDBusConnection *connection, const char *interface_name, const char *signal_name) +int mc_ipc_unregister_listener(GList **listener_list, GDBusConnection *connection, const char *interface_name, const char *signal_name) { int i = 0; + int list_len = 0; char *key = NULL; mc_retvm_if(listener_list == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "listener_list is NULL"); @@ -229,16 +230,17 @@ int mc_ipc_unregister_listener(GList *listener_list, GDBusConnection *connection return MEDIA_CONTROLLER_ERROR_INVALID_OPERATION; } - for (i = g_list_length(listener_list) - 1; i >= 0; i--) { - mc_ipc_listener_s *listener = (mc_ipc_listener_s *)g_list_nth_data(listener_list, i); + list_len = g_list_length(*listener_list) - 1; + for (i = list_len; i >= 0; i--) { + mc_ipc_listener_s *listener = (mc_ipc_listener_s *)g_list_nth_data(*listener_list, i); if (listener && !g_strcmp0(listener->key, key)) { _mc_ipc_signal_unsubscribe(connection, listener->handler); MC_SAFE_FREE(listener->interface_name); MC_SAFE_FREE(listener->signal_name); MC_SAFE_G_FREE(listener->key); - (listener_list) = g_list_remove(listener_list, listener); + (*listener_list) = g_list_remove(*listener_list, listener); MC_SAFE_FREE(listener); - mc_debug("listener[%s.%s] is unregistered. listener_cnt[%d]", interface_name, signal_name, g_list_length(listener_list)); + mc_debug("listener[%s.%s] is unregistered. listener_cnt[%d]", interface_name, signal_name, g_list_length(*listener_list)); break; } } @@ -248,22 +250,25 @@ int mc_ipc_unregister_listener(GList *listener_list, GDBusConnection *connection return MEDIA_CONTROLLER_ERROR_NONE; } -int mc_ipc_unregister_all_listener(GList *listener_list, GDBusConnection *connection) +int mc_ipc_unregister_all_listener(GList **listener_list, GDBusConnection *connection) { int i = 0; + int list_len = 0; mc_retvm_if(connection == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "connection is NULL"); mc_retvm_if(listener_list == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "listener_list is NULL"); - for (i = g_list_length(listener_list) - 1; i >= 0; i--) { - mc_ipc_listener_s *listener = (mc_ipc_listener_s *)g_list_nth_data(listener_list, i); + list_len = g_list_length(*listener_list) - 1; + + for (i = list_len; i >= 0; i--) { + mc_ipc_listener_s *listener = (mc_ipc_listener_s *)g_list_nth_data(*listener_list, i); if (listener) { - mc_debug("listener[%s] is unregistered. listener_cnt[%d]", listener->key, g_list_length(listener_list)); + mc_debug("listener[%s] is unregistered. listener_cnt[%d]", listener->key, g_list_length(*listener_list)); _mc_ipc_signal_unsubscribe(connection, listener->handler); MC_SAFE_FREE(listener->interface_name); MC_SAFE_FREE(listener->signal_name); MC_SAFE_G_FREE(listener->key); - (listener_list) = g_list_remove(listener_list, listener); + (*listener_list) = g_list_remove(*listener_list, listener); MC_SAFE_FREE(listener); } } diff --git a/src/media_controller_server.c b/src/media_controller_server.c index 893aef3..b857a5c 100755 --- a/src/media_controller_server.c +++ b/src/media_controller_server.c @@ -52,13 +52,6 @@ static int __mc_server_create(media_controller_server_s **mc_server) goto ERROR; } - _server->listeners = g_list_alloc(); - if (_server->listeners == NULL) { - ret = MEDIA_CONTROLLER_ERROR_OUT_OF_MEMORY; - mc_error("Error allocation list %d", ret); - goto ERROR; - } - *mc_server = _server; return MEDIA_CONTROLLER_ERROR_NONE; @@ -70,9 +63,6 @@ ERROR: if (_server->db_handle) mc_db_disconnect(_server->db_handle); - if (_server->listeners) - g_list_free(_server->listeners); - MC_SAFE_FREE(_server->server_name); MC_SAFE_FREE(_server->metadata); MC_SAFE_FREE(_server); @@ -447,7 +437,7 @@ int mc_server_set_playback_state_command_received_cb(mc_server_h server, mc_serv mc_server->playback_state_reciever.user_data = user_data; char *interface_name = mc_util_get_interface_name(MC_SERVER, mc_server->server_name); - ret = mc_ipc_register_listener(mc_server->listeners, mc_server->dconn, interface_name, MC_DBUS_SIGNAL_NAME_PLAYBACK_STATE_CMD, __server_playback_state_command_cb, (void *)&(mc_server->playback_state_reciever)); + ret = mc_ipc_register_listener(&mc_server->listeners, mc_server->dconn, interface_name, MC_DBUS_SIGNAL_NAME_PLAYBACK_STATE_CMD, __server_playback_state_command_cb, (void *)&(mc_server->playback_state_reciever)); MC_SAFE_FREE(interface_name); @@ -462,7 +452,7 @@ int mc_server_unset_playback_state_command_received_cb(mc_server_h server) mc_retvm_if(mc_server == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL"); char *interface_name = mc_util_get_interface_name(MC_SERVER, mc_server->server_name); - ret = mc_ipc_unregister_listener(mc_server->listeners, mc_server->dconn, interface_name, MC_DBUS_SIGNAL_NAME_PLAYBACK_STATE_CMD); + ret = mc_ipc_unregister_listener(&mc_server->listeners, mc_server->dconn, interface_name, MC_DBUS_SIGNAL_NAME_PLAYBACK_STATE_CMD); mc_server->playback_state_reciever.callback = NULL; mc_server->playback_state_reciever.user_data = NULL; @@ -484,7 +474,7 @@ int mc_server_set_custom_command_received_cb(mc_server_h server, mc_server_custo mc_server->custom_cmd_reciever.user_data = user_data; char *interface_name = mc_util_get_interface_name(MC_SERVER, mc_server->server_name); - ret = mc_ipc_register_listener(mc_server->listeners, mc_server->dconn, interface_name, MC_DBUS_SIGNAL_NAME_CUSTOM_CMD, __server_custom_command_cb, (void *)&(mc_server->custom_cmd_reciever)); + ret = mc_ipc_register_listener(&mc_server->listeners, mc_server->dconn, interface_name, MC_DBUS_SIGNAL_NAME_CUSTOM_CMD, __server_custom_command_cb, (void *)&(mc_server->custom_cmd_reciever)); MC_SAFE_FREE(interface_name); @@ -499,7 +489,7 @@ int mc_server_unset_custom_command_received_cb(mc_server_h server) mc_retvm_if(mc_server == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL"); char *interface_name = mc_util_get_interface_name(MC_SERVER, mc_server->server_name); - ret = mc_ipc_unregister_listener(mc_server->listeners, mc_server->dconn, interface_name, MC_DBUS_SIGNAL_NAME_CUSTOM_CMD); + ret = mc_ipc_unregister_listener(&mc_server->listeners, mc_server->dconn, interface_name, MC_DBUS_SIGNAL_NAME_CUSTOM_CMD); mc_server->custom_cmd_reciever.callback = NULL; mc_server->custom_cmd_reciever.user_data = NULL; @@ -629,7 +619,7 @@ int mc_server_destroy(mc_server_h server) mc_retvm_if(mc_server == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL"); - ret = mc_ipc_unregister_all_listener(mc_server->listeners, mc_server->dconn); + ret = mc_ipc_unregister_all_listener(&mc_server->listeners, mc_server->dconn); if (ret != MEDIA_CONTROLLER_ERROR_NONE) mc_error("fail mc_ipc_unregister_all_listener [%d]", ret); |