* @param[out] ret The return value from server.
*/
#define player_msg_send(api, player, retbuf, ret) \
- do{ \
+ do { \
char *__sndMsg__; \
int __len__; \
int __fd__; \
int __timeout__ = client_get_api_timeout(player, api); \
- if(CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
- else {ret = PLAYER_ERROR_INVALID_STATE;break;} \
+ if (CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
+ else {ret = PLAYER_ERROR_INVALID_STATE; break; } \
__sndMsg__ = muse_core_msg_json_factory_new(api, \
0); \
__len__ = muse_core_ipc_send_msg(__fd__, __sndMsg__); \
} else \
ret = client_wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
muse_core_msg_json_factory_free(__sndMsg__); \
- }while(0)
+ } while (0)
/**
* @brief Create and send message. Wait for server result.
* @param[in] param the name of param is key, must be local variable. never be pointer.
*/
#define player_msg_send1(api, player, retbuf, ret, type, param) \
- do{ \
+ do { \
char *__sndMsg__; \
int __len__; \
int __fd__; \
int __timeout__ = client_get_api_timeout(player, api); \
type __value__ = (type)param; \
- if(CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
- else {ret = PLAYER_ERROR_INVALID_STATE;break;} \
+ 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_##type, #param, __value__, \
0); \
} else \
ret = client_wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
muse_core_msg_json_factory_free(__sndMsg__); \
- }while(0)
+ } while (0)
/**
* @brief Create and send message. Wait for server result.
* @param[in] param# the name of param is key, must be local variable. never be pointer.
*/
#define player_msg_send2(api, player, retbuf, ret, type1, param1, type2, param2) \
- do{ \
+ do { \
char *__sndMsg__; \
int __len__; \
int __fd__; \
int __timeout__ = client_get_api_timeout(player, api); \
type1 __value1__ = (type1)param1; \
type2 __value2__ = (type2)param2; \
- if(CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
- else {ret = PLAYER_ERROR_INVALID_STATE;break;} \
+ 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__, \
MUSE_TYPE_##type2, #param2, __value2__, \
} else \
ret = client_wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
muse_core_msg_json_factory_free(__sndMsg__); \
- }while(0)
+ } while (0)
/**
* @brief Create and send message. Wait for server result.
* @param[in] param# the name of param is key, must be local variable. never be pointer.
*/
#define player_msg_send3(api, player, retbuf, ret, type1, param1, type2, param2, type3, param3) \
- do{ \
+ do { \
char *__sndMsg__; \
int __len__; \
int __fd__; \
type1 __value1__ = (type1)param1; \
type2 __value2__ = (type2)param2; \
type3 __value3__ = (type3)param3; \
- if(CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
- else {ret = PLAYER_ERROR_INVALID_STATE;break;} \
+ 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__, \
MUSE_TYPE_##type2, #param2, __value2__, \
} else \
ret = client_wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
muse_core_msg_json_factory_free(__sndMsg__); \
- }while(0)
+ } while (0)
/**
* @brief Create and send message. Wait for server result.
* @param[in] param# the name of param is key, must be local variable. never be pointer.
*/
#define player_msg_send4(api, player, retbuf, ret, type1, param1, type2, param2, type3, param3, type4, param4) \
- do{ \
+ do { \
char *__sndMsg__; \
int __len__; \
int __fd__; \
type2 __value2__ = (type2)param2; \
type3 __value3__ = (type3)param3; \
type4 __value4__ = (type4)param4; \
- if(CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
- else {ret = PLAYER_ERROR_INVALID_STATE;break;} \
+ 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__, \
MUSE_TYPE_##type2, #param2, __value2__, \
} else \
ret = client_wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
muse_core_msg_json_factory_free(__sndMsg__); \
- }while(0)
+ } while (0)
/**
* @brief Create and send message. Wait for server result.
* @param[in] param# the name of param is key, must be local variable. never be pointer.
*/
#define player_msg_send5(api, player, retbuf, ret, type1, param1, type2, param2, type3, param3, type4, param4, type5, param5) \
- do{ \
- char *__sndMsg__; \
- int __len__; \
- int __fd__; \
- int __timeout__ = client_get_api_timeout(player, api); \
- type1 __value1__ = (type1)param1; \
- type2 __value2__ = (type2)param2; \
- type3 __value3__ = (type3)param3; \
- type4 __value4__ = (type4)param4; \
- type5 __value5__ = (type5)param5; \
- 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__, \
- MUSE_TYPE_##type2, #param2, __value2__, \
- MUSE_TYPE_##type3, #param3, __value3__, \
- MUSE_TYPE_##type4, #param4, __value4__, \
- MUSE_TYPE_##type5, #param5, __value5__, \
- 0); \
- __len__ = muse_core_ipc_send_msg(__fd__, __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)
+ do { \
+ char *__sndMsg__; \
+ int __len__; \
+ int __fd__; \
+ int __timeout__ = client_get_api_timeout(player, api); \
+ type1 __value1__ = (type1)param1; \
+ type2 __value2__ = (type2)param2; \
+ type3 __value3__ = (type3)param3; \
+ type4 __value4__ = (type4)param4; \
+ type5 __value5__ = (type5)param5; \
+ 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__, \
+ MUSE_TYPE_##type2, #param2, __value2__, \
+ MUSE_TYPE_##type3, #param3, __value3__, \
+ MUSE_TYPE_##type4, #param4, __value4__, \
+ MUSE_TYPE_##type5, #param5, __value5__, \
+ 0); \
+ __len__ = muse_core_ipc_send_msg(__fd__, __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.
* @param[in] param# the name of param is key, must be local variable. never be pointer.
*/
#define player_msg_send6(api, player, retbuf, ret, type1, param1, type2, param2, type3, param3, type4, param4, type5, param5, type6, param6) \
- do{ \
+ do { \
char *__sndMsg__; \
int __len__; \
int __fd__; \
type4 __value4__ = (type4)param4; \
type5 __value5__ = (type5)param5; \
type6 __value6__ = (type6)param6; \
- if(CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
- else {ret = PLAYER_ERROR_INVALID_STATE;break;} \
+ 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__, \
MUSE_TYPE_##type2, #param2, __value2__, \
} else \
ret = client_wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
muse_core_msg_json_factory_free(__sndMsg__); \
- }while(0)
+ } while (0)
/**
* @brief Create and send message. Wait for server result.
* @param[in] datum_size The size of a array's datum.
*/
#define player_msg_send_array(api, player, retbuf, ret, param, length, datum_size) \
- do{ \
+ 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;} \
+ 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), \
+ datum_size == sizeof(int) ? length : \
+ length / sizeof(int) + (length % sizeof(int) ? 1 : 0), \
__value__, \
0); \
__len__ = muse_core_ipc_send_msg(__fd__, __sndMsg__); \
} else \
ret = client_wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
muse_core_msg_json_factory_free(__sndMsg__); \
- }while(0)
+ } while (0)
/**
* @brief Create and send message. Wait for server result.
* @param[in] datum_size# The size of a array's datum.
*/
#define player_msg_send_array2(api, player, retbuf, ret, param1, length1, datum_size1, param2, length2, datum_size2) \
- do{ \
+ do { \
char *__sndMsg__; \
int __len__; \
int __fd__; \
int __timeout__ = client_get_api_timeout(player, api); \
int *__value1__ = (int *)param1; \
int *__value2__ = (int *)param2; \
- if(CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
- else {ret = PLAYER_ERROR_INVALID_STATE;break;} \
+ 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, #length1, length1, \
MUSE_TYPE_ARRAY, #param1, \
- datum_size1 == sizeof(int)? length1 : \
- length1 / sizeof(int) + (length1 % sizeof(int)?1:0), \
+ datum_size1 == sizeof(int) ? length1 : \
+ length1 / sizeof(int) + (length1 % sizeof(int) ? 1 : 0), \
__value1__, \
MUSE_TYPE_INT, #length2, length2, \
MUSE_TYPE_ARRAY, #param2, \
- datum_size2 == sizeof(int)? length2 : \
- length2 / sizeof(int) + (length2 % sizeof(int)?1:0), \
+ datum_size2 == sizeof(int) ? length2 : \
+ length2 / sizeof(int) + (length2 % sizeof(int) ? 1 : 0), \
__value2__, \
0); \
__len__ = muse_core_ipc_send_msg(__fd__, __sndMsg__); \
} else \
ret = client_wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
muse_core_msg_json_factory_free(__sndMsg__); \
- }while(0)
+ } while (0)
/**
* @brief Create and send message. Wait for server result.
* @param[in] datum_size# The size of a array's datum.
*/
#define player_msg_send1_array2(api, player, retbuf, ret, type1, param1, param2, length2, datum_size2, param3, length3, datum_size3) \
- do{ \
- char *__sndMsg__; \
- int __len__; \
- int __fd__; \
- int __timeout__ = client_get_api_timeout(player, api); \
- type1 __value1__ = (type1)param1; \
- int *__value2__ = (int *)param2; \
- int *__value3__ = (int *)param3; \
- 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__, \
- MUSE_TYPE_INT, #length2, length2, \
- MUSE_TYPE_ARRAY, #param2, \
- datum_size2 == sizeof(int)? length2 : \
- length2 / sizeof(int) + (length2 % sizeof(int)?1:0), \
- __value2__, \
- MUSE_TYPE_INT, #length3, length3, \
- MUSE_TYPE_ARRAY, #param3, \
- datum_size3 == sizeof(int)? length3 : \
- length3 / sizeof(int) + (length3 % sizeof(int)?1:0), \
- __value3__, \
- 0); \
- __len__ = muse_core_ipc_send_msg(__fd__, __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)
+ do { \
+ char *__sndMsg__; \
+ int __len__; \
+ int __fd__; \
+ int __timeout__ = client_get_api_timeout(player, api); \
+ type1 __value1__ = (type1)param1; \
+ int *__value2__ = (int *)param2; \
+ int *__value3__ = (int *)param3; \
+ 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__, \
+ MUSE_TYPE_INT, #length2, length2, \
+ MUSE_TYPE_ARRAY, #param2, \
+ datum_size2 == sizeof(int) ? length2 : \
+ length2 / sizeof(int) + (length2 % sizeof(int) ? 1 : 0), \
+ __value2__, \
+ MUSE_TYPE_INT, #length3, length3, \
+ MUSE_TYPE_ARRAY, #param3, \
+ datum_size3 == sizeof(int) ? length3 : \
+ length3 / sizeof(int) + (length3 % sizeof(int) ? 1 : 0), \
+ __value3__, \
+ 0); \
+ __len__ = muse_core_ipc_send_msg(__fd__, __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.
* @param[in] datum_size# The size of a array's datum.
*/
#define player_msg_send2_array(api, player, retbuf, ret, type1, param1, type2, param2, param_arr, length, datum_size) \
- do{ \
+ do { \
char *__sndMsg__; \
int __len__; \
int __fd__; \
int __timeout__ = client_get_api_timeout(player, api); \
type1 __value1__ = (type1)param1; \
type2 __value2__ = (type2)param2; \
- int *__value_arr__ = (int *)param_arr; \
- if(CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
- else {ret = PLAYER_ERROR_INVALID_STATE;break;} \
+ int *__value_arr__ = (int *)param_arr; \
+ 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__, \
MUSE_TYPE_##type2, #param2, __value2__, \
- MUSE_TYPE_INT, #length, length, \
+ MUSE_TYPE_INT, #length, length, \
MUSE_TYPE_ARRAY, #param_arr, \
- datum_size == sizeof(int)? length : \
- length / sizeof(int) + (length % sizeof(int)?1:0), \
+ datum_size == sizeof(int) ? length : \
+ length / sizeof(int) + (length % sizeof(int) ? 1 : 0), \
__value_arr__, \
0); \
__len__ = muse_core_ipc_send_msg(__fd__, __sndMsg__); \
} else \
ret = client_wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
muse_core_msg_json_factory_free(__sndMsg__); \
- }while(0)
+ } while (0)
/**
* @brief Create and send message. Wait for server result.
* @param[in] datum_size# The size of a array's datum.
*/
#define player_msg_send3_array2(api, player, retbuf, ret, type1, param1, type2, param2, type3, param3, param4, length4, datum_size4, param5, length5, datum_size5) \
- do{ \
- char *__sndMsg__; \
- int __len__; \
- int __fd__; \
- int __timeout__ = client_get_api_timeout(player, api); \
- type1 __value1__ = (type1)param1; \
- type2 __value2__ = (type2)param2; \
- type3 __value3__ = (type3)param3; \
- int *__value4__ = (int *)param4; \
- int *__value5__ = (int *)param5; \
- 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__, \
- MUSE_TYPE_##type2, #param2, __value2__, \
- MUSE_TYPE_##type3, #param3, __value3__, \
- MUSE_TYPE_INT, #length4, length4, \
- MUSE_TYPE_ARRAY, #param4, \
- datum_size4 == sizeof(int)? length4 : \
- length4 / sizeof(int) + (length4 % sizeof(int)?1:0), \
- __value4__, \
- MUSE_TYPE_INT, #length5, length5, \
- MUSE_TYPE_ARRAY, #param5, \
- datum_size5 == sizeof(int)? length5 : \
- length5 / sizeof(int) + (length5 % sizeof(int)?1:0), \
- __value5__, \
- 0); \
- __len__ = muse_core_ipc_send_msg(__fd__, __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)
+ do { \
+ char *__sndMsg__; \
+ int __len__; \
+ int __fd__; \
+ int __timeout__ = client_get_api_timeout(player, api); \
+ type1 __value1__ = (type1)param1; \
+ type2 __value2__ = (type2)param2; \
+ type3 __value3__ = (type3)param3; \
+ int *__value4__ = (int *)param4; \
+ int *__value5__ = (int *)param5; \
+ 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__, \
+ MUSE_TYPE_##type2, #param2, __value2__, \
+ MUSE_TYPE_##type3, #param3, __value3__, \
+ MUSE_TYPE_INT, #length4, length4, \
+ MUSE_TYPE_ARRAY, #param4, \
+ datum_size4 == sizeof(int) ? length4 : \
+ length4 / sizeof(int) + (length4 % sizeof(int) ? 1 : 0), \
+ __value4__, \
+ MUSE_TYPE_INT, #length5, length5, \
+ MUSE_TYPE_ARRAY, #param5, \
+ datum_size5 == sizeof(int) ? length5 : \
+ length5 / sizeof(int) + (length5 % sizeof(int) ? 1 : 0), \
+ __value5__, \
+ 0); \
+ __len__ = muse_core_ipc_send_msg(__fd__, __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.
* @param[in] param the name of param is key, must be local variable. never be pointer.
*/
#define player_msg_send1_async(api, player, type, param) \
- do{ \
+ do { \
char *__sndMsg__; \
int __len__; \
int __fd__; \
type __value__ = (type)param; \
- if(CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
- else {ret = PLAYER_ERROR_INVALID_STATE;break;} \
+ 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_##type, #param, __value__, \
0); \
LOGE("sending message failed"); \
return PLAYER_ERROR_INVALID_OPERATION; \
} \
- }while(0)
+ } while (0)
/**
* @brief Create and send message. Does not wait server result.
* @param[in] param the name of param is key, must be local variable. never be pointer.
*/
#define player_msg_send1_no_return(api, fd, type, param) \
- do{ \
+ do { \
char *__sndMsg__; \
int __len__; \
type __value__ = (type)param; \
if (__len__ <= 0) { \
LOGE("sending message failed"); \
} \
- }while(0)
+ } while (0)
/**
* @brief Create and send message. Does not wait server result.
* @param[in] param the name of param is key, must be local variable. never be pointer.
*/
#define player_msg_create_handle(api, fd, type1, param1, type2, param2) \
- do{ \
+ do { \
char *__sndMsg__; \
int __len__; \
type1 __value1__ = (type1)param1; \
LOGE("sending message failed"); \
return PLAYER_ERROR_INVALID_OPERATION; \
} \
- }while(0)
+ } while (0)
/**
* @param[in] set 1 is set the user callback, 0 is unset the user callback.
*/
#define player_msg_set_callback(api, player, ret, event_type, set) \
- do{ \
+ do { \
char *__sndMsg__; \
int __len__; \
int __fd__; \
int __value1__ = (int)event_type; \
int __value2__ = (int)set; \
- if(CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
- else {ret = PLAYER_ERROR_INVALID_STATE;break;} \
+ 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, #event_type, __value1__, \
MUSE_TYPE_INT, #set, __value2__, \
LOGE("sending message failed"); \
ret = PLAYER_ERROR_INVALID_OPERATION; \
} \
- }while(0)
+ } while (0)
/**
* @brief Get value from Message.
void *__jobj__ = muse_core_msg_json_object_new(buf, NULL, NULL); \
if (!muse_core_msg_json_object_get_value(#param1, __jobj__, ¶m1, MUSE_TYPE_##type1)) { \
LOGE("failed to get value(%s)", #param1); \
- ret=FALSE; \
+ ret = FALSE; \
} \
if (ret && !muse_core_msg_json_object_get_value(#param2, __jobj__, ¶m2, MUSE_TYPE_##type2)) { \
LOGE("failed to get %s value", #param2); \
- ret=FALSE; \
+ ret = FALSE; \
} \
if (ret && !muse_core_msg_json_object_get_value(#arr_param, __jobj__, arr_param, MUSE_TYPE_ANY)) { \
LOGE("failed to get %s value", #arr_param); \
- ret=FALSE; \
+ ret = FALSE; \
} \
muse_core_msg_json_object_free(__jobj__); \
- } while(0)
+ } while (0)
/**
* @brief Get value from Message.
} \
muse_core_msg_json_object_free(__jobj__); \
} \
- } while(0)
+ } while (0)
#endif /* __TIZEN_MEDIA_PLAYER_MSG_PRIVATE_H__ */
int _player_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
{
int ret = MEDIA_PACKET_FINALIZE;
- tbm_surface_h tsurf = NULL;
muse_player_api_e api = MUSE_PLAYER_API_MEDIA_PACKET_FINALIZE_CB;
_media_pkt_fin_data *fin_data = (_media_pkt_fin_data *) user_data;
intptr_t packet;
return ret;
}
- ret = media_packet_get_tbm_surface(pkt, &tsurf);
- if (ret != MEDIA_PACKET_ERROR_NONE) {
- LOGE("media_packet_get_tbm_surface failed 0x%x", ret);
- goto EXIT;
- }
-
- if (tsurf) {
- tbm_surface_destroy(tsurf);
- tsurf = NULL;
- }
-
if (!fin_data || fin_data->fd <= INVALID_SOCKET) {
LOGE("invalid parameter, fd: %d", (fin_data) ? (fin_data->fd) : (-1));
goto EXIT;
}
-#if 1 /* FIXME : after applying media_packet_pool, no need to check packet_list manully. */
+ /* Do not destroy tbm surface here to reuse during playback *
+ * they will be destroyed at player_unprepare() or player_destroy(). *
+ * ref: __player_remove_tsurf_list() */
+
packet = fin_data->remote_pkt;
snd_msg = muse_core_msg_json_factory_new(api, MUSE_TYPE_POINTER, "packet", packet, 0);
snd_len = muse_core_ipc_send_msg(fin_data->fd, snd_msg);
if (snd_len > 0) {
/* player handle is available. remove packet from the list */
if (fin_data->cb_info->packet_list) {
- g_mutex_lock(&fin_data->cb_info->packet_list_mutex);
+ g_mutex_lock(&fin_data->cb_info->data_mutex);
if (g_list_find(fin_data->cb_info->packet_list, pkt)) {
fin_data->cb_info->packet_list = g_list_remove(fin_data->cb_info->packet_list, pkt);
} else {
LOGW("there is no packet(%p) in exported list.", pkt);
}
- g_mutex_unlock(&fin_data->cb_info->packet_list_mutex);
+ g_mutex_unlock(&fin_data->cb_info->data_mutex);
} else {
LOGW("there is no packet list.", pkt);
}
} else {
LOGE("fail to send msg.");
}
-#else
- player_msg_send1_no_return(api, fin_data->cb_info->fd, POINTER, packet);
-#endif
EXIT:
if (fin_data) {
g_mutex_unlock(&cb_info->seek_cb_mutex);
}
+static void __player_remove_tsurf_list(player_cli_s * pc)
+{
+ GList *l = NULL;
+
+ g_mutex_lock(&pc->cb_info->data_mutex);
+ if (pc->cb_info->tsurf_list) {
+ LOGD("total num of tsurf list = %d", g_list_length(pc->cb_info->tsurf_list));
+
+ for (l = g_list_first(pc->cb_info->tsurf_list); l; l = g_list_next(l)) {
+ player_tsurf_info_t* tmp = (player_tsurf_info_t *)l->data;
+
+ LOGD("%p will be removed", tmp);
+ if (tmp) {
+ if (tmp->tsurf) {
+ tbm_surface_destroy(tmp->tsurf);
+ tmp->tsurf = NULL;
+ }
+ g_free(tmp);
+ }
+ }
+ g_list_free(pc->cb_info->tsurf_list);
+ pc->cb_info->tsurf_list = NULL;
+ }
+ g_mutex_unlock(&pc->cb_info->data_mutex);
+ return;
+}
+
+static player_tsurf_info_t* __player_get_tsurf_from_list(callback_cb_info_s * cb_info, tbm_key key)
+{
+ 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)) {
+ LOGD("found tsurf_data of tbm_key %d", key);
+ g_mutex_unlock(&cb_info->data_mutex);
+ return tmp;
+ }
+ }
+ g_mutex_unlock(&cb_info->data_mutex);
+ LOGD("there is no tsurf_data for tbm_key:%d", key);
+ return NULL;
+}
+
static void __media_packet_video_frame_cb_handler(callback_cb_info_s * cb_info, char *recvMsg)
{
tbm_bo bo[4] = { NULL, };
char *surface_info = (char *)&sinfo;
media_packet_h pkt = NULL;
tbm_surface_h tsurf = NULL;
+ player_tsurf_info_t *tsurf_data = NULL;
int bo_num = 0;
media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
bool make_pkt_fmt = false;
- int ret;
- _media_pkt_fin_data *fin_data;
+ int ret = MEDIA_FORMAT_ERROR_NONE;
+ _media_pkt_fin_data *fin_data = NULL;
intptr_t packet;
uint64_t pts = 0;
int i = 0;
}
}
- tsurf = tbm_surface_internal_create_with_bos(&sinfo, bo, bo_num);
- if (tsurf) {
- /* check media packet format */
- if (cb_info->pkt_fmt) {
- int pkt_fmt_width = 0;
- int pkt_fmt_height = 0;
- media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
-
- media_format_get_video_info(cb_info->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
- if (pkt_fmt_mimetype != mimetype || pkt_fmt_width != sinfo.width || pkt_fmt_height != sinfo.height) {
- LOGW("different format. current 0x%x, %dx%d, new 0x%x, %dx%d", pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height, mimetype, sinfo.width, sinfo.height);
- media_format_unref(cb_info->pkt_fmt);
- cb_info->pkt_fmt = NULL;
- make_pkt_fmt = true;
- }
- } else {
- make_pkt_fmt = true;
- }
- /* create packet format */
- if (make_pkt_fmt) {
- LOGI("make new pkt_fmt - mimetype 0x%x, %dx%d", mimetype, sinfo.width, sinfo.height);
- ret = media_format_create(&cb_info->pkt_fmt);
- if (ret == MEDIA_FORMAT_ERROR_NONE) {
- ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
- ret |= media_format_set_video_width(cb_info->pkt_fmt, sinfo.width);
- ret |= media_format_set_video_height(cb_info->pkt_fmt, sinfo.height);
- LOGI("media_format_set_video_mime,width,height ret : 0x%x", ret);
- } else {
- LOGE("media_format_create failed");
- }
+ tsurf_data = __player_get_tsurf_from_list(cb_info, key[0]);
+ if (!tsurf_data) {
+ tsurf_data = g_new(player_tsurf_info_t, 1);
+ if (!tsurf_data) {
+ LOGE("failed to alloc tsurf info");
+ goto ERROR;
}
- fin_data = g_new(_media_pkt_fin_data, 1);
- fin_data->remote_pkt = packet;
- fin_data->cb_info = cb_info;
- fin_data->fd = cb_info->fd;
- ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt, tsurf, (media_packet_finalize_cb) _player_media_packet_finalize, (void *)fin_data, &pkt);
- if (ret != MEDIA_PACKET_ERROR_NONE) {
- LOGE("media_packet_create_from_tbm_surface failed");
- tbm_surface_destroy(tsurf);
- tsurf = NULL;
+ tsurf = tbm_surface_internal_create_with_bos(&sinfo, bo, bo_num);
+ if (!tsurf) {
+ LOGE("failed to create tbm surface");
+ g_free(tsurf_data);
+ goto ERROR;
+ }
+ tsurf_data->key = key[0];
+ tsurf_data->tsurf = tsurf;
+ g_mutex_lock(&cb_info->data_mutex);
+ cb_info->tsurf_list = g_list_append(cb_info->tsurf_list, tsurf_data);
+ LOGD("key %d is added to the pool", key[0]);
+ if (cb_info->video_frame_pool_size < g_list_length(cb_info->tsurf_list)) {
+ LOGE("need to check the pool size: %d < %d", cb_info->video_frame_pool_size, g_list_length(cb_info->tsurf_list));
+ }
+ g_mutex_unlock(&cb_info->data_mutex);
+ } else {
+ if (tsurf_data->tsurf) {
+ tsurf = tsurf_data->tsurf;
+ } else {
+ LOGE("tsurf_data->tsurf is null (never enter here)");
+ goto ERROR;
}
-
- /* keep the media packet to avoid mem leak. */
- g_mutex_lock(&cb_info->packet_list_mutex);
- cb_info->packet_list = g_list_append(cb_info->packet_list, pkt);
- g_mutex_unlock(&cb_info->packet_list_mutex);
}
- if (pkt) {
- if (pts != 0) {
- ret = media_packet_set_pts(pkt, (uint64_t) pts);
- if (ret != MEDIA_PACKET_ERROR_NONE)
- LOGE("media_packet_set_pts failed");
+ /* check media packet format */
+ if (cb_info->pkt_fmt) {
+ int pkt_fmt_width = 0;
+ int pkt_fmt_height = 0;
+ media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
+
+ media_format_get_video_info(cb_info->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
+ if (pkt_fmt_mimetype != mimetype || pkt_fmt_width != sinfo.width || pkt_fmt_height != sinfo.height) {
+ LOGW("different format. current 0x%x, %dx%d, new 0x%x, %dx%d", pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height, mimetype, sinfo.width, sinfo.height);
+ media_format_unref(cb_info->pkt_fmt);
+ cb_info->pkt_fmt = NULL;
+ make_pkt_fmt = true;
}
- if (cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME]) {
- /* call media packet callback */
- ((player_media_packet_video_decoded_cb) cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME]) (pkt, cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME]);
+ } else {
+ make_pkt_fmt = true;
+ }
+ /* create packet format */
+ if (make_pkt_fmt) {
+ LOGI("make new pkt_fmt - mimetype 0x%x, %dx%d", mimetype, sinfo.width, sinfo.height);
+ ret = media_format_create(&cb_info->pkt_fmt);
+ if (ret == MEDIA_FORMAT_ERROR_NONE) {
+ ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
+ ret |= media_format_set_video_width(cb_info->pkt_fmt, sinfo.width);
+ ret |= media_format_set_video_height(cb_info->pkt_fmt, sinfo.height);
+ LOGI("media_format_set_video_mime,width,height ret : 0x%x", ret);
} else {
- LOGE("_video_decoded_cb is not set");
- media_packet_destroy(pkt);
+ LOGE("media_format_create failed");
}
}
+ fin_data = g_new(_media_pkt_fin_data, 1);
+ if (!fin_data) {
+ LOGE("failed to alloc fin_data");
+ goto ERROR;
+ }
+ fin_data->remote_pkt = packet;
+ fin_data->cb_info = cb_info;
+ fin_data->fd = cb_info->fd;
+ ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt, tsurf, (media_packet_finalize_cb) _player_media_packet_finalize, (void *)fin_data, &pkt);
+ if (ret != MEDIA_PACKET_ERROR_NONE || !pkt) {
+ LOGE("media_packet_create_from_tbm_surface failed %d %p", ret, pkt);
+ goto ERROR;
+ }
+
+ /* keep the media packet to avoid mem leak. */
+ g_mutex_lock(&cb_info->data_mutex);
+ cb_info->packet_list = g_list_append(cb_info->packet_list, pkt);
+ g_mutex_unlock(&cb_info->data_mutex);
+
+ if (pts != 0) {
+ ret = media_packet_set_pts(pkt, (uint64_t) pts);
+ if (ret != MEDIA_PACKET_ERROR_NONE)
+ LOGE("media_packet_set_pts failed");
+ }
+ if (cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME]) {
+ /* call media packet callback */
+ ((player_media_packet_video_decoded_cb) cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME]) (pkt, cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME]);
+ } else {
+ LOGE("_video_decoded_cb is not set");
+ media_packet_destroy(pkt);
+ }
+
+ for (i = 0; i < bo_num; i++) {
+ if (bo[i])
+ tbm_bo_unref(bo[i]);
+ }
+ return;
+
+ERROR:
+ if (pkt)
+ media_packet_destroy(pkt);
+
+ if (fin_data)
+ g_free(fin_data);
+
for (i = 0; i < bo_num; i++) {
if (bo[i])
tbm_bo_unref(bo[i]);
}
+
+ player_msg_send1_no_return(MUSE_PLAYER_API_MEDIA_PACKET_FINALIZE_CB, cb_info->fd, POINTER, packet);
+ return;
}
static void __audio_frame_cb_handler(callback_cb_info_s * cb_info, char *recvMsg)
for (i = 0; i < MUSE_PLAYER_API_MAX; i++)
g_cond_init(&cb_info->player_cond[i]);
- g_mutex_init(&cb_info->packet_list_mutex);
+ g_mutex_init(&cb_info->data_mutex);
g_mutex_init(&cb_info->seek_cb_mutex);
buff = &cb_info->buff;
for (i = 0; i < MUSE_PLAYER_API_MAX; i++)
g_cond_clear(&cb_info->player_cond[i]);
- g_mutex_clear(&cb_info->packet_list_mutex);
+ g_mutex_clear(&cb_info->data_mutex);
g_mutex_clear(&cb_info->seek_cb_mutex);
g_free(cb_info->buff.recvMsg);
}
#endif
if (pc->cb_info && pc->cb_info->packet_list) {
- g_mutex_lock(&pc->cb_info->packet_list_mutex);
+ g_mutex_lock(&pc->cb_info->data_mutex);
LOGW("num of remained packets : %d !!", g_list_length(pc->cb_info->packet_list));
/* each media packet have to destroyed in application. */
g_list_free(pc->cb_info->packet_list);
pc->cb_info->packet_list = NULL;
- g_mutex_unlock(&pc->cb_info->packet_list_mutex);
+ g_mutex_unlock(&pc->cb_info->data_mutex);
}
if (player_unset_evas_object_cb(player) != MM_ERROR_NONE)
LOGW("fail to unset evas object callback");
if (CALLBACK_INFO(pc)) {
+ __player_remove_tsurf_list(pc);
_player_event_queue_destroy(CALLBACK_INFO(pc));
tbm_bufmgr_deinit(TBM_BUFMGR(pc));
_player_deinit_memory_buffer(pc);
}
+ pc->cb_info->video_frame_pool_size = 0;
+ __player_remove_tsurf_list(pc);
+
g_free(ret_buf);
return ret;
}
return PLAYER_ERROR_INVALID_PARAMETER;
} else
return PLAYER_ERROR_INVALID_PARAMETER;
- }
- else { /* PLAYER_DISPLAY_TYPE_NONE */
+ } else { /* PLAYER_DISPLAY_TYPE_NONE */
LOGI("Wayland surface type is NONE");
wl_win.type = type;
wl_win.wl_window_x = 0;