[0.6.62] fix mem leak 63/145463/2 accepted/tizen/4.0/unified/20170829.020534 accepted/tizen/unified/20170823.031715 submit/tizen/20170822.114338 submit/tizen_4.0/20170828.100004 submit/tizen_4.0/20170828.110004
authorEunhae Choi <eunhae1.choi@samsung.com>
Tue, 22 Aug 2017 10:24:07 +0000 (19:24 +0900)
committerEunhae Choi <eunhae1.choi@samsung.com>
Tue, 22 Aug 2017 11:04:40 +0000 (20:04 +0900)
Change-Id: Ic38e7bae4b099d2ae84dc08db96640be3b69645a

packaging/libmm-player.spec
src/mm_player_audioeffect.c
src/mm_player_priv.c
src/mm_player_utils.c

index 412c383..b0a75a6 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-player
 Summary:    Multimedia Framework Player Library
-Version:    0.6.61
+Version:    0.6.62
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index a50901a..2f22888 100644 (file)
@@ -34,7 +34,7 @@ mm_player_get_foreach_present_supported_effect_type(MMHandleType hplayer, MMAudi
        mm_player_t *player = NULL;
        int result = MM_ERROR_NONE;
        mm_sound_device_flags_e flags = MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG | MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG;
-       MMSoundDeviceList_t device_list;
+       MMSoundDeviceList_t device_list = NULL;
        MMSoundDevice_t device_h = NULL;
        mm_sound_device_type_e device_type;
        int i = 0;
@@ -47,30 +47,25 @@ mm_player_get_foreach_present_supported_effect_type(MMHandleType hplayer, MMAudi
 
        /* get status if speaker is activated */
        /* (1) get current device list */
-       result = mm_sound_get_current_device_list(flags, &device_list);
-
-       if (result) {
-               LOGE("mm_sound_get_current_device_list() failed [%x]!!", result);
+       result = mm_sound_get_device_list(flags, &device_list);
+       if (result != MM_ERROR_NONE) {
+               LOGE("mm_sound_get_device_list() failed [%x]!!", result);
                MMPLAYER_FLEAVE();
                return result;
        }
 
        /* (2) get device handle of device list */
        result = mm_sound_get_next_device(device_list, &device_h);
-
-       if (result) {
+       if (result != MM_ERROR_NONE) {
                LOGE("mm_sound_get_next_device() failed [%x]!!", result);
-               MMPLAYER_FLEAVE();
-               return result;
+               goto EXIT;
        }
 
        /* (3) get device type */
        result = mm_sound_get_device_type(device_h, &device_type);
-
-       if (result) {
+       if (result != MM_ERROR_NONE) {
                LOGE("mm_sound_get_device_type() failed [%x]!!", result);
-               MMPLAYER_FLEAVE();
-               return result;
+               goto EXIT;
        }
 
        if (effect_type == MM_AUDIO_EFFECT_TYPE_PRESET) {
@@ -81,8 +76,11 @@ mm_player_get_foreach_present_supported_effect_type(MMHandleType hplayer, MMAudi
                                        player->ini.audio_effect_preset_earphone_only_list[i])
                                        continue;
 
-                               if (!foreach_cb(effect_type, i, user_data))
-                                       goto CALLBACK_ERROR;
+                               if (!foreach_cb(effect_type, i, user_data)) {
+                                       LOGE("foreach callback returned error");
+                                       result = MM_ERROR_PLAYER_INTERNAL;
+                                       goto EXIT;
+                               }
                        }
                }
        } else if (effect_type == MM_AUDIO_EFFECT_TYPE_CUSTOM) {
@@ -93,8 +91,11 @@ mm_player_get_foreach_present_supported_effect_type(MMHandleType hplayer, MMAudi
                                        player->ini.audio_effect_custom_earphone_only_list[i]) {
                                        continue;
                                }
-                               if (!foreach_cb(effect_type, i, user_data))
-                                       goto CALLBACK_ERROR;
+                               if (!foreach_cb(effect_type, i, user_data)) {
+                                       LOGE("foreach callback returned error");
+                                       result = MM_ERROR_PLAYER_INTERNAL;
+                                       goto EXIT;
+                               }
                        }
                }
        } else {
@@ -102,14 +103,12 @@ mm_player_get_foreach_present_supported_effect_type(MMHandleType hplayer, MMAudi
                result = MM_ERROR_INVALID_ARGUMENT;
        }
 
-       MMPLAYER_FLEAVE();
-
-       return result;
+EXIT:
+       if (device_list)
+               mm_sound_free_device_list(device_list);
 
-CALLBACK_ERROR:
-       LOGE("foreach callback returned error");
        MMPLAYER_FLEAVE();
-       return MM_ERROR_PLAYER_INTERNAL;
+       return result;
 }
 
 
@@ -218,7 +217,7 @@ __mmplayer_audio_set_output_type(mm_player_t *player, MMAudioEffectType effect_t
 {
        GstElement *audio_effect_element = NULL;
        mm_sound_device_flags_e flags = MM_SOUND_DEVICE_ALL_FLAG;
-       MMSoundDeviceList_t device_list;
+       MMSoundDeviceList_t device_list = NULL;
        MMSoundDevice_t device_h = NULL;
        mm_sound_device_type_e device_type;
        int output_type = 0;
@@ -231,30 +230,25 @@ __mmplayer_audio_set_output_type(mm_player_t *player, MMAudioEffectType effect_t
        audio_effect_element = player->pipeline->audiobin[MMPLAYER_A_FILTER].gst;
 
        /* (1) get current device list */
-       result = mm_sound_get_current_device_list(flags, &device_list);
-
-       if (result) {
-               LOGE("mm_sound_get_current_device_list() failed [%x]!!", result);
+       result = mm_sound_get_device_list(flags, &device_list);
+       if (result != MM_ERROR_NONE) {
+               LOGE("mm_sound_get_device_list() failed [%x]!!", result);
                MMPLAYER_FLEAVE();
                return result;
        }
 
        /* (2) get device handle of device list */
        result = mm_sound_get_next_device(device_list, &device_h);
-
-       if (result) {
+       if (result != MM_ERROR_NONE) {
                LOGE("mm_sound_get_next_device() failed [%x]!!", result);
-               MMPLAYER_FLEAVE();
-               return result;
+               goto EXIT;
        }
 
        /* (3) get device type */
        result = mm_sound_get_device_type(device_h, &device_type);
-
-       if (result) {
+       if (result != MM_ERROR_NONE) {
                LOGE("mm_sound_get_device_type() failed [%x]!!", result);
-               MMPLAYER_FLEAVE();
-               return result;
+               goto EXIT;
        }
 
        /* SPEAKER case */
@@ -262,8 +256,8 @@ __mmplayer_audio_set_output_type(mm_player_t *player, MMAudioEffectType effect_t
                if (MM_AUDIO_EFFECT_TYPE_SQUARE != effect_type) {
                        if (__mmplayer_is_earphone_only_effect_type(player, effect_type, effect)) {
                                LOGE("earphone is not equipped, this filter will not be applied");
-                               MMPLAYER_FLEAVE();
-                               return MM_ERROR_PLAYER_SOUND_EFFECT_INVALID_STATUS;
+                               result = MM_ERROR_PLAYER_SOUND_EFFECT_INVALID_STATUS;
+                               goto EXIT;
                        }
                }
                output_type = MM_AUDIO_EFFECT_OUTPUT_SPK;
@@ -284,6 +278,11 @@ __mmplayer_audio_set_output_type(mm_player_t *player, MMAudioEffectType effect_t
        /* set filter output mode */
        g_object_set(audio_effect_element, "filter-output-mode", output_type, NULL);
 
+EXIT:
+       if (device_list)
+               mm_sound_free_device_list(device_list);
+
+       MMPLAYER_FLEAVE();
        return result;
 }
 
@@ -292,7 +291,7 @@ _mmplayer_is_supported_effect_type(mm_player_t* player, MMAudioEffectType effect
 {
        gboolean result = TRUE;
        mm_sound_device_flags_e flags = MM_SOUND_DEVICE_ALL_FLAG;
-       MMSoundDeviceList_t device_list;
+       MMSoundDeviceList_t device_list = NULL;
        MMSoundDevice_t device_h = NULL;
        mm_sound_device_type_e device_type;
        int ret = MM_ERROR_NONE;
@@ -301,29 +300,25 @@ _mmplayer_is_supported_effect_type(mm_player_t* player, MMAudioEffectType effect
 
        /* get status if speaker is activated */
        /* (1) get current device list */
-       ret = mm_sound_get_current_device_list(flags, &device_list);
-       if (ret) {
+       ret = mm_sound_get_device_list(flags, &device_list);
+       if (ret != MM_ERROR_NONE) {
                MMPLAYER_FLEAVE();
-               LOGE("mm_sound_get_current_device_list() failed [%x]!!", ret);
+               LOGE("mm_sound_get_device_list() failed [%x]!!", ret);
                return FALSE;
        }
 
        /* (2) get device handle of device list */
        ret = mm_sound_get_next_device(device_list, &device_h);
-
-       if (ret) {
+       if (ret != MM_ERROR_NONE) {
                LOGE("mm_sound_get_next_device() failed [%x]!!", ret);
-               MMPLAYER_FLEAVE();
-               return FALSE;
+               goto EXIT;
        }
 
        /* (3) get device type */
        ret = mm_sound_get_device_type(device_h, &device_type);
-
-       if (ret) {
+       if (ret != MM_ERROR_NONE) {
                LOGE("mm_sound_get_device_type() failed [%x]!!", ret);
-               MMPLAYER_FLEAVE();
-               return FALSE;
+               goto EXIT;
        }
 
        /* preset */
@@ -368,9 +363,11 @@ _mmplayer_is_supported_effect_type(mm_player_t* player, MMAudioEffectType effect
                result = FALSE;
        }
 
+EXIT:
+       if (device_list)
+               mm_sound_free_device_list(device_list);
 
        MMPLAYER_FLEAVE();
-
        return result;
 }
 
index 665418b..f8c82c0 100644 (file)
@@ -1826,6 +1826,7 @@ do {      \
                buffer = gst_sample_get_buffer(sample);\
                if (!gst_buffer_map(buffer, &info, GST_MAP_READ)) {\
                        LOGD("failed to get image data from tag");\
+                       gst_sample_unref(sample);\
                        return FALSE;\
                } \
                SECURE_LOGD("update album cover data : %p, size : %d\n", info.data, info.size);\
@@ -1842,6 +1843,7 @@ do {      \
                        } \
                } \
                gst_buffer_unmap(buffer, &info);\
+               gst_sample_unref(sample);\
        }       \
 } while (0)
 
@@ -6353,8 +6355,10 @@ __mmplayer_gst_create_pipeline(mm_player_t* player)
                                if (util_check_valid_url(proxy))
                                        g_object_set(G_OBJECT(element), "proxy", proxy, NULL);
                                /* parsing cookies */
-                               if ((cookie_list = util_get_cookie_list((const char*)cookies)))
+                               if ((cookie_list = util_get_cookie_list((const char*)cookies))) {
                                        g_object_set(G_OBJECT(element), "cookies", cookie_list, NULL);
+                                       g_strfreev (cookie_list);
+                               }
                                if (user_agent)
                                        g_object_set(G_OBJECT(element), "user-agent", user_agent, NULL);
 
@@ -7927,29 +7931,19 @@ static int __mmfplayer_parse_profile(const char *uri, void *param, MMPlayerParse
                                ret = MM_ERROR_NONE;
                        }
                }
-       } else if ((path = strstr(uri, "http://"))) {
+       } else if ((path = strstr(uri, "http://")) || (path = strstr(uri, "https://"))) {
                if (strlen(path)) {
+                       gchar *tmp = NULL;
                        strncpy(data->uri, uri, MM_MAX_URL_LEN-1);
+                       tmp = g_ascii_strdown(uri, strlen(uri));
 
-                       if (g_str_has_suffix(g_ascii_strdown(uri, strlen(uri)), ".ism/manifest") ||
-                               g_str_has_suffix(g_ascii_strdown(uri, strlen(uri)), ".isml/manifest"))
+                       if (tmp && (g_str_has_suffix(tmp, ".ism/manifest") || g_str_has_suffix(tmp, ".isml/manifest")))
                                data->uri_type = MM_PLAYER_URI_TYPE_SS;
                        else
                                data->uri_type = MM_PLAYER_URI_TYPE_URL_HTTP;
 
                        ret = MM_ERROR_NONE;
-               }
-       } else if ((path = strstr(uri, "https://"))) {
-               if (strlen(path)) {
-                       strncpy(data->uri, uri, MM_MAX_URL_LEN-1);
-
-               if (g_str_has_suffix(g_ascii_strdown(uri, strlen(uri)), ".ism/manifest") ||
-                               g_str_has_suffix(g_ascii_strdown(uri, strlen(uri)), ".isml/manifest"))
-                               data->uri_type = MM_PLAYER_URI_TYPE_SS;
-
-                       data->uri_type = MM_PLAYER_URI_TYPE_URL_HTTP;
-
-                       ret = MM_ERROR_NONE;
+                       g_free(tmp);
                }
        } else if ((path = strstr(uri, "rtspu://"))) {
                if (strlen(path)) {
index e92c35f..8bc83b4 100644 (file)
@@ -262,6 +262,7 @@ util_is_sdp_file(const char *path)
        /* strlen(".sdp") == 4 */
        if (strlen(uri) <= 4) {
                LOGW("path is too short.\n");
+               g_free(uri);
                return ret;
        }