#define MMPLAYER_VIDEO_BO_LOCK(x_player) g_mutex_lock(&((mm_player_t *)x_player)->video_bo_mutex)
#define MMPLAYER_VIDEO_BO_UNLOCK(x_player) g_mutex_unlock(&((mm_player_t *)x_player)->video_bo_mutex)
#define MMPLAYER_VIDEO_BO_WAIT(x_player) g_cond_wait(&((mm_player_t *)x_player)->video_bo_cond, &((mm_player_t *)x_player)->video_bo_mutex)
-#define MMPLAYER_VIDEO_BO_WAIT_UNTIL(x_player, end_time) g_cond_wait_until(&((mm_player_t *)x_player)->video_bo_cond, &((mm_player_t *)x_player)->video_bo_mutex, end_time);
+#define MMPLAYER_VIDEO_BO_WAIT_UNTIL(x_player, end_time) g_cond_wait_until(&((mm_player_t *)x_player)->video_bo_cond, &((mm_player_t *)x_player)->video_bo_mutex, end_time)
#define MMPLAYER_VIDEO_BO_SIGNAL(x_player) g_cond_signal(&((mm_player_t *)x_player)->video_bo_cond);
/* media stream lock */
#define MMPLAYER_MEDIA_STREAM_CALLBACK_LOCK(x_player) g_mutex_lock(&((mm_player_t *)x_player)->media_stream_cb_lock)
#define MMPLAYER_MEDIA_STREAM_CALLBACK_UNLOCK(x_player) g_mutex_unlock(&((mm_player_t *)x_player)->media_stream_cb_lock)
+/* subtitle info */
+#define MMPLAYER_SUBTITLE_INFO_LOCK(x_player) g_mutex_lock(&((mm_player_t *)x_player)->subtitle_info_mutex)
+#define MMPLAYER_SUBTITLE_INFO_UNLOCK(x_player) g_mutex_unlock(&((mm_player_t *)x_player)->subtitle_info_mutex)
+#define MMPLAYER_SUBTITLE_INFO_WAIT(x_player) g_cond_wait(&((mm_player_t *)x_player)->subtitle_info_cond, &((mm_player_t *)x_player)->subtitle_info_mutex)
+#define MMPLAYER_SUBTITLE_INFO_WAIT_UNTIL(x_player, end_time) g_cond_wait_until(&((mm_player_t *)x_player)->subtitle_info_cond, &((mm_player_t *)x_player)->subtitle_info_mutex, end_time)
+#define MMPLAYER_SUBTITLE_INFO_SIGNAL(x_player) g_cond_signal(&((mm_player_t *)x_player)->subtitle_info_cond);
+
#if 0
#define MMPLAYER_FENTER(); LOGD("<ENTER>");
#define MMPLAYER_FLEAVE(); LOGD("<LEAVE>");
if (lang_list != NULL) {
count = g_list_length((GList *)g_value_get_pointer(lang_list));
if (count) {
+ MMPLAYER_SUBTITLE_INFO_LOCK(player);
player->subtitle_language_list = (GList *)g_value_get_pointer(lang_list);
mm_attrs_set_int_by_name(attrs, "content_text_track_num", (gint)count);
if (mmf_attrs_commit(attrs))
LOGE("failed to commit.\n");
LOGD("Total subtitle tracks = %d \n", count);
- }
- while (count) {
- temp = g_list_nth_data(player->subtitle_language_list, count - 1);
- if (temp)
- LOGD("value of lang_key is %s and lang_code is %s",
- temp->language_key, temp->language_code);
- count--;
+
+ while (count) {
+ temp = g_list_nth_data(player->subtitle_language_list, count - 1);
+ if (temp)
+ LOGD("value of lang_key is %s and lang_code is %s",
+ temp->language_key, temp->language_code);
+ count--;
+ }
+ MMPLAYER_SUBTITLE_INFO_SIGNAL(player);
+ MMPLAYER_SUBTITLE_INFO_UNLOCK(player);
}
}
}
LOGD("subtitle file path is [%s].\n", subtitle_uri);
+ MMPLAYER_SUBTITLE_INFO_LOCK(player);
+ player->subtitle_language_list = NULL;
+ MMPLAYER_SUBTITLE_INFO_UNLOCK(player);
+
/* create the subtitle source */
subsrc = gst_element_factory_make("filesrc", "subtitle_source");
if (!subsrc) {
player->no_more_pad = FALSE;
player->num_dynamic_pad = 0;
player->demux_pad_index = 0;
- player->subtitle_language_list = NULL;
player->use_deinterleave = FALSE;
player->max_audio_channels = 0;
player->video_share_api_delta = 0;
player->video_share_clock_delta = 0;
player->video_hub_download_mode = 0;
+
+ MMPLAYER_SUBTITLE_INFO_LOCK(player);
+ player->subtitle_language_list = NULL;
+ MMPLAYER_SUBTITLE_INFO_UNLOCK(player);
+
__mmplayer_reset_gapless_state(player);
if (player->streamer) {
/* create media stream callback mutex */
g_mutex_init(&player->media_stream_cb_lock);
+ /* create subtitle info lock and cond */
+ g_mutex_init(&player->subtitle_info_mutex);
+ g_cond_init(&player->subtitle_info_cond);
+
player->streaming_type = STREAMING_SERVICE_NONE;
/* give default value of audio effect setting */
return MM_ERROR_PLAYER_INTERNAL;
}
- if (player->is_external_subtitle_present && player->subtitle_language_list) {
- g_list_free(player->subtitle_language_list);
- player->subtitle_language_list = NULL;
- }
+ /* release subtitle info lock and cond */
+ g_mutex_clear(&player->subtitle_info_mutex);
+ g_cond_clear(&player->subtitle_info_cond);
__mmplayer_release_dump_list(player->dump_list);
base_time = gst_element_get_base_time(GST_ELEMENT_CAST(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst));
start_time = gst_element_get_start_time(GST_ELEMENT_CAST(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst));
- LOGD("base_time=%" GST_TIME_FORMAT " start_time=%" GST_TIME_FORMAT " curr_time=%" GST_TIME_FORMAT,
- GST_TIME_ARGS(base_time), GST_TIME_ARGS(start_time), GST_TIME_ARGS(curr_time));
+ LOGD("state: %d, base_time=%" GST_TIME_FORMAT " start_time=%" GST_TIME_FORMAT " curr_time=%" GST_TIME_FORMAT,
+ current_state, GST_TIME_ARGS(base_time), GST_TIME_ARGS(start_time), GST_TIME_ARGS(curr_time));
if (current_state > GST_STATE_READY) {
// sync state with current pipeline
}
//gst_pad_set_blocked_async(src-srcpad, TRUE)
+ MMPLAYER_SUBTITLE_INFO_LOCK(player);
+ player->subtitle_language_list = NULL;
+ MMPLAYER_SUBTITLE_INFO_UNLOCK(player);
ret = gst_element_set_state(textbin[MMPLAYER_T_BIN].gst, GST_STATE_READY);
if (ret != GST_STATE_CHANGE_SUCCESS) {
MMPLAYER_BUS_MSG_THREAD_SIGNAL(player);
player->is_external_subtitle_added_now = TRUE;
+
+ MMPLAYER_SUBTITLE_INFO_LOCK(player);
+ if (!player->subtitle_language_list) {
+ gint64 timeout = g_get_monotonic_time() + G_TIME_SPAN_SECOND; /* wait 1 sec */
+ if (!MMPLAYER_SUBTITLE_INFO_WAIT_UNTIL(player, timeout))
+ LOGW("subtitle language list is not updated yet");
+ }
+ MMPLAYER_SUBTITLE_INFO_UNLOCK(player);
}
MMPLAYER_FLEAVE();
MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
MMPLAYER_FENTER();
+ MMPLAYER_SUBTITLE_INFO_LOCK(player);
if (type == MM_PLAYER_TRACK_TYPE_TEXT && player->subtitle_language_list) {
GstElement *subparse = NULL;
_mmplayer_sync_subtitle_pipeline(player);
- } else
+ } else {
ret = _mmplayer_change_track_language(hplayer, type, index);
+ }
EXIT:
+ MMPLAYER_SUBTITLE_INFO_UNLOCK(player);
MMPLAYER_FLEAVE();
return ret;
}
MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
MMPLAYER_FENTER();
+ MMPLAYER_SUBTITLE_INFO_LOCK(player);
if (!player->pipeline || !player->pipeline->mainbin[MMPLAYER_M_T_SUBMUX_EXTERNAL].gst) {
ret = MM_ERROR_PLAYER_NOT_INITIALIZED;
goto EXIT;
}
EXIT:
+ MMPLAYER_SUBTITLE_INFO_UNLOCK(player);
MMPLAYER_FLEAVE();
return ret;
}
MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
MMPLAYER_FENTER();
+ MMPLAYER_SUBTITLE_INFO_LOCK(player);
if (!player->pipeline || !player->pipeline->mainbin[MMPLAYER_M_T_SUBMUX_EXTERNAL].gst) {
ret = MM_ERROR_PLAYER_NOT_INITIALIZED;
goto EXIT;
}
EXIT:
+ MMPLAYER_SUBTITLE_INFO_UNLOCK(player);
MMPLAYER_FLEAVE();
return ret;
}
MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
MMPLAYER_FENTER();
+ MMPLAYER_SUBTITLE_INFO_LOCK(player);
+
if (type >= MM_PLAYER_TRACK_TYPE_MAX) {
ret = MM_ERROR_INVALID_ARGUMENT;
LOGD("Not a proper type [type:%d] \n", type);
}
EXIT:
+ MMPLAYER_SUBTITLE_INFO_UNLOCK(player);
MMPLAYER_FLEAVE();
return ret;
}
mm_player_t* player = (mm_player_t*) hplayer;
MMPLAYER_FENTER();
+ MMPLAYER_SUBTITLE_INFO_LOCK(player);
+
if (type == MM_PLAYER_TRACK_TYPE_TEXT && player->subtitle_language_list) {
int language_code_size = 3;/*Size of ISO-639-1*/
MMPlayerLangStruct *language_list = NULL;
}
EXIT:
+ MMPLAYER_SUBTITLE_INFO_UNLOCK(player);
MMPLAYER_FLEAVE();
return ret;
}
MMPLAYER_FENTER();
int index = -1;
+ MMPLAYER_SUBTITLE_INFO_LOCK(player);
if (player->subtitle_language_list) {
int total_track_count = 0;
LOGE("foreach callback returned error");
EXIT:
+ MMPLAYER_SUBTITLE_INFO_UNLOCK(player);
MMPLAYER_FLEAVE();
return ret;