From b7692aa499e1f63db21fd6680c3300ed68018d2c Mon Sep 17 00:00:00 2001 From: Eunhae Choi Date: Fri, 7 Oct 2016 19:34:01 +0900 Subject: [PATCH] [v0.6.2] wait until last drained cb call when doing gapless Change-Id: I40fd0419cbd418a40519c49623120100018d0e52 --- packaging/libmm-player.spec | 2 +- src/mm_player_priv.c | 54 +++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/packaging/libmm-player.spec b/packaging/libmm-player.spec index a459893..d8ce176 100644 --- a/packaging/libmm-player.spec +++ b/packaging/libmm-player.spec @@ -1,6 +1,6 @@ Name: libmm-player Summary: Multimedia Framework Player Library -Version: 0.6.1 +Version: 0.6.2 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 diff --git a/src/mm_player_priv.c b/src/mm_player_priv.c index 7288ee4..459be8e 100644 --- a/src/mm_player_priv.c +++ b/src/mm_player_priv.c @@ -2221,7 +2221,8 @@ __mmplayer_gst_selector_event_probe(GstPad * pad, GstPadProbeInfo * info, gpoint if (GST_EVENT_TYPE(event) != GST_EVENT_STREAM_START && GST_EVENT_TYPE(event) != GST_EVENT_FLUSH_STOP && - GST_EVENT_TYPE(event) != GST_EVENT_SEGMENT) + GST_EVENT_TYPE(event) != GST_EVENT_SEGMENT && + GST_EVENT_TYPE(event) != GST_EVENT_EOS) return ret; caps = gst_pad_query_caps(pad, NULL); @@ -2255,6 +2256,15 @@ __mmplayer_gst_selector_event_probe(GstPad * pad, GstPadProbeInfo * info, gpoint LOGD("stream type is %d", stream_type); switch (GST_EVENT_TYPE(event)) { + case GST_EVENT_EOS: + { + /* in case of gapless, drop eos event not to send it to sink */ + if (player->gapless.reconfigure) { + LOGD("%s:%s EOS received but will be drop", GST_DEBUG_PAD_NAME(pad)); + ret = GST_PAD_PROBE_DROP; + } + break; + } case GST_EVENT_STREAM_START: { gint64 stop_running_time = 0; @@ -11821,6 +11831,11 @@ static void __mmplayer_gst_decode_drained(GstElement *bin, gpointer data) { mm_player_t* player = (mm_player_t*)data; + GstIterator *iter = NULL; + GValue item = { 0, }; + GstPad *pad = NULL; + gboolean done = FALSE; + gboolean is_all_drained = TRUE; MMPLAYER_FENTER(); MMPLAYER_RETURN_IF_FAIL(player); @@ -11837,7 +11852,8 @@ __mmplayer_gst_decode_drained(GstElement *bin, gpointer data) return; } - if (!__mmplayer_verify_next_play_path(player)) { + if (!player->gapless.reconfigure && /* If it is already checked, skip verify. */ + !__mmplayer_verify_next_play_path(player)) { LOGD("decoding is finished."); __mmplayer_reset_gapless_state(player); MMPLAYER_CMD_UNLOCK(player); @@ -11845,6 +11861,40 @@ __mmplayer_gst_decode_drained(GstElement *bin, gpointer data) } player->gapless.reconfigure = TRUE; + + /* check decodebin src pads whether they received EOS or not */ + iter = gst_element_iterate_src_pads(player->pipeline->mainbin[MMPLAYER_M_AUTOPLUG].gst); + + while (!done) { + switch (gst_iterator_next (iter, &item)) { + case GST_ITERATOR_OK: + pad = g_value_get_object (&item); + if (!GST_PAD_IS_EOS(pad)) { + LOGW("[%s:%s] not received EOS yet.", GST_DEBUG_PAD_NAME(pad)); + is_all_drained = FALSE; + break; + } + g_value_reset (&item); + break; + case GST_ITERATOR_RESYNC: + gst_iterator_resync (iter); + break; + case GST_ITERATOR_ERROR: + case GST_ITERATOR_DONE: + done = TRUE; + break; + } + } + g_value_unset (&item); + gst_iterator_free (iter); + + if (!is_all_drained) { + LOGD("Wait util the all pads get EOS."); + MMPLAYER_CMD_UNLOCK(player); + MMPLAYER_FLEAVE(); + return; + } + player->gapless.update_segment[MM_PLAYER_TRACK_TYPE_AUDIO] = FALSE; player->gapless.update_segment[MM_PLAYER_TRACK_TYPE_VIDEO] = FALSE; -- 2.7.4