From: Gilbok Lee Date: Fri, 17 Feb 2017 09:06:16 +0000 (+0900) Subject: [0.3.49] add disconnect error callback for using idle event X-Git-Tag: accepted/tizen/common/20170303.090825~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F57%2F116957%2F1;p=platform%2Fcore%2Fapi%2Fplayer.git [0.3.49] add disconnect error callback for using idle event Change-Id: I27e5e54d79cdcd23c0e261afc8d8ae12f162dafe --- diff --git a/packaging/capi-media-player.spec b/packaging/capi-media-player.spec index 261f0f8..a35627f 100644 --- a/packaging/capi-media-player.spec +++ b/packaging/capi-media-player.spec @@ -1,6 +1,6 @@ Name: capi-media-player Summary: A Media Player API -Version: 0.3.48 +Version: 0.3.49 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/player.c b/src/player.c index 671b904..513c9e0 100755 --- a/src/player.c +++ b/src/player.c @@ -612,6 +612,13 @@ static void __error_cb_handler(callback_cb_info_s * cb_info, _player_recv_data * ((player_error_cb) cb_info->user_cb[ev]) (code, cb_info->user_data[ev]); } +static void __disconnected_error_cb_handler(callback_cb_info_s * cb_info, _player_recv_data *recv_data) +{ + muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_ERROR; + + ((player_error_cb) cb_info->user_cb[ev]) (PLAYER_ERROR_SERVICE_DISCONNECTED, cb_info->user_data[ev]); +} + static void __buffering_cb_handler(callback_cb_info_s * cb_info, _player_recv_data *recv_data) { int percent; @@ -1171,6 +1178,7 @@ static void (*_user_callbacks[MUSE_PLAYER_EVENT_TYPE_NUM]) (callback_cb_info_s * #ifdef TIZEN_FEATURE_EVAS_RENDERER __retrieve_buffer_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER */ #endif + __disconnected_error_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_SERVICE_DISCONNECTED */ }; gboolean _player_event_job_function(void *user_data) @@ -1212,8 +1220,10 @@ DONE: g_mutex_unlock(&data->event_mutex); g_mutex_clear(&data->event_mutex); - g_free(data->recv_data->buffer); - g_free(data->recv_data); + if (data->recv_data) { + g_free(data->recv_data->buffer); + g_free(data->recv_data); + } g_free(data); return FALSE; /* remove from the event list */ @@ -1226,6 +1236,7 @@ static bool _player_need_sync_context(int event_id) (event_id == MUSE_PLAYER_EVENT_TYPE_PD) || (event_id == MUSE_PLAYER_EVENT_TYPE_COMPLETE) || (event_id == MUSE_PLAYER_EVENT_TYPE_ERROR) || + (event_id == MUSE_PLAYER_EVENT_TYPE_SERVICE_DISCONNECTED) || (event_id == MUSE_PLAYER_EVENT_TYPE_PREPARE)) { LOGD("%d callback will be issued in the mainloop.", event_id); return TRUE; @@ -1539,11 +1550,23 @@ static void _remove_all_ret_msg(callback_cb_info_s * cb_info) static void _notify_disconnected(callback_cb_info_s * cb_info) { - int code = PLAYER_ERROR_SERVICE_DISCONNECTED; - muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_ERROR; - if (!cb_info || !cb_info->user_cb[ev]) + muse_player_event_e event = MUSE_PLAYER_EVENT_TYPE_SERVICE_DISCONNECTED; + if (!cb_info || !cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_ERROR]) return; - ((player_error_cb) cb_info->user_cb[ev]) (code, cb_info->user_data[ev]); + + if (_user_callbacks[event]) { + _player_cb_data *data = NULL; + data = g_new(_player_cb_data, 1); + if (!data) { + LOGE("fail to alloc mem"); + return; + } + data->int_data = (int)event; + data->cb_info = cb_info; + data->recv_data = NULL; + g_mutex_init(&data->event_mutex); + _player_event_queue_add(&cb_info->event_queue, data); + } } static void *client_cb_handler(gpointer data)