[0.6.249] Post INTERRUPT_STARTED message before _mmplayer_unrealize
[platform/core/multimedia/libmm-player.git] / src / mm_player_priv.c
index c90a9e0..c25a6fc 100644 (file)
@@ -802,10 +802,14 @@ _mmplayer_bus_watcher_remove(MMHandleType hplayer)
                __mmplayer_remove_g_source_from_context(player->context.thread_default, player->bus_watcher);
                MMPLAYER_BUS_WATCHER_LOCK(player);
                end_time = g_get_monotonic_time () + 2 * G_TIME_SPAN_SECOND;
-               while (player->bus_watcher > 0)
-                       MMPLAYER_BUS_WATCHER_WAIT_UNTIL(player, end_time);
+               while (player->bus_watcher > 0) {
+                       if (!MMPLAYER_BUS_WATCHER_WAIT_UNTIL(player, end_time)) {
+                               LOGW("MMPLAYER_BUS_WATCHER_WAIT_UNTIL() timeout has passed - bus_watcher (%d)",
+                                               player->bus_watcher);
+                               break;
+                       }
+               }
                MMPLAYER_BUS_WATCHER_UNLOCK(player);
-
                g_mutex_clear(&player->bus_watcher_mutex);
                g_cond_clear(&player->bus_watcher_cond);
        }
