[0.6.65] Remove pd watch callback when unrelize pd pipeline 85/168585/1 accepted/tizen_3.0_common accepted/tizen_3.0_mobile accepted/tizen_3.0_tv accepted/tizen_3.0_wearable tizen_3.0 accepted/tizen/3.0/common/20180202.113507 accepted/tizen/3.0/mobile/20180202.052054 accepted/tizen/3.0/tv/20180202.052058 accepted/tizen/3.0/wearable/20180202.052102 submit/tizen_3.0/20180130.022618
authorGilbok Lee <gilbok.lee@samsung.com>
Fri, 11 Aug 2017 06:18:57 +0000 (15:18 +0900)
committerEunhae Choi <eunhae1.choi@samsung.com>
Mon, 29 Jan 2018 06:49:04 +0000 (15:49 +0900)
- add pd lock to avoid the deadlock during state change

Change-Id: If2387afb79b8384b46c888cc8826afa98e764a52
(cherry picked from commit ce13f1afa11fdbb6561a3fa9c192d406eb1f127c)

packaging/libmm-player.spec
src/include/mm_player_pd.h
src/mm_player_pd.c
src/mm_player_priv.c

index 45b0148..ab934c1 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-player
 Summary:    Multimedia Framework Player Library
-Version:    0.6.64
+Version:    0.6.65
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index 9e54cb2..2841603 100644 (file)
@@ -37,7 +37,7 @@ typedef struct {
        gchar *path_read_from;          // path for download and playback
        gchar *location_to_save;                // path for saving to local
        gint64 total_size;                              // size of file to download (bytes)
-
+       GMutex pd_mutex;
        GstElement *playback_pipeline_src;  // src element of playback pipeline
        GstElement *downloader_pipeline;
        GstElement *downloader_src;
index 62c6ffe..8c9511b 100644 (file)
@@ -277,6 +277,9 @@ gboolean _mmplayer_destroy_pd_downloader(MMHandleType handle)
        if (pd && pd->downloader_pipeline)
                _mmplayer_unrealize_pd_downloader(handle);
 
+       if (pd)
+               g_mutex_clear(&pd->pd_mutex);
+
        /* release PD handle */
        MMPLAYER_FREEIF(pd);
 
@@ -304,6 +307,7 @@ gboolean _mmplayer_realize_pd_downloader(MMHandleType handle, gchar *src_uri, gc
        pd->location_to_save = g_strdup(dst_uri);
        pd->playback_pipeline_src = pushsrc;
        pd->total_size = 0LL;
+       g_mutex_init(&pd->pd_mutex);
 
        MMPLAYER_FLEAVE();
 
@@ -381,10 +385,13 @@ gboolean _mmplayer_start_pd_downloader(MMHandleType handle)
 
        SECURE_LOGD("src location = %s, save location = %s\n", pd->path_read_from, pd->location_to_save);
 
+       g_mutex_lock(&pd->pd_mutex);
+
        /* Start to download */
        sret = gst_element_set_state(pd->downloader_pipeline, GST_STATE_PLAYING);
        if (GST_STATE_CHANGE_FAILURE == sret) {
                LOGE("PD download pipeline failed to go to PLAYING state...");
+               g_mutex_unlock(&pd->pd_mutex);
                return FALSE;
        }
 
@@ -393,11 +400,14 @@ gboolean _mmplayer_start_pd_downloader(MMHandleType handle)
        sret = gst_element_get_state(pd->downloader_pipeline, &cur_state, &pending_state, PD_STATE_CHANGE_TIMEOUT);
        if (GST_STATE_CHANGE_FAILURE == sret) {
                LOGE("PD download pipeline failed to do get_state...");
+               g_mutex_unlock(&pd->pd_mutex);
                return FALSE;
        }
 
        LOGD("get-state :: sret = %d\n", sret);
 
+       g_mutex_unlock(&pd->pd_mutex);
+
        MMPLAYER_FLEAVE();
 
        return TRUE;
@@ -409,6 +419,7 @@ gboolean _mmplayer_unrealize_pd_downloader(MMHandleType handle)
        MMPLAYER_FENTER();
 
        mm_player_pd_t * pd = NULL;
+       GstBus *bus = NULL;
 
        MMPLAYER_RETURN_VAL_IF_FAIL(handle, FALSE);
 
@@ -416,6 +427,12 @@ gboolean _mmplayer_unrealize_pd_downloader(MMHandleType handle)
 
        MMPLAYER_RETURN_VAL_IF_FAIL(pd && pd->downloader_pipeline, FALSE);
 
+       g_mutex_lock(&pd->pd_mutex);
+
+       bus = gst_pipeline_get_bus(GST_PIPELINE(pd->downloader_pipeline));
+       gst_bus_remove_watch(bus);
+       gst_object_unref(bus);
+
        gst_element_set_state(pd->downloader_pipeline, GST_STATE_NULL);
        gst_element_get_state(pd->downloader_pipeline, NULL, NULL, PD_STATE_CHANGE_TIMEOUT);
 
@@ -426,6 +443,8 @@ gboolean _mmplayer_unrealize_pd_downloader(MMHandleType handle)
        MMPLAYER_FREEIF(pd->path_read_from);
        MMPLAYER_FREEIF(pd->location_to_save);
 
+       g_mutex_unlock(&pd->pd_mutex);
+
        MMPLAYER_FLEAVE();
 
        return TRUE;
index c2e6732..4c06677 100644 (file)
@@ -8700,12 +8700,7 @@ __mmplayer_destroy_streaming_ext(mm_player_t* player)
 {
        MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
 
-       if (player->pd_downloader) {
-               _mmplayer_unrealize_pd_downloader((MMHandleType)player);
-               MMPLAYER_FREEIF(player->pd_downloader);
-       }
-
-       if (MMPLAYER_IS_HTTP_PD(player)) {
+       if (player->pd_downloader || MMPLAYER_IS_HTTP_PD(player)) {
                _mmplayer_destroy_pd_downloader((MMHandleType)player);
                MMPLAYER_FREEIF(player->pd_file_save_path);
        }
@@ -9052,10 +9047,8 @@ __mmplayer_unrealize_streaming_ext(mm_player_t *player)
        MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
 
        /* destroy can called at anytime */
-       if (player->pd_downloader && MMPLAYER_IS_HTTP_PD(player)) {
+       if (player->pd_downloader && MMPLAYER_IS_HTTP_PD(player))
                _mmplayer_unrealize_pd_downloader((MMHandleType)player);
-               MMPLAYER_FREEIF(player->pd_downloader);
-       }
 
        MMPLAYER_FLEAVE();
        return MM_ERROR_NONE;