int __fd__; \
int __timeout__ = client_get_api_timeout(player, api); \
type1 __value1__ = (type1)param1; \
+ int __tfd__[MUSE_NUM_FD];\
+ memset(__tfd__, -1, sizeof(__tfd__)); \
+ __tfd__[0] = tfd; \
if (CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
else {ret = PLAYER_ERROR_INVALID_STATE; break; } \
__sndMsg__ = muse_core_msg_json_factory_new(api, \
MUSE_TYPE_##type1, #param1, __value1__, \
0); \
- __len__ = muse_core_ipc_send_fd_msg(__fd__, tfd, __sndMsg__); \
+ __len__ = muse_core_ipc_send_fd_msg(__fd__, __tfd__, __sndMsg__); \
if (__len__ <= 0) { \
LOGE("sending message failed"); \
ret = PLAYER_ERROR_INVALID_OPERATION; \
int __fd__; \
int __timeout__ = client_get_api_timeout(player, api); \
int *__value__ = (int *)param; \
+ int __tfd__[MUSE_NUM_FD]; \
+ memset(__tfd__, -1, sizeof(__tfd__)); \
+ __tfd__[0] = tfd; \
if (CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
else {ret = PLAYER_ERROR_INVALID_STATE; break; } \
__sndMsg__ = muse_core_msg_json_factory_new(api, \
length / sizeof(int) + (length % sizeof(int) ? 1 : 0), \
__value__, \
0); \
- __len__ = muse_core_ipc_send_fd_msg(__fd__, tfd, __sndMsg__); \
+ __len__ = muse_core_ipc_send_fd_msg(__fd__, __tfd__, __sndMsg__); \
if (__len__ <= 0) { \
LOGE("sending message failed"); \
ret = PLAYER_ERROR_INVALID_OPERATION; \
#define INVALID_DEFAULT_VALUE -1
typedef struct {
- tbm_fd tfd;
+ tbm_fd tfd[MUSE_NUM_FD];
char* buffer;
} _player_recv_data;
/* continue the remained job */
}
if (tsurf) {
- LOGD("_player_media_packet_finalize tsurf destroy %p", tsurf);
+ /* LOGD("_player_media_packet_finalize tsurf destroy %p", tsurf); */
tbm_surface_destroy(tsurf);
tsurf = NULL;
}
tbm_surface_h tsurf = NULL;
if (media_packet_get_tbm_surface(pkt, &tsurf) == MEDIA_PACKET_ERROR_NONE) {
- LOGD("tsurf set to null %p", tsurf);
+ /* LOGD("tsurf set to null %p", tsurf); */
tsurf = NULL;
}
}
player_msg_get4(recv_data->buffer, width, INT, height, INT, size, INT, key, INT, ret_val);
if (ret_val) {
- if (recv_data->tfd < 0) {
+ if (recv_data->tfd[0] < 0) {
LOGE("There is no valid tbm_fd");
goto EXIT;
}
- bo = tbm_bo_import_fd(cb_info->bufmgr, recv_data->tfd);
+ bo = tbm_bo_import_fd(cb_info->bufmgr, recv_data->tfd[0]);
if (bo == NULL) {
LOGE("TBM get error : bo is NULL");
goto EXIT;
}
EXIT:
- if (recv_data->tfd > INVALID_DEFAULT_VALUE)
- close(recv_data->tfd);
- recv_data->tfd = INVALID_DEFAULT_VALUE;
+ if (recv_data->tfd[0] > INVALID_DEFAULT_VALUE)
+ close(recv_data->tfd[0]);
+ memset(recv_data->tfd, INVALID_DEFAULT_VALUE, sizeof(recv_data->tfd));
if (bo)
tbm_bo_unref(bo);
return;
}
-static player_tsurf_info_t* __player_get_tsurf_from_list(callback_cb_info_s * cb_info, tbm_key key, tbm_surface_info_s sinfo)
+static player_tsurf_info_t* __player_get_tsurf_from_list(callback_cb_info_s * cb_info, int *key, tbm_surface_info_s sinfo)
{
GList *l = NULL;
g_mutex_lock(&cb_info->data_mutex);
for (l = g_list_first(cb_info->tsurf_list); l; l = g_list_next(l)) {
player_tsurf_info_t *tmp = (player_tsurf_info_t *)l->data;
- if (tmp && (tmp->key == key)) { /* need to check fd, bo num, etc */
- LOGD("found tsurf_data of tbm_key %d", key);
+ if (tmp && key && (tmp->key[0] == key[0])) {
+ LOGD("found tsurf_data of tbm_key %d", key[0]);
/* need to check tsuf info to support DRC */
if ((tbm_surface_get_height(tmp->tsurf) != sinfo.height) ||
}
}
g_mutex_unlock(&cb_info->data_mutex);
- LOGD("there is no tsurf_data for tbm_key:%d", key);
+ LOGD("there is no tsurf_data for tbm_key:%d", key[0]);
return NULL;
}
static void __media_packet_video_frame_cb_handler(callback_cb_info_s * cb_info, _player_recv_data *recv_data)
{
tbm_bo bo[4] = { NULL, };
- tbm_key key[4] = { 0, };
+ int key[4] = { INVALID_DEFAULT_VALUE, };
tbm_surface_info_s sinfo;
char *surface_info = (char *)&sinfo;
media_packet_h pkt = NULL;
LOGE("failed to get value from msg. jobj:%p, err:%d", jobj, err);
if (jobj)
muse_core_msg_json_object_free(jobj);
- return;
+ goto ERROR;
}
muse_core_msg_json_object_free(jobj);
if (!cb_info) {
LOGE("cb_info is null");
- return;
+ goto ERROR;
}
if (!cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME]) {
/* send msg to release packet. */
LOGE("_video_decoded_cb is not set");
- player_msg_send1_no_return(MUSE_PLAYER_API_MEDIA_PACKET_FINALIZE_CB, cb_info->fd, POINTER, packet);
- return;
+ goto ERROR;
}
+ if (recv_data->tfd[0] <= INVALID_DEFAULT_VALUE) {
+ LOGE("tbm fd is invalid");
+ goto ERROR;
+ }
- tsurf_data = __player_get_tsurf_from_list(cb_info, key[0], sinfo);
+ tsurf_data = __player_get_tsurf_from_list(cb_info, key, sinfo);
if (!tsurf_data) {
- for (i = 0; i < 4; i++) {
- if (key[i]) {
- bo_num++;
- bo[i] = tbm_bo_import(cb_info->bufmgr, key[i]);
- }
+ for (i = 0; i < MUSE_NUM_FD; i++) {
+ if (recv_data->tfd[i] <= INVALID_DEFAULT_VALUE)
+ break;
+
+ bo_num++;
+ bo[i] = tbm_bo_import_fd(cb_info->bufmgr, recv_data->tfd[i]);
}
tsurf_data = g_new(player_tsurf_info_t, 1);
LOGE("failed to alloc tsurf info");
goto ERROR;
}
+ memset(tsurf_data->key, INVALID_DEFAULT_VALUE, sizeof(tsurf_data->key));
tsurf = tbm_surface_internal_create_with_bos(&sinfo, bo, bo_num);
if (!tsurf) {
g_free(tsurf_data);
goto ERROR;
}
- tsurf_data->key = key[0];
+ memcpy(tsurf_data->key, key, sizeof(tsurf_data->key));
tsurf_data->tsurf = tsurf;
if (cb_info->use_tsurf_pool) {
g_mutex_lock(&cb_info->data_mutex);
media_packet_destroy(pkt);
}
+ for (i = 0; i < MUSE_NUM_FD; i++) { /* if tsruf pool is enabled, bo_num can be zero. */
+ if (recv_data->tfd[i] > INVALID_DEFAULT_VALUE)
+ close(recv_data->tfd[i]);
+ }
+
for (i = 0; i < bo_num; i++) {
if (bo[i])
tbm_bo_unref(bo[i]);
}
+
+ memset(recv_data->tfd, INVALID_DEFAULT_VALUE, sizeof(recv_data->tfd));
return;
ERROR:
if (fin_data)
g_free(fin_data);
+ for (i = 0; i < MUSE_NUM_FD; i++) { /* if tsruf pool is enabled, bo_num can be zero. */
+ if (recv_data->tfd[i] > INVALID_DEFAULT_VALUE)
+ close(recv_data->tfd[i]);
+ }
+
for (i = 0; i < bo_num; i++) {
if (bo[i])
tbm_bo_unref(bo[i]);
}
+ memset(recv_data->tfd, INVALID_DEFAULT_VALUE, sizeof(recv_data->tfd));
+
+ if (cb_info && packet)
+ player_msg_send1_no_return(MUSE_PLAYER_API_MEDIA_PACKET_FINALIZE_CB, cb_info->fd, POINTER, packet);
- player_msg_send1_no_return(MUSE_PLAYER_API_MEDIA_PACKET_FINALIZE_CB, cb_info->fd, POINTER, packet);
return;
}
return;
}
- if (recv_data->tfd < 0) {
+ if (recv_data->tfd[0] < 0) {
LOGE("failed to get tbm_fd(key:%d)", key);
goto EXIT;
}
- bo = tbm_bo_import_fd(cb_info->bufmgr, recv_data->tfd);
+ bo = tbm_bo_import_fd(cb_info->bufmgr, recv_data->tfd[0]);
if (bo == NULL) {
- LOGE("TBM get error : bo is NULL, tbm_fd:%d(key:%d)", recv_data->tfd, key);
+ LOGE("TBM get error : bo is NULL, tbm_fd:%d(key:%d)", recv_data->tfd[0], key);
goto EXIT;
}
tbm_bo_unmap(bo);
EXIT:
- if (recv_data->tfd > INVALID_DEFAULT_VALUE)
- close(recv_data->tfd);
- recv_data->tfd = INVALID_DEFAULT_VALUE;
+ if (recv_data->tfd[0] > INVALID_DEFAULT_VALUE)
+ close(recv_data->tfd[0]);
+ memset(recv_data->tfd, INVALID_DEFAULT_VALUE, sizeof(recv_data->tfd));
if (bo)
tbm_bo_unref(bo);
callback_cb_info_s *cb_info = data;
char *recvMsg = NULL;
muse_core_msg_parse_err_e err;
- tbm_fd tfd = INVALID_DEFAULT_VALUE;
+ tbm_fd tfd[MUSE_NUM_FD];
+ memset(tfd, INVALID_DEFAULT_VALUE, sizeof(tfd));
while (g_atomic_int_get(&cb_info->running)) {
len = 0;
err = MUSE_MSG_PARSE_ERROR_NONE;
- len = player_recv_msg(cb_info, &tfd);
+ len = player_recv_msg(cb_info, tfd);
if (len <= 0)
break;
g_mutex_lock(&cb_info->player_mutex);
cb_info->buff.recved++;
_add_ret_msg(api, cb_info, offset, parse_len);
- if (api == MUSE_PLAYER_API_GET_ALBUM_ART && tfd != INVALID_DEFAULT_VALUE) {
+ if (api == MUSE_PLAYER_API_GET_ALBUM_ART && tfd[0] != INVALID_DEFAULT_VALUE) {
LOGD("get tbm fd for album art.");
- cb_info->tfd = tfd;
+ cb_info->tfd = tfd[0];
}
g_cond_signal(&cb_info->player_cond[api]);
g_mutex_unlock(&cb_info->player_mutex);
g_mutex_lock(&cb_info->player_mutex);
recv_data = g_new0(_player_recv_data, 1);
if (recv_data != NULL) {
- recv_data->tfd = tfd;
+ memcpy(recv_data->tfd, tfd, sizeof(recv_data->tfd));
recv_data->buffer = strndup(recvMsg+offset, parse_len);
} else {
LOGE("failed to alloc recv_data.");