From 9a148e59a67184466974091ffab6f82abcd6441d Mon Sep 17 00:00:00 2001 From: Gilbok Lee Date: Fri, 18 Sep 2020 11:02:37 +0900 Subject: [PATCH] [0.3.136] Return error when muse client get module index failed Change-Id: I48b4ae33cb63ee3f78a58539e666553dfa8f9e72 --- include/player_private.h | 2 +- packaging/capi-media-player.spec | 2 +- src/player.c | 21 +++++++++------------ 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/include/player_private.h b/include/player_private.h index 8cfb668..64d0b5d 100644 --- a/include/player_private.h +++ b/include/player_private.h @@ -91,7 +91,7 @@ do { \ } \ } while (0) -#define CONNECTION_RETRY 51 +#define CONNECTION_RETRY 50 #define CONNECTION_TIME_OUT 50 /* ms */ #define CREATE_CB_TIME_OUT 400 /* ms */ #define CALLBACK_TIME_OUT 5000 /* ms */ diff --git a/packaging/capi-media-player.spec b/packaging/capi-media-player.spec index 204afdf..2d86e57 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.135 +Version: 0.3.136 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/player.c b/src/player.c index 22b493d..1ff746c 100644 --- a/src/player.c +++ b/src/player.c @@ -2024,9 +2024,8 @@ int player_create(player_h *player) muse_player_api_e api = MUSE_PLAYER_API_CREATE; int module_index = INVALID_DEFAULT_VALUE; player_cli_s *pc = NULL; - char *ret_buf = NULL; + gchar *ret_buf = NULL; int retry_count = CONNECTION_RETRY; - bool retry = false; PLAYER_INSTANCE_CHECK(player); @@ -2036,19 +2035,19 @@ int player_create(player_h *player) if (pc == NULL) return PLAYER_ERROR_OUT_OF_MEMORY; - while (--retry_count) { + while (retry_count--) { ret = PLAYER_ERROR_NONE; sock_fd = muse_client_new(); if (sock_fd <= INVALID_DEFAULT_VALUE) { LOGE("connection failure %d", errno); ret = PLAYER_ERROR_INVALID_OPERATION; - retry = true; usleep(CONNECTION_TIME_OUT * G_TIME_SPAN_MILLISECOND); - goto ERROR; + goto ERROR_RETRY; } if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) { LOGE("muse client get module index failed"); + ret = PLAYER_ERROR_INVALID_OPERATION; goto ERROR; } @@ -2066,11 +2065,8 @@ int player_create(player_h *player) } ret = client_wait_for_server_ack(api, pc->cb_info, CREATE_CB_TIME_OUT); - if (ret == PLAYER_ERROR_INVALID_OPERATION) { - retry = true; - goto ERROR; - } - retry = false; + if (ret == PLAYER_ERROR_INVALID_OPERATION) + goto ERROR_RETRY; if (!_player_event_queue_new(pc->cb_info)) { LOGE("fail to create event queue"); @@ -2120,6 +2116,8 @@ int player_create(player_h *player) return ret; ERROR: + retry_count = 0; +ERROR_RETRY: if (pc && pc->cb_info) { if (pc->cb_info->event_queue.running) _player_event_queue_destroy(pc->cb_info); @@ -2129,11 +2127,10 @@ ERROR: muse_client_close(sock_fd); } sock_fd = INVALID_DEFAULT_VALUE; + g_free(ret_buf); ret_buf = NULL; LOGE("ret value : %d, retry #%d", ret, CONNECTION_RETRY - retry_count); - if (!retry) - break; } g_free(pc); pc = NULL; -- 2.7.4