} \
} while (0)
-#define __RELEASEIF_MESSAGE_THREAD(thread_id) \
- do { \
- if (thread_id) { \
- pthread_join(thread_id, NULL); \
- thread_id = 0; \
- LOGI("message thread released\n"); \
- } \
- } while (0)
-
-#define __GET_MESSAGE(handle) \
- do { \
- if (handle && handle->message_queue) { \
- g_mutex_lock(&handle->message_queue_lock); \
- if (g_queue_is_empty(handle->message_queue)) { \
- g_cond_wait(&handle->message_queue_cond, &handle->message_queue_lock); \
- } \
- handle->current_message = (int)(intptr_t)g_queue_pop_head(handle->message_queue); \
- g_mutex_unlock(&handle->message_queue_lock); \
- LOGI("Retrieved message [%d] from queue", handle->current_message); \
- } else { \
- LOGI("Failed to retrieve message from queue"); \
- handle->current_message = PLAYER_MESSAGE_NONE; \
- } \
- } while (0)
-
-#define __ADD_MESSAGE(handle, message) \
- do { \
- if (handle && handle->message_queue) { \
- g_mutex_lock(&handle->message_queue_lock); \
- if (message == PLAYER_MESSAGE_LOOP_EXIT) \
- g_queue_clear(handle->message_queue); \
- g_queue_push_tail(handle->message_queue, (gpointer)message); \
- g_cond_signal(&handle->message_queue_cond); \
- g_mutex_unlock(&handle->message_queue_lock); \
- LOGI("Adding message [%d] to queue", message); \
- } else { \
- LOGI("Failed to add message [%d] to queue", message); \
- } \
- } while (0)
-
/*
* Internal Implementation
*/
return PLAYER_ERROR_NONE;
}
-static void __message_cb_loop(void *data)
-{
- bool running = true;
- legacy_player_t *handle = (legacy_player_t *)data;
- if (!handle) {
- LOGE("null handle in __message_cb_loop");
- return;
- }
- do {
- __GET_MESSAGE(handle);
- switch (handle->current_message) {
- case PLAYER_MESSAGE_NONE:
- {
- LOGW("PLAYER_MESSAGE_NONE");
- running = false;
- }
- break;
- case PLAYER_MESSAGE_PREPARED:
- {
- LOGW("PLAYER_MESSAGE_PREPARED");
-
- LEGACY_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE);
- if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) {
- __player_update_state(handle, PLAYER_INTERNAL_STATE_READY);
- ((player_prepared_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE])(handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE]);
- handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL;
- handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL;
- } else {
- LOGE("null handle in PLAYER_MESSAGE_PREPARED");
- }
- LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE);
- }
- break;
- case PLAYER_MESSAGE_ERROR:
- {
- LOGW("PLAYER_MESSAGE_ERROR");
- if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_ERROR])
- ((player_error_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_ERROR])(handle->error_code, handle->user_data[MUSE_PLAYER_EVENT_TYPE_ERROR]);
- else
- LOGE("null handle in PLAYER_MESSAGE_ERROR");
- }
- break;
- case PLAYER_MESSAGE_SEEK_DONE:
- {
- LOGW("PLAYER_MESSAGE_SEEK_DONE");
- if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK]) {
- ((player_seek_completed_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK])(handle->user_data[MUSE_PLAYER_EVENT_TYPE_SEEK]);
- handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK] = NULL;
- handle->user_data[MUSE_PLAYER_EVENT_TYPE_SEEK] = NULL;
- } else {
- LOGE("null handle in PLAYER_MESSAGE_SEEK_DONE");
- }
- }
- break;
- case PLAYER_MESSAGE_EOS:
- {
- LOGW("PLAYER_MESSAGE_EOS");
- if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_COMPLETE])
- ((player_completed_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_COMPLETE])(handle->user_data[MUSE_PLAYER_EVENT_TYPE_COMPLETE]);
- else
- LOGE("null handle in PLAYER_MESSAGE_EOS");
- }
- break;
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
- case PLAYER_MESSAGE_GAPLESS_CONSTRUCTION:
- {
- LOGW("PLAYER_MESSAGE_GAPLESS_CONSTRUCTION");
- if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER])
- ((player_retrieve_buffer_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER])(handle->user_data[MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER]);
- else
- LOGE("null handle in PLAYER_MESSAGE_GAPLESS_CONSTRUCTION");
- }
- break;
-#endif
- case PLAYER_MESSAGE_LOOP_EXIT:
- {
- LOGW("PLAYER_MESSAGE_LOOP_EXIT");
- running = false;
- }
- break;
- case PLAYER_MESSAGE_MAX:
- {
- LOGW("PLAYER_MESSAGE_MAX");
- running = false;
- }
- break;
- default:
- break;
- }
- } while (running);
- return;
-}
-
static player_state_e __convert_player_state(mmplayer_state_e state)
{
if (state == MM_PLAYER_STATE_NONE)
if (msg->state.previous == MM_PLAYER_STATE_READY && msg->state.current == MM_PLAYER_STATE_PAUSED) {
LEGACY_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE);
if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) {
- /* asyc && prepared cb has been set */
- LOGI("Prepared! [current state : %d]", handle->state);
+ /* async && prepared cb has been set */
+ LOGD("Prepared! [current state : %d]", handle->state);
PLAYER_TRACE_ASYNC_END("MM:PLAYER:PREPARE_ASYNC", *(int *)handle);
- __ADD_MESSAGE(handle, PLAYER_MESSAGE_PREPARED);
+
+ __player_update_state(handle, PLAYER_INTERNAL_STATE_READY);
+ ((legacy_player_prepared_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE])(handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE]);
+
+ handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL;
+ handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL;
}
LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE);
}
LOGI("Ready to streaming information (BOS) [current state : %d]", handle->state);
break;
case MM_MESSAGE_END_OF_STREAM: /* 0x105 */
- if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_COMPLETE])
- __ADD_MESSAGE(handle, PLAYER_MESSAGE_EOS);
+ if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_COMPLETE]) {
+ LOGD("Playback is completed.");
+ ((player_completed_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_COMPLETE])(handle->user_data[MUSE_PLAYER_EVENT_TYPE_COMPLETE]);
+ }
break;
#ifdef TIZEN_FEATURE_EVAS_RENDERER
case MM_MESSAGE_GAPLESS_CONSTRUCTION: /* 0x105 */
if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER])
- __ADD_MESSAGE(handle, PLAYER_MESSAGE_GAPLESS_CONSTRUCTION);
+ ((player_retrieve_buffer_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER])(handle->user_data[MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER]);
break;
#endif
case MM_MESSAGE_BUFFERING: /* 0x103 */
}
}
if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK]) {
- __ADD_MESSAGE(handle, PLAYER_MESSAGE_SEEK_DONE);
+ LOGD("Seek is completed");
+ ((player_seek_completed_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK])(handle->user_data[MUSE_PLAYER_EVENT_TYPE_SEEK]);
+ handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK] = NULL;
+ handle->user_data[MUSE_PLAYER_EVENT_TYPE_SEEK] = NULL;
}
break;
case MM_MESSAGE_PLAY_POSITION:
if (err_code != PLAYER_ERROR_NONE && handle->user_cb[MUSE_PLAYER_EVENT_TYPE_ERROR]) {
handle->error_code = err_code;
- __ADD_MESSAGE(handle, PLAYER_MESSAGE_ERROR);
+ LOGE("ERROR is occurred 0x%X", err_code);
+ ((player_error_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_ERROR])(err_code, handle->user_data[MUSE_PLAYER_EVENT_TYPE_ERROR]);
}
LPLAYER_FLEAVE();
g_mutex_init(&handle->user_cb_lock[type]);
}
- handle->message_queue = g_queue_new();
- g_mutex_init(&handle->message_queue_lock);
- g_cond_init(&handle->message_queue_cond);
- ret = pthread_create(&handle->message_thread, NULL, (void *)__message_cb_loop, (void *)handle);
- if (ret != 0) {
- LOGE("Failed to create message thread 0x%X", ret);
- return PLAYER_ERROR_OUT_OF_MEMORY;
- }
-
LOGI("new handle : %p", *player);
PLAYER_TRACE_END();
return PLAYER_ERROR_NONE;
handle->is_shutdown = true;
- __ADD_MESSAGE(handle, PLAYER_MESSAGE_LOOP_EXIT);
-
LEGACY_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE);
if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) {
handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL;
mm_player_abort_pause(handle->mm_handle);
__RELEASEIF_PREPARE_THREAD(handle->prepare_async_thread);
- __RELEASEIF_MESSAGE_THREAD(handle->message_thread);
ret = mm_player_destroy(handle->mm_handle);
if (ret != MM_ERROR_NONE) {
g_mutex_clear(&handle->user_cb_lock[type]);
}
- if (handle->message_queue) {
- g_queue_free(handle->message_queue);
- handle->message_queue = NULL;
- }
-
- g_cond_broadcast(&handle->message_queue_cond);
- g_mutex_clear(&handle->message_queue_lock);
- g_cond_clear(&handle->message_queue_cond);
-
g_free(handle);
handle = NULL;
return NULL;
}
-int legacy_player_prepare_async(legacy_player_h player, player_prepared_cb callback, void *user_data)
+int legacy_player_prepare_async(legacy_player_h player, legacy_player_prepared_cb callback, void *user_data)
{
legacy_player_t *handle = (legacy_player_t *)player;
int ret = MM_ERROR_NONE;
PLAYER_NULL_ARG_CHECK(num);
PLAYER_NULL_ARG_CHECK(extra_num);
- ret = mm_player_get_num_of_video_out_buffers(handle->mm_handle, num, extra_num);
+ ret = mm_player_get_attribute(handle->mm_handle, NULL, MM_PLAYER_VIDEO_BUFFER_TOTAL_SIZE, num,
+ MM_PLAYER_VIDEO_BUFFER_EXTRA_SIZE, extra_num, (char *)NULL);
if (ret != MM_ERROR_NONE)
return __player_convert_error_code(ret, (char *)__FUNCTION__);