return NULL;
}
+static void _remove_all_ret_msg(callback_cb_info_s * cb_info)
+{
+ ret_msg_s *msg = cb_info->buff.retMsgHead;
+ ret_msg_s *prev = NULL;
+ while (msg) {
+ prev = msg;
+ msg = msg->next;
+ LOGI("Remove %s", prev->msg);
+ g_free(prev->msg);
+ prev->msg = NULL;
+ g_free(prev);
+ }
+}
+
static void _notify_disconnected(callback_cb_info_s * cb_info)
{
int code = PLAYER_ERROR_SERVICE_DISCONNECTED;
g_mutex_clear(&cb_info->seek_cb_mutex);
g_free(cb_info->buff.recvMsg);
+ _remove_all_ret_msg(cb_info);
if (cb_info->buff.part_of_msg)
g_free(cb_info->buff.part_of_msg);
g_free(cb_info);
g_mutex_lock(&cb_info->player_mutex);
msg = _get_ret_msg(api, cb_info);
- if (!buff->recved || !msg) {
- if (!g_cond_wait_until(&cb_info->player_cond[api], &cb_info->player_mutex, end_time)) {
- LOGW("api %d return msg does not received %dms", api, time_out);
- g_mutex_unlock(&cb_info->player_mutex);
- return PLAYER_ERROR_INVALID_OPERATION;
+ do {
+ if (!buff->recved || !msg) {
+ if (!g_cond_wait_until(&cb_info->player_cond[api], &cb_info->player_mutex, end_time)) {
+ LOGW("api %d return msg does not received %dms", api, time_out);
+ ret = PLAYER_ERROR_INVALID_OPERATION;
+ break;
+ }
}
- }
- if (!msg)
- msg = _get_ret_msg(api, cb_info);
- if (msg) {
- *ret_buf = msg->msg;
- g_free(msg);
- if (!player_msg_get(ret, *ret_buf))
- ret = PLAYER_ERROR_INVALID_OPERATION;
- } else {
- LOGE("api %d return msg is not exist", api);
- ret = PLAYER_ERROR_INVALID_OPERATION;
- }
- buff->recved--;
+ if (!msg)
+ msg = _get_ret_msg(api, cb_info);
+ if (msg) {
+ *ret_buf = msg->msg;
+ buff->recved--;
+ g_free(msg);
+ if (!player_msg_get(ret, *ret_buf))
+ ret = PLAYER_ERROR_INVALID_OPERATION;
+ } else {
+ LOGE("api %d is the spurious wakeup", api);
+ }
+ } while (!msg);
g_mutex_unlock(&cb_info->player_mutex);
-
return ret;
}