* @brief Create and send message. Does not wait server result.
* @remarks Does NOT guarantee thread safe.
* @param[in] api The enum of module API.
- * @param[in] player The handle of capi media player.
+ * @param[in] fd The socket fd to send msg.
* @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
* @param[in] param the name of param is key, must be local variable. never be pointer.
*/
} while (0)
/**
+* @brief Create and send message. Wait for server result.
+* @remarks Does NOT guarantee thread safe.
+* @param[in] api The enum of module API.
+* @param[in] player The handle of capi media player.
+* @param[out] retbuf The buffer of return message. Must be char pointer.Must free after use.
+* @param[out] ret The return value from server.
+* @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
+* @param[in] param# the name of param is key, must be local variable. never be pointer.
+* @param[in] tfd the tbm fd from tbm_bo_export_fd().
+*/
+#define player_msg_send1_fd(api, player, retbuf, ret, type1, param1, tfd) \
+ do { \
+ char *__sndMsg__; \
+ int __len__; \
+ int __fd__; \
+ int __timeout__ = client_get_api_timeout(player, api); \
+ type1 __value1__ = (type1)param1; \
+ 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__); \
+ if (__len__ <= 0) { \
+ LOGE("sending message failed"); \
+ ret = PLAYER_ERROR_INVALID_OPERATION; \
+ } else \
+ ret = client_wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
+ muse_core_msg_json_factory_free(__sndMsg__); \
+ } while (0)
+
+/**
+* @brief Create and send message. Wait for server result.
+* @remarks Does NOT guarantee thread safe.
+* @param[in] api The enum of module API.
+* @param[in] player The handle of capi media player.
+* @param[out] retbuf The buffer of return message. Must be char pointer.Must free after use.
+* @param[out] ret The return value from server.
+* @param[in] param the name of param is key, must be local array/pointer variable.
+* @param[in] length The size of array.
+* @param[in] datum_size The size of a array's datum.
+* @param[in] tfd the tbm fd from tbm_bo_export_fd().
+*/
+#define player_msg_send_array_fd(api, player, retbuf, ret, param, length, datum_size, tfd) \
+do { \
+ char *__sndMsg__; \
+ int __len__; \
+ int __fd__; \
+ int __timeout__ = client_get_api_timeout(player, api); \
+ int *__value__ = (int *)param; \
+ 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_INT, #length, length, \
+ MUSE_TYPE_ARRAY, #param, \
+ datum_size == sizeof(int) ? length : \
+ length / sizeof(int) + (length % sizeof(int) ? 1 : 0), \
+ __value__, \
+ 0); \
+ __len__ = muse_core_ipc_send_fd_msg(__fd__, tfd, __sndMsg__); \
+ if (__len__ <= 0) { \
+ LOGE("sending message failed"); \
+ ret = PLAYER_ERROR_INVALID_OPERATION; \
+ } else \
+ ret = client_wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
+ muse_core_msg_json_factory_free(__sndMsg__); \
+} while (0)
+
+/**
* @brief Create and send message. Does not wait server result.
* @remarks Does NOT guarantee thread safe.
* @param[in] api The enum of module API.
} \
} while (0)
-
/**
* @brief Create and send message for callback. Does not wait server result.
* @remarks Does NOT guarantee thread safe.
#ifdef TIZEN_FEATURE_EVAS_RENDERER
#include <mm_evas_renderer.h>
#endif
-#define INVALID_SOCKET -1
+
+#define INVALID_DEFAULT_VALUE -1
typedef struct {
int int_data;
return ret;
}
- if (!fin_data || fin_data->fd <= INVALID_SOCKET) {
+ if (!fin_data || fin_data->fd <= INVALID_DEFAULT_VALUE) {
LOGE("invalid parameter, fd: %d", (fin_data) ? (fin_data->fd) : (-1));
goto EXIT;
}
msg_buff_s *buff = &cb_info->buff;
memset(buff->recvMsg, 0x00, sizeof(char)*buff->bufLen);
- recvLen = muse_core_ipc_recv_msg(cb_info->fd, buff->recvMsg);
+ recvLen = muse_core_ipc_recv_fd_msg(cb_info->fd, buff->recvMsg, &cb_info->tfd);
/* check the first msg */
if (buff->part_of_msg && buff->recvMsg[0] != '{')
unsigned int size = 0;
tbm_bo bo = NULL;
tbm_bo_handle thandle;
- tbm_key key = 0;
+ int key = INVALID_DEFAULT_VALUE;
bool ret_val = TRUE;
- player_msg_get3(recvMsg, width, INT, height, INT, size, INT, ret_val);
+ player_msg_get4(recvMsg, width, INT, height, INT, size, INT, key, INT, ret_val);
if (ret_val) {
- if (!player_msg_get(key, recvMsg)) {
- LOGE("There is no tbm_key value. %d", key);
+ if (cb_info->tfd < 0) {
+ LOGE("There is no valid tbm_fd");
goto EXIT;
}
- bo = tbm_bo_import(cb_info->bufmgr, key);
+ bo = tbm_bo_import_fd(cb_info->bufmgr, cb_info->tfd);
if (bo == NULL) {
LOGE("TBM get error : bo is NULL");
goto EXIT;
}
EXIT:
+ if (cb_info->tfd > INVALID_DEFAULT_VALUE)
+ close(cb_info->tfd);
+ cb_info->tfd = INVALID_DEFAULT_VALUE;
+
if (bo)
tbm_bo_unref(bo);
/* return buffer */
- if (key != 0) {
+ if (key > INVALID_DEFAULT_VALUE) {
LOGD("send msg to release buffer. key:%d", key);
player_msg_send1_no_return(MUSE_PLAYER_API_RETURN_BUFFER, cb_info->fd, INT, key);
}
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)) {
+ if (tmp && (tmp->key == key)) { /* need to check fd, bo num, etc */
LOGD("found tsurf_data of tbm_key %d", key);
/* need to check tsuf info to support DRC */
{
tbm_bo bo = NULL;
tbm_bo_handle thandle;
- tbm_key key = 0;
+ int key = INVALID_DEFAULT_VALUE;
player_audio_raw_data_s audio;
if (!player_msg_get(key, recvMsg)) {
- LOGE("failed to get value from msg.");
+ LOGE("failed to get key value from msg.");
return;
}
- bo = tbm_bo_import(cb_info->bufmgr, key);
+ if (cb_info->tfd < 0) {
+ LOGE("failed to get tbm_fd(key:%d)", key);
+ goto EXIT;
+ }
+
+ bo = tbm_bo_import_fd(cb_info->bufmgr, cb_info->tfd);
if (bo == NULL) {
- LOGE("TBM get error : bo is NULL, key:%d", key);
+ LOGE("TBM get error : bo is NULL, tbm_fd:%d(key:%d)", cb_info->tfd, key);
goto EXIT;
}
tbm_bo_unmap(bo);
EXIT:
+ if (cb_info->tfd > INVALID_DEFAULT_VALUE)
+ close(cb_info->tfd);
+ cb_info->tfd = INVALID_DEFAULT_VALUE;
+
if (bo)
tbm_bo_unref(bo);
/* return buffer */
- if (key != 0) {
+ if (key > INVALID_DEFAULT_VALUE) {
LOGD("send msg to release buffer. key:%d", key);
player_msg_send1_no_return(MUSE_PLAYER_API_RETURN_BUFFER, cb_info->fd, INT, key);
}
g_atomic_int_set(&cb_info->running, 1);
cb_info->fd = sockfd;
cb_info->thread = g_thread_new("callback_thread", client_cb_handler, (gpointer) cb_info);
+ cb_info->tfd = INVALID_DEFAULT_VALUE;
return cb_info;
}
int i;
g_return_if_fail(cb_info);
- if (cb_info->fd > INVALID_SOCKET)
+ if (cb_info->fd > INVALID_DEFAULT_VALUE)
muse_core_connection_close(cb_info->fd);
- if (cb_info->data_fd > INVALID_SOCKET)
+ if (cb_info->data_fd > INVALID_DEFAULT_VALUE)
muse_core_connection_close(cb_info->data_fd);
- cb_info->fd = cb_info->data_fd = INVALID_SOCKET;
+ cb_info->fd = cb_info->data_fd = INVALID_DEFAULT_VALUE;
g_thread_join(cb_info->thread);
g_thread_unref(cb_info->thread);
PLAYER_INSTANCE_CHECK(player);
int ret = PLAYER_ERROR_NONE;
- int sock_fd = INVALID_SOCKET;
+ int sock_fd = INVALID_DEFAULT_VALUE;
int pid = getpid();
muse_player_api_e api = MUSE_PLAYER_API_CREATE;
while (--retry_count) {
sock_fd = muse_core_client_new();
- if (sock_fd <= INVALID_SOCKET) {
+ if (sock_fd <= INVALID_DEFAULT_VALUE) {
LOGE("connection failure %d", errno);
ret = PLAYER_ERROR_INVALID_OPERATION;
retry = true;
muse_player_api_e api = MUSE_PLAYER_API_SET_MEMORY_BUFFER;
player_cli_s *pc = (player_cli_s *) player;
char *ret_buf = NULL;
- tbm_bo bo;
+ tbm_bo bo = NULL;
tbm_bo_handle thandle;
- tbm_key key;
+ tbm_fd tfd = INVALID_DEFAULT_VALUE;
if (SERVER_TBM_BO(pc)) {
LOGE("Already set the memory buffer. unprepare please");
memcpy(thandle.ptr, data, size);
tbm_bo_unmap(bo);
- key = tbm_bo_export(bo);
- if (key == 0) {
- LOGE("TBM get error : key is 0");
+ tfd = tbm_bo_export_fd(bo);
+ if (tfd < 0) {
+ LOGE("tbm_bo_export_fd err 0x%x", tfd);
ret = PLAYER_ERROR_INVALID_OPERATION;
goto EXIT;
}
- player_msg_send2(api, pc, ret_buf, ret, INT, key, INT, size);
+ player_msg_send1_fd(api, pc, ret_buf, ret, INT, size, tfd);
pc->push_media_stream = FALSE;
EXIT:
+ if (tfd > INVALID_DEFAULT_VALUE)
+ close(tfd);
+
tbm_bo_unref(bo);
if (ret == PLAYER_ERROR_NONE) {
int size = 0;
tbm_bo bo = NULL;
tbm_bo_handle thandle;
- tbm_key key = 0;
+ tbm_fd tfd = INVALID_DEFAULT_VALUE;
+ int key = INVALID_DEFAULT_VALUE;
void *jobj = NULL;
LOGD("ENTER");
if (muse_core_msg_json_object_get_value("size", jobj, &size, MUSE_TYPE_INT) && (size > 0)) {
LOGD("size : %d", size);
if (!muse_core_msg_json_object_get_value("key", jobj, &key, MUSE_TYPE_INT)) {
+ LOGE("failed to get key value");
ret = PLAYER_ERROR_INVALID_OPERATION;
goto EXIT;
}
- bo = tbm_bo_import(pc->cb_info->bufmgr, key);
+ tfd = pc->cb_info->tfd;
+ if (tfd < 0) {
+ LOGE("failed to get tbm fd value");
+ ret = PLAYER_ERROR_INVALID_OPERATION;
+ goto EXIT;
+ }
+
+ bo = tbm_bo_import_fd(pc->cb_info->bufmgr, tfd);
if (bo == NULL) {
LOGE("TBM get error : bo is NULL");
ret = PLAYER_ERROR_INVALID_OPERATION;
ret = PLAYER_ERROR_INVALID_OPERATION;
}
tbm_bo_unmap(bo);
+ *psize = size;
} else {
*palbum_art = NULL;
+ *psize = 0;
}
- *psize = size;
}
EXIT:
if (ret_buf)
g_free(ret_buf);
+ if (tfd > INVALID_DEFAULT_VALUE)
+ close(tfd);
+ pc->cb_info->tfd = INVALID_DEFAULT_VALUE;
+
if (bo)
tbm_bo_unref(bo);
/* return buffer */
- if (key != 0) {
+ if (key > INVALID_DEFAULT_VALUE) {
LOGD("send msg to release buffer. key:%d", key);
player_msg_send1_async(MUSE_PLAYER_API_RETURN_BUFFER, pc, INT, key);
}
#ifdef __UN_USED
tbm_bo bo = NULL;
tbm_bo_handle thandle;
+ tbm_fd tfd = INVALID_DEFAULT_VALUE;
#endif
char *buf;
media_format_h format;
memcpy(thandle.ptr, buf, push_media.size);
tbm_bo_unmap(bo);
- push_media.key = tbm_bo_export(bo);
- if (push_media.key == 0) {
- LOGE("TBM get error : key is 0");
+ tfd = tbm_bo_export_fd(bo);
+ if (tfd < 0) {
+ LOGE("tbm_bo_export_fd err 0x%x", tfd);
ret = PLAYER_ERROR_INVALID_OPERATION;
goto ERROR;
}
- player_msg_send_array(api, pc, ret_buf, ret, push_media_msg, msg_size, sizeof(char));
+ player_msg_send_array_fd(api, pc, ret_buf, ret, push_media_msg, msg_size, sizeof(char), tfd);
} else if (push_media.buf_type == PUSH_MEDIA_BUF_TYPE_MSG) {
buf_size = (int)push_media.size;
player_msg_send_array2(api, pc, ret_buf, ret, push_media_msg, msg_size, sizeof(char), buf, buf_size, sizeof(char));
#ifdef __UN_USED
ERROR:
+ if (tfd > INVALID_DEFAULT_VALUE)
+ close(tfd);
+
if (push_media.buf_type == PUSH_MEDIA_BUF_TYPE_TBM)
tbm_bo_unref(bo);
#endif