/* util */
static gboolean __mmplayer_verify_gapless_play_path(mmplayer_t *player);
-static void __mmplayer_check_pipeline(mmplayer_t *player);
+static void __mmplayer_check_pipeline_reconfigure_state(mmplayer_t *player);
static gboolean __mmplayer_deactivate_selector(mmplayer_t *player, mmplayer_track_type_e type);
static void __mmplayer_deactivate_old_path(mmplayer_t *player);
static int __mmplayer_gst_create_plain_text_elements(mmplayer_t *player);
MMPLAYER_FLEAVE();
}
+void _mmplayer_set_reconfigure_state(mmplayer_t *player, gboolean state)
+{
+ LOGI("set pipeline reconfigure state %d", state);
+ MMPLAYER_RECONFIGURE_LOCK(player);
+ player->gapless.reconfigure = state;
+ if (!state) /* wake up the waiting job */
+ MMPLAYER_RECONFIGURE_SIGNAL(player);
+ MMPLAYER_RECONFIGURE_UNLOCK(player);
+}
+
static gpointer
__mmplayer_gapless_play_thread(gpointer data)
{
LOGD("reconfigure pipeline for gapless play.");
if (player->gapless_play_thread_exit) {
- if (player->gapless.reconfigure) {
- player->gapless.reconfigure = false;
- MMPLAYER_PLAYBACK_UNLOCK(player);
- }
+ _mmplayer_set_reconfigure_state(player, FALSE);
LOGD("exiting gapless play thread");
break;
}
__mmplayer_create_text_sink_path(player, text_selector);
EXIT:
- if (player->gapless.reconfigure) {
- player->gapless.reconfigure = FALSE;
- MMPLAYER_PLAYBACK_UNLOCK(player);
- }
-
+ _mmplayer_set_reconfigure_state(player, FALSE);
MMPLAYER_FLEAVE();
}
player->subtitle_language_list = NULL;
MMPLAYER_SUBTITLE_INFO_UNLOCK(player);
+ MMPLAYER_RECONFIGURE_LOCK(player);
__mmplayer_reset_gapless_state(player);
+ MMPLAYER_RECONFIGURE_UNLOCK(player);
if (player->streamer) {
_mm_player_streaming_initialize(player->streamer, FALSE);
/* release attributes */
_mmplayer_deconstruct_attribute(handle);
+ if (player->uri_info.uri_list) {
+ GList *uri_list = player->uri_info.uri_list;
+ for (; uri_list; uri_list = g_list_next(uri_list)) {
+ gchar *uri = uri_list->data;
+ MMPLAYER_FREEIF(uri);
+ }
+ g_list_free(player->uri_info.uri_list);
+ player->uri_info.uri_list = NULL;
+ }
+
/* release lock */
g_mutex_clear(&player->fsink_lock);
return MM_ERROR_NONE;
}
-static void
-__mmplayer_check_pipeline(mmplayer_t *player)
+static void __mmplayer_check_pipeline_reconfigure_state(mmplayer_t *player)
{
GstState element_state = GST_STATE_VOID_PENDING;
GstState element_pending_state = GST_STATE_VOID_PENDING;
- gint timeout = 0;
- int ret = MM_ERROR_NONE;
+ GstStateChangeReturn result = GST_STATE_CHANGE_FAILURE;
+ gint timeout = MMPLAYER_STATE_CHANGE_TIMEOUT(player);
+
+ MMPLAYER_RETURN_IF_FAIL(player && player->pipeline);
- if (!player->gapless.reconfigure)
+ MMPLAYER_RECONFIGURE_LOCK(player);
+ if (!player->gapless.reconfigure) {
+ MMPLAYER_RECONFIGURE_UNLOCK(player);
return;
+ }
- LOGW("pipeline is under construction.");
+ LOGI("reconfigure is under process");
+ MMPLAYER_RECONFIGURE_WAIT(player);
+ MMPLAYER_RECONFIGURE_UNLOCK(player);
+ LOGI("reconfigure is completed.");
- MMPLAYER_PLAYBACK_LOCK(player);
- MMPLAYER_PLAYBACK_UNLOCK(player);
+ result = gst_element_get_state(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst,
+ &element_state, &element_pending_state, timeout * GST_SECOND);
+ if (result == GST_STATE_CHANGE_FAILURE)
+ LOGW("failed to get pipeline state in %d sec", timeout);
- timeout = MMPLAYER_STATE_CHANGE_TIMEOUT(player);
-
- /* wait for state transition */
- ret = gst_element_get_state(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, &element_state, &element_pending_state, timeout * GST_SECOND);
- if (ret == GST_STATE_CHANGE_FAILURE)
- LOGE("failed to change pipeline state within %d sec", timeout);
+ return;
}
/* NOTE : it should be able to call 'stop' anytime*/
/* check current state */
MMPLAYER_CHECK_STATE(player, MMPLAYER_COMMAND_STOP);
- /* check pipline building state */
- __mmplayer_check_pipeline(player);
+ /* need to wait till the rebuilding pipeline is completed */
+ __mmplayer_check_pipeline_reconfigure_state(player);
+ MMPLAYER_RECONFIGURE_LOCK(player);
__mmplayer_reset_gapless_state(player);
+ MMPLAYER_RECONFIGURE_UNLOCK(player);
/* NOTE : application should not wait for EOS after calling STOP */
_mmplayer_cancel_eos_timer(player);
/* check current state */
MMPLAYER_CHECK_STATE(player, MMPLAYER_COMMAND_PAUSE);
- /* check pipline building state */
- __mmplayer_check_pipeline(player);
+ /* check pipline reconfigure state */
+ __mmplayer_check_pipeline_reconfigure_state(player);
switch (MMPLAYER_CURRENT_STATE(player)) {
case MM_PLAYER_STATE_READY:
MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
- /* check pipline building state */
- __mmplayer_check_pipeline(player);
+ /* check pipline reconfigure state */
+ __mmplayer_check_pipeline_reconfigure_state(player);
ret = _mmplayer_gst_set_position(player, position, FALSE);
player->streamer = NULL;
}
- MMPLAYER_PLAYBACK_LOCK(player);
MMPLAYER_GAPLESS_PLAY_THREAD_SIGNAL(player);
-
MMPLAYER_FLEAVE();
return;
return;
}
- if (!player->gapless.reconfigure && /* If it is already checked, skip verify. */
- !__mmplayer_verify_gapless_play_path(player)) {
+ if (!__mmplayer_verify_gapless_play_path(player)) {
LOGD("decoding is finished.");
- __mmplayer_reset_gapless_state(player);
MMPLAYER_CMD_UNLOCK(player);
return;
}
- player->gapless.reconfigure = TRUE;
+ _mmplayer_set_reconfigure_state(player, TRUE);
+ MMPLAYER_CMD_UNLOCK(player);
/* check decodebin src pads whether they received EOS or not */
iter = gst_element_iterate_src_pads(player->pipeline->mainbin[MMPLAYER_M_AUTOPLUG].gst);
if (!is_all_drained) {
LOGD("Wait util the all pads get EOS.");
- MMPLAYER_CMD_UNLOCK(player);
MMPLAYER_FLEAVE();
return;
}
/* deactivate pipeline except sinkbins to set up the new pipeline of next uri*/
MMPLAYER_POST_MSG(player, MM_MESSAGE_GAPLESS_CONSTRUCTION, NULL); /* post message for gapless */
__mmplayer_deactivate_old_path(player);
- MMPLAYER_CMD_UNLOCK(player);
MMPLAYER_FLEAVE();
}
}
/* clean the uri list except original uri */
- if (player->uri_info.uri_list) {
+ if (player->uri_info.uri_list && g_list_length(player->uri_info.uri_list) > 1) {
original_uri = g_list_nth_data(player->uri_info.uri_list, 0);
-
if (!original_uri)
LOGW("failed to get original uri info");
GList *uri_list = player->uri_info.uri_list;
for (; uri_list; uri_list = g_list_next(uri_list)) {
gchar *uri = uri_list->data;
- MMPLAYER_FREEIF(uri);
+ if (original_uri != uri)
+ MMPLAYER_FREEIF(uri);
}
- g_list_free(player->uri_info.uri_list);
- player->uri_info.uri_list = NULL;
}
/* clear the audio stream buffer list */