fix crash and build error from tv profile
[platform/core/api/media-content.git] / src / media_info.c
index 2741bab..ca7d0b1 100755 (executable)
@@ -264,8 +264,10 @@ static int __media_info_insert_batch(media_batch_insert_e insert_type, const cha
 void _media_info_item_get_detail(sqlite3_stmt* stmt, media_info_h media)
 {
        media_info_s *_media = (media_info_s*)media;
+#ifndef _USE_TV_PROFILE
        char *tmp_path = NULL;
        char repl_path[MAX_QUERY_SIZE] = {0, };
+#endif
 
        _media->media_id = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_UUID));
 #ifdef _USE_TV_PROFILE
@@ -466,7 +468,10 @@ int media_info_insert_to_db(const char *path, media_info_h *info)
        media_info_s *_media = (media_info_s*)calloc(1, sizeof(media_info_s));
        media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
 
-       ret = _media_info_get_media_info_from_db(repl_path, DEFAULT_MEDIA_STORAGE_ID, (media_info_h)_media);
+       if (STRING_VALID(storage_id))
+               ret = _media_info_get_media_info_from_db(repl_path, storage_id, (media_info_h)_media);
+       else
+               ret = _media_info_get_media_info_from_db(repl_path, DEFAULT_MEDIA_STORAGE_ID, (media_info_h)_media);
 
        *info = (media_info_h)_media;
        return ret;
@@ -3081,16 +3086,18 @@ int media_info_cancel_face_detection(media_info_h media)
 static int __media_info_map_data_usr_to_svc(media_info_s *media, media_svc_content_info_s **service_content, media_content_storage_e storage_type)
 {
        media_content_retvm_if(media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid handle");
+#ifndef _USE_TV_PROFILE
        char repl_path[MAX_QUERY_SIZE] = {0, };
        char *tmp_path = NULL;
+#endif
 
        media_svc_content_info_s *svc_content_info = calloc(1, sizeof(media_svc_content_info_s));
        media_content_retvm_if(svc_content_info == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-       memset(repl_path, 0, sizeof(repl_path));
 
 #ifdef _USE_TV_PROFILE
        svc_content_info->path = g_strdup(media->file_path);
 #else
+       memset(repl_path, 0, sizeof(repl_path));
        tmp_path = g_strdup(media->file_path);
        _media_content_replace_path(tmp_path, repl_path);
        svc_content_info->path = g_strdup(repl_path);