[0.6.61] Remove pd watch callback when unrelize pd pipeline 37/143737/5
authorGilbok Lee <gilbok.lee@samsung.com>
Fri, 11 Aug 2017 06:18:57 +0000 (15:18 +0900)
committerGilbok Lee <gilbok.lee@samsung.com>
Mon, 21 Aug 2017 10:55:42 +0000 (19:55 +0900)
Add pd mutex

Change-Id: I2273780a6ecb1786feab45107f32f197a635ea08

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

index 2632db358c28d7a369a68614158f92a4a3037244..412c3836bb5e2d8a36bf97472d096014cef3906f 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-player
 Summary:    Multimedia Framework Player Library
-Version:    0.6.60
+Version:    0.6.61
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index 9e54cb2fdc07ae1d86f476118ab143731b3f7fb1..2841603e05ee98331b7e06b424a910317eff1edf 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 62c6ffe17037f0cf4ba4ab92d3c318b45072ce73..8c9511b3a968979eaea5ac5f3b1ca06a0cc991e6 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 43bcc2b63f9229ff3e3ff93738a53faa53de8153..82918ec67e232397f4a8ca133de8f4dfe1a14598 100644 (file)
@@ -8727,12 +8727,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);
        }
@@ -9089,10 +9084,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;