[0.6.40] check external storage state before use the path 00/122200/2
authorEunhae Choi <eunhae1.choi@samsung.com>
Thu, 30 Mar 2017 12:57:48 +0000 (21:57 +0900)
committerEunhae Choi <eunhae1.choi@samsung.com>
Thu, 30 Mar 2017 13:29:08 +0000 (22:29 +0900)
Change-Id: I544d9b6002138660169844e023fe42338a09aecb

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

index 74ba6e8..79aa5ed 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-player
 Summary:    Multimedia Framework Player Library
-Version:    0.6.39
+Version:    0.6.40
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index f6642b2..4d716fa 100644 (file)
@@ -5723,8 +5723,13 @@ __mmplayer_gst_create_subtitle_src(mm_player_t* player)
                LOGE("subtitle uri is not proper filepath.\n");
                return MM_ERROR_PLAYER_INVALID_URI;
        }
-       LOGD("subtitle file path is [%s].\n", subtitle_uri);
 
+       if (!util_get_storage_info(subtitle_uri, &player->storage_info[MMPLAYER_PATH_TEXT])) {
+               LOGE("failed to get storage info of subtitle path");
+               return MM_ERROR_PLAYER_INVALID_URI;
+       }
+
+       LOGD("subtitle file path is [%s].\n", subtitle_uri);
 
        /* create the subtitle source */
        subsrc = gst_element_factory_make("filesrc", "subtitle_source");
@@ -5812,9 +5817,6 @@ __mmplayer_gst_create_subtitle_src(mm_player_t* player)
        gst_object_unref(pad);
        pad = NULL;
 
-       if (!util_get_storage_info(subtitle_uri, &player->storage_info[MMPLAYER_PATH_TEXT]))
-               LOGE("failed to get storage info of subtitle path");
-
        /* create dot. for debugging */
        MMPLAYER_GENERATE_DOT_IF_ENABLED(player, "pipeline-with-subtitle");
        MMPLAYER_FLEAVE();
@@ -6363,6 +6365,10 @@ __mmplayer_gst_create_pipeline(mm_player_t* player) // @
                                        LOGD("PD Location : %s\n", path);
 
                                        if (path) {
+                                               if (!util_get_storage_info(path, &player->storage_info[MMPLAYER_PATH_VOD])) {
+                                                       LOGE("failed to get storage info");
+                                                       break;
+                                               }
                                                player->pd_file_save_path = g_strdup(path);
                                        } else {
                                                LOGE("can't find pd location so, it should be set \n");
@@ -6380,12 +6386,9 @@ __mmplayer_gst_create_pipeline(mm_player_t* player) // @
                                        g_object_set(G_OBJECT(element), "location", player->pd_file_save_path, NULL);
                                else
                                        g_object_set(G_OBJECT(element), "location", player->profile.uri, NULL);
-
                                g_object_get(element, "location", &location, NULL);
                                LOGD("PD_LOCATION [%s].\n", location);
-                               if (!util_get_storage_info(location, &player->storage_info[MMPLAYER_PATH_VOD]))
-                                       LOGE("failed to get storage info");
-                               if (location)
+                               if(location)
                                        g_free(location);
                        }
                }
@@ -6394,19 +6397,19 @@ __mmplayer_gst_create_pipeline(mm_player_t* player) // @
        /* file source */
        case MM_PLAYER_URI_TYPE_FILE:
                {
-
                        LOGD("using filesrc for 'file://' handler.\n");
+                       if (!util_get_storage_info(player->profile.uri, &player->storage_info[MMPLAYER_PATH_VOD])) {
+                               LOGE("failed to get storage info");
+                               break;
+                       }
 
                        element = gst_element_factory_make("filesrc", "source");
-
                        if (!element) {
                                LOGE("failed to create filesrc\n");
                                break;
                        }
 
                        g_object_set(G_OBJECT(element), "location", (player->profile.uri)+7, NULL);     /* uri+7 -> remove "file:// */
-                       if (!util_get_storage_info(player->profile.uri, &player->storage_info[MMPLAYER_PATH_VOD]))
-                               LOGE("failed to get storage info");
                }
                break;
 
@@ -11227,6 +11230,10 @@ __mmplayer_activate_next_source(mm_player_t *player, GstState target)
        case MM_PLAYER_URI_TYPE_FILE:
        {
                LOGD("using filesrc for 'file://' handler.\n");
+               if (!util_get_storage_info(player->profile.uri, &player->storage_info[MMPLAYER_PATH_VOD])) {
+                       LOGE("failed to get storage info");
+                       break;
+               }
 
                element = gst_element_factory_make("filesrc", "source");
 
@@ -11236,8 +11243,6 @@ __mmplayer_activate_next_source(mm_player_t *player, GstState target)
                }
 
                g_object_set(G_OBJECT(element), "location", (player->profile.uri)+7, NULL);     /* uri+7 -> remove "file:// */
-               if (!util_get_storage_info(player->profile.uri, &player->storage_info[MMPLAYER_PATH_VOD]))
-                       LOGE("failed to get storage info");
                break;
        }
        case MM_PLAYER_URI_TYPE_URL_HTTP:
@@ -14204,6 +14209,12 @@ __mmplayer_change_external_subtitle_language(mm_player_t* player, const char* fi
                goto EXIT;
        }
 
+       if (!util_get_storage_info(filepath, &player->storage_info[MMPLAYER_PATH_TEXT])) {
+               LOGE("failed to get storage info of subtitle path");
+               result = MM_ERROR_PLAYER_INVALID_URI;
+               goto EXIT;
+       }
+
        LOGD("old subtitle file path is [%s]\n", subtitle_uri);
        LOGD("new subtitle file path is [%s]\n", filepath);
 
@@ -14245,9 +14256,6 @@ __mmplayer_change_external_subtitle_language(mm_player_t* player, const char* fi
 
        g_object_set(G_OBJECT(mainbin[MMPLAYER_M_SUBSRC].gst), "location", filepath, NULL);
 
-       if (!util_get_storage_info(filepath, &player->storage_info[MMPLAYER_PATH_TEXT]))
-               LOGE("failed to get storage info of subtitle path");
-
        charset = util_get_charset(filepath);
        if (charset) {
                LOGD("detected charset is %s\n", charset);
index 6e72720..e92c35f 100644 (file)
@@ -472,7 +472,7 @@ static int _util_storage_supported_cb(int storage_id, storage_type_e type,
 
        MMPLAYER_RETURN_VAL_IF_FAIL(storage_info, FALSE);
 
-       if (type == storage_info->type && state >= STORAGE_STATE_MOUNTED) {
+       if (type == storage_info->type) {
                storage_info->id = storage_id;
                storage_info->state = state;
                return FALSE;
@@ -502,7 +502,12 @@ bool util_get_storage_info(const char *path, MMPlayerStorageInfo *storage_info)
                return false;
        }
 
-       LOGD("storage info: type %d, id %d", storage_info->type, storage_info->id);
+       if ((storage_info->type == STORAGE_TYPE_EXTERNAL) &&
+               (storage_info->state <= STORAGE_STATE_REMOVED)) {
+               LOGE("need to check the storage state : %d", storage_info->state);
+               return false;
+       }
 
+       LOGD("storage info: type %d, id %d", storage_info->type, storage_info->id);
        return true;
 }