PLAYER_CHECK_CONDITION(arg <= max,PLAYER_ERROR_INVALID_PARAMETER,"PLAYER_ERROR_INVALID_PARAMETER") \
PLAYER_CHECK_CONDITION(arg >= min,PLAYER_ERROR_INVALID_PARAMETER,"PLAYER_ERROR_INVALID_PARAMETER")
+/* user_cb_lock */
+#define LEGACY_PLAYER_USER_CB_LOCK(x_handle,type) \
+ do { \
+ if (_check_enabled_user_cb_lock(type)) \
+ g_mutex_lock(&((player_s*)x_handle)->user_cb_lock[type]); \
+ } while (0)
+
+#define LEGACY_PLAYER_USER_CB_UNLOCK(x_handle,type) \
+ do { \
+ if (_check_enabled_user_cb_lock(type)) \
+ g_mutex_unlock(&((player_s*)x_handle)->user_cb_lock[type]); \
+ } while (0)
+
+
#ifdef TIZEN_TTRACE
#include <ttrace.h>
#define PLAYER_TRACE_BEGIN(NAME) traceBegin(TTRACE_TAG_VIDEO, NAME)
MMHandleType mm_handle;
const void* user_cb[MUSE_PLAYER_EVENT_TYPE_NUM];
void* user_data[MUSE_PLAYER_EVENT_TYPE_NUM];
+ GMutex user_cb_lock[MUSE_PLAYER_EVENT_TYPE_NUM];
void* wl_display;
void* display_handle;
player_display_type_e display_type;
int legacy_player_get_timeout_for_muse(player_h player, int *timeout);
int legacy_player_get_num_of_video_out_buffers(player_h player, int *num, int *extra_num);
int legacy_player_set_file_buffering_path(player_h player, const char *file_path);
+bool _check_enabled_user_cb_lock(int event_id);
#ifdef __cplusplus
}
player_s *handle = (player_s *)user_data;
MMPlayerVideoStreamDataType *video_stream = (MMPlayerVideoStreamDataType *)stream;
+ LEGACY_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME);
+
if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME]) {
/* media packet and zero-copy */
media_packet_h pkt = NULL;
unsigned char *ptr = video_stream->data[0];
unsigned char *ptr2 = video_stream->data[1];
- if (!ptr)
+ if (!ptr) {
+ LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME);
return TRUE;
- if (!ptr2 && video_stream->format == MM_PIXEL_FORMAT_NV12T)
+ }
+ if (!ptr2 && video_stream->format == MM_PIXEL_FORMAT_NV12T) {
+ LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME);
return TRUE;
-
+ }
tsurf = tbm_surface_create(video_stream->width, video_stream->height, bo_format);
if (tsurf) {
/* map surface to set data */
if (tbm_surface_map(tsurf, TBM_SURF_OPTION_READ | TBM_SURF_OPTION_WRITE, &tsuri)) {
LOGE("tbm_surface_map failed");
+ LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME);
return TRUE;
}
}
}
}
+
+ LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME);
return TRUE;
}
return 0;
}
+ LEGACY_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_PD);
+
if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PD])
((player_pd_message_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PD])(type, handle->user_data[MUSE_PLAYER_EVENT_TYPE_PD]);
+ LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PD);
+
return 0;
}
}
}
+bool _check_enabled_user_cb_lock(int type)
+{
+ if ((type == MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME) ||
+ (type == MUSE_PLAYER_EVENT_TYPE_PD) ||
+ (type == MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO) ||
+ (type == MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO)) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
/*
* Public Implementation
*/
handle = NULL;
return __player_convert_error_code(ret, (char *)__FUNCTION__);
} else {
+ muse_player_event_e type = MUSE_PLAYER_EVENT_TYPE_PREPARE;
+
*player = (player_h)handle;
handle->state = PLAYER_STATE_IDLE;
handle->display_type = PLAYER_DISPLAY_TYPE_NONE;
handle->is_stopped = FALSE;
handle->is_display_visible = TRUE;
handle->is_media_stream = FALSE;
+
+ for (type = MUSE_PLAYER_EVENT_TYPE_PREPARE; type < MUSE_PLAYER_EVENT_TYPE_NUM; type++) {
+ if (_check_enabled_user_cb_lock(type)) {
+ g_mutex_init(&handle->user_cb_lock[type]);
+ }
+ }
#ifdef USE_ECORE_FUNCTIONS
handle->ecore_jobs = g_hash_table_new_full(g_str_hash, g_str_equal, __job_key_to_remove, __job_value_to_destroy);
#else
LOGE("[%s] PLAYER_ERROR_INVALID_OPERATION(0x%08x)", __FUNCTION__, PLAYER_ERROR_INVALID_OPERATION);
return PLAYER_ERROR_INVALID_OPERATION;
} else {
+ muse_player_event_e type = MUSE_PLAYER_EVENT_TYPE_PREPARE;
+
handle->state = PLAYER_STATE_NONE;
+
+ for (type = MUSE_PLAYER_EVENT_TYPE_PREPARE; type < MUSE_PLAYER_EVENT_TYPE_NUM; type++) {
+ if (_check_enabled_user_cb_lock(type)) {
+ g_mutex_clear(&handle->user_cb_lock[type]);
+ }
+ }
+
#ifndef USE_ECORE_FUNCTIONS
if (handle->message_queue) {
g_queue_free(handle->message_queue);
PLAYER_INSTANCE_CHECK(player);
player_s *handle = (player_s *)player;
+ LEGACY_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_PD);
handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PD] = NULL;
handle->user_data[MUSE_PLAYER_EVENT_TYPE_PD] = NULL;
+ LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PD);
LOGI("[%s] Event type : %d ", __FUNCTION__, MUSE_PLAYER_EVENT_TYPE_PD);
int ret = mm_player_set_pd_message_callback(handle->mm_handle, NULL, NULL);
PLAYER_INSTANCE_CHECK(player);
player_s *handle = (player_s *)player;
+ LEGACY_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME);
+
handle->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME] = NULL;
handle->user_data[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME] = NULL;
+ LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME);
+
LOGI("Event type : %d ", MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME);
int ret = mm_player_set_video_stream_callback(handle->mm_handle, NULL, NULL);
handle->user_cb[event_type] = callback; \
handle->user_data[event_type] = user_data; \
LOGI("[%s] Event type : %d ", __FUNCTION__, event_type); \
-} while (0) \
+} while (0)
bool __audio_stream_callback_ex(MMPlayerAudioStreamDataType *stream, void *user_data)
{
LOGE("[%s] event type %d, status %d, bytes %llu", __FUNCTION__, event_type, status, bytes);
+ LEGACY_PLAYER_USER_CB_LOCK(handle, event_type);
+
if (handle->user_cb[event_type]) {
((player_media_stream_buffer_status_cb_ex)handle->user_cb[event_type])(status, bytes, handle->user_data[event_type]);
} else {
LOGE("[%s][type:%d] buffer status cb was not set.", __FUNCTION__, type);
+ LEGACY_PLAYER_USER_CB_UNLOCK(handle, event_type);
return FALSE;
}
+ LEGACY_PLAYER_USER_CB_UNLOCK(handle, event_type);
+
return TRUE;
}
return PLAYER_ERROR_INVALID_PARAMETER;
}
- ret = mm_player_set_media_stream_buffer_status_callback(handle->mm_handle, type, (mm_player_media_stream_buffer_status_callback)__media_stream_buffer_status_callback_ex, (void *)handle);
-
- if (ret != MM_ERROR_NONE)
- return __player_convert_error_code(ret, (char *)__FUNCTION__);
-
if (type == PLAYER_STREAM_TYPE_VIDEO)
event_type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO;
else
event_type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO;
- LOGI("[%s] Event type : %d ", __FUNCTION__, type);
+
+ ret = mm_player_set_media_stream_buffer_status_callback(handle->mm_handle, type, (mm_player_media_stream_buffer_status_callback)__media_stream_buffer_status_callback_ex, (void *)handle);
+
+ if (ret != MM_ERROR_NONE) {
+ LEGACY_PLAYER_USER_CB_UNLOCK(handle, event_type);
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+ }
+
+ LEGACY_PLAYER_USER_CB_LOCK(handle, event_type);
handle->user_cb[event_type] = callback;
handle->user_data[event_type] = user_data;
+ LEGACY_PLAYER_USER_CB_UNLOCK(handle, event_type);
+
+ LOGI("[%s] Event type : %d ", __FUNCTION__, type);
return PLAYER_ERROR_NONE;
}
else
return PLAYER_ERROR_INVALID_PARAMETER;
+ LEGACY_PLAYER_USER_CB_LOCK(handle, event_type);
+
handle->user_cb[event_type] = NULL;
handle->user_data[event_type] = NULL;
+ LEGACY_PLAYER_USER_CB_UNLOCK(handle, event_type);
+
LOGI("[%s] Event type : %d ", __FUNCTION__, type);
ret = mm_player_set_media_stream_buffer_status_callback(handle->mm_handle, type, NULL, NULL);
+
if (ret != MM_ERROR_NONE)
return __player_convert_error_code(ret, (char *)__FUNCTION__);
else
return __player_convert_error_code(ret, (char *)__FUNCTION__);
else
return PLAYER_ERROR_NONE;
-}
\ No newline at end of file
+}