@@ -3009,7 +3013,7 @@ __mmplayer_gst_make_audio_extract_sink(mmplayer_t *player, GList **bucket)
                                MM_PLAYER_SIGNAL_TYPE_AUTOPLUG, "no-more-pads", G_CALLBACK(__mmplayer_gst_audio_deinterleave_no_more_pads), (gpointer)player);
                player->no_more_pad = FALSE;
        } else {
-       /* 4-2. create fakesink to extract interlevaed pcm */
+       /* 4-2. create fakesink to extract interleaved pcm */
                LOGD("add audio fakesink for interleaved audio");
                MMPLAYER_CREATE_ELEMENT(audiobin, extract_sink_id, "fakesink", "fakeaudiosink", *bucket, player);
                if (!(player->audio_extract_opt & MM_PLAYER_AUDIO_EXTRACT_NO_SYNC_WITH_CLOCK))
@@ -4615,6 +4619,8 @@ __resource_release_cb(mm_resource_manager_h rm, mm_resource_manager_res_h res,
 
        player->interrupted_by_resource = TRUE;
 
+       MMPLAYER_POST_MSG(player, MM_MESSAGE_INTERRUPT_STARTED, NULL);
+
        /* get last play position */
        if (_mmplayer_gst_get_position(player, &pos) == MM_ERROR_NONE) {
                msg.union_type = MM_MSG_UNION_TIME;
@@ -4715,8 +4721,8 @@ _mmplayer_create_player(MMHandleType handle)
 
        ret = _mmplayer_initialize_video_capture(player);
        if (ret != MM_ERROR_NONE) {
-               LOGE("failed to initialize video capture");
-               goto ERROR;
+               LOGW("video capture is not supported");
+               /* do not handle as error for headless profile */
        }
 
        /* initialize resource manager */
@@ -5670,11 +5676,24 @@ _mmplayer_abort_pause(MMHandleType hplayer)
                                                player->pipeline->mainbin,
                                                MM_ERROR_PLAYER_NOT_INITIALIZED);
 
-       LOGD("set the pipeline state to READY");
+       if (player->pipeline->videobin && player->pipeline->videobin[MMPLAYER_V_BIN].gst) {
+               LOGD("set the videobin state to READY");
+               ret = _mmplayer_gst_set_state(player, player->pipeline->videobin[MMPLAYER_V_BIN].gst,
+                                                       GST_STATE_READY, TRUE, MMPLAYER_STATE_CHANGE_TIMEOUT(player));
 
-       /* set state to READY */
+       }
+
+       if (player->pipeline->audiobin && player->pipeline->audiobin[MMPLAYER_A_BIN].gst) {
+               LOGD("set the audiobin state to READY");
+               ret = _mmplayer_gst_set_state(player, player->pipeline->audiobin[MMPLAYER_A_BIN].gst,
+                                                       GST_STATE_READY, TRUE, MMPLAYER_STATE_CHANGE_TIMEOUT(player));
+
+       }
+
+       LOGD("set the pipeline state to READY");
        ret = _mmplayer_gst_set_state(player, player->pipeline->mainbin[MMPLAYER_M_PIPE].gst,
                                                GST_STATE_READY, FALSE, MMPLAYER_STATE_CHANGE_TIMEOUT(player));
+
        if (ret != MM_ERROR_NONE) {
                LOGE("fail to change state to READY");
                return MM_ERROR_PLAYER_INTERNAL;
@@ -7486,7 +7505,7 @@ _mmplayer_gst_decode_pad_removed(GstElement *elem, GstPad *pad,
        if (MMPLAYER_USE_DECODEBIN(player))
                return;
 
-       if (!videobin || !g_str_has_prefix (GST_PAD_NAME (pad), "video"))
+       if (!videobin || !g_str_has_prefix(GST_PAD_NAME (pad), "video"))
                return;
 
        ret = _mmplayer_gst_set_state(player, mainbin[MMPLAYER_M_V_CONCAT].gst, GST_STATE_NULL, FALSE, timeout);
@@ -7550,7 +7569,7 @@ _mmplayer_gst_about_to_finish(GstElement *bin, gpointer data)
        _mmplayer_set_reconfigure_state(player, TRUE);
        MMPLAYER_CMD_UNLOCK(player);
 
-       MMPLAYER_POST_MSG(player, MM_MESSAGE_GAPLESS_CONSTRUCTION, NULL);
+       MMPLAYER_POST_MSG(player, MM_MESSAGE_FLUSH_BUFFER, NULL);
        __mmplayer_deactivate_old_path(player);
 
        MMPLAYER_FLEAVE();
@@ -7621,7 +7640,7 @@ _mmplayer_gst_decode_drained(GstElement *bin, gpointer data)
        player->gapless.update_segment[MM_PLAYER_TRACK_TYPE_VIDEO] = FALSE;
 
        /* 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_POST_MSG(player, MM_MESSAGE_FLUSH_BUFFER, NULL); /* post message for gapless */
        __mmplayer_deactivate_old_path(player);
 
        MMPLAYER_FLEAVE();
@@ -7676,6 +7695,9 @@ _mmplayer_gst_element_added(GstElement *bin, GstElement *element, gpointer data)
 #endif
                player->pipeline->mainbin[MMPLAYER_M_DEMUX].id = MMPLAYER_M_DEMUX;
                player->pipeline->mainbin[MMPLAYER_M_DEMUX].gst = element;
+       } else if (g_strrstr(klass, "Parser") && (g_strrstr(klass, "Video"))) {
+               player->pipeline->mainbin[MMPLAYER_M_V_PARSE].id = MMPLAYER_M_V_PARSE;
+               player->pipeline->mainbin[MMPLAYER_M_V_PARSE].gst = element;
        }
 
        if (g_strrstr(factory_name, "asfdemux") || g_strrstr(factory_name, "qtdemux") || g_strrstr(factory_name, "avidemux")) {
@@ -7699,6 +7721,12 @@ _mmplayer_gst_element_added(GstElement *bin, GstElement *element, gpointer data)
                }
        } else if (g_strrstr(factory_name, player->ini.videocodec_element_hw)) {
                player->pipeline->mainbin[MMPLAYER_M_DEC1].gst = element;
+       } else if (g_strrstr(factory_name, "omxdec_h264")) {
+               GstElement *video_parse = player->pipeline->mainbin[MMPLAYER_M_V_PARSE].gst;
+               if (video_parse && (g_object_class_find_property(G_OBJECT_GET_CLASS(video_parse), "config-interval"))) {
+                       g_object_set(G_OBJECT(video_parse), "config-interval", -1, NULL);
+                       LOGD("Send SPS and PPS Insertion every IDR frame");
+               }
        }
 
        if ((player->pipeline->mainbin[MMPLAYER_M_DEMUX].gst) &&
@@ -8006,7 +8034,7 @@ __mmplayer_release_signal_connection(mmplayer_t *player, mmplayer_signal_type_e
        for (; sig_list; sig_list = sig_list->next) {
                item = sig_list->data;
 
-               if (item && item->obj && GST_IS_ELEMENT(item->obj)) {
+               if (item && item->obj) {
                        if (g_signal_handler_is_connected(item->obj, item->sig))
                                g_signal_handler_disconnect(item->obj, item->sig);
                }
@@ -8414,7 +8442,7 @@ __mmplayer_switch_stream(mmplayer_t *player, mmplayer_track_type_e type, int ind
 
        if (streams) {
                LOGD("send select stream event");
-               gst_element_send_event(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst,
+               gst_element_send_event(player->pipeline->mainbin[MMPLAYER_M_AUTOPLUG].gst,
                                gst_event_new_select_streams(streams));
                g_list_free(streams);
        }