fix crash and build error from tv profile 49/90749/1
authorYong Yeon Kim <yy9875.kim@samsung.com>
Tue, 4 Oct 2016 06:54:13 +0000 (15:54 +0900)
committerYong Yeon Kim <yy9875.kim@samsung.com>
Tue, 4 Oct 2016 06:54:54 +0000 (15:54 +0900)
Change-Id: I318c00b00af8fd19f3b9b5981fa594b9f1bf6fe3

packaging/capi-content-media-content.spec
src/media_db.c
src/media_folder.c
src/media_info.c

index 584942b..bd7145a 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       capi-content-media-content
 Summary:    A Media content library in Tizen Native API
-Version:    0.2.85
+Version:    0.2.86
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index d6ae261..213257c 100755 (executable)
@@ -603,8 +603,10 @@ int _media_db_get_folder(filter_h filter, media_folder_cb callback, void *user_d
        sqlite3_stmt *stmt = NULL;
        attribute_h attr = NULL;
        filter_s *_filter = (filter_s*)filter;
+#ifndef _USE_TV_PROFILE
        char *tmp_path = NULL;
        char repl_path[MAX_QUERY_SIZE] = {0, };
+#endif
 
        attr = _content_get_alias_attirbute_handle();
        memset(select_query, 0x00, sizeof(select_query));
@@ -669,12 +671,13 @@ int _media_db_get_playlist(filter_h filter, media_playlist_cb callback, void *us
        char *option_query = NULL;
        sqlite3_stmt *stmt = NULL;
        attribute_h attr = NULL;
+#ifndef _USE_TV_PROFILE
        char *tmp_path = NULL;
        char repl_path[MAX_QUERY_SIZE] = {0, };
+#endif
 
        attr = _content_get_attirbute_handle();
        memset(select_query, 0x00, sizeof(select_query));
-       memset(repl_path, 0x00, sizeof(repl_path));
 
        if (!SAFE_STRLCPY(select_query, SELECT_PLAYLIST_LIST, sizeof(select_query))) {
                media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
@@ -703,6 +706,7 @@ int _media_db_get_playlist(filter_h filter, media_playlist_cb callback, void *us
 #ifdef _USE_TV_PROFILE
                _playlist->thumbnail_path = g_strdup((const char *)sqlite3_column_text(stmt, 2));
 #else
+               memset(repl_path, 0x00, sizeof(repl_path));
                tmp_path = g_strdup((const char *)sqlite3_column_text(stmt, 2));
                if (STRING_VALID(tmp_path)) {
                        _media_content_rollback_path(tmp_path, repl_path);
index 6559108..2c316ea 100755 (executable)
@@ -43,8 +43,16 @@ int media_folder_foreach_folder_from_db(filter_h filter, media_folder_cb callbac
                return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
        }
 
+#ifdef _USE_TV_PROFILE
+       g_mutex_lock(_content_get_db_mutex());
+#endif
+
        ret = _media_db_get_folder(filter, callback, user_data);
 
+#ifdef _USE_TV_PROFILE
+       g_mutex_unlock(_content_get_db_mutex());
+#endif
+
        return ret;
 }
 
@@ -343,8 +351,10 @@ int media_folder_get_folder_from_db(const char *folder_id, media_folder_h *folde
        int ret = MEDIA_CONTENT_ERROR_NONE;
        sqlite3_stmt *stmt = NULL;
        char select_query[DEFAULT_QUERY_SIZE];
+#ifndef _USE_TV_PROFILE
        char *tmp_path = NULL;
        char repl_path[MAX_QUERY_SIZE] = {0, };
+#endif
 
        if (!STRING_VALID(folder_id)) {
                media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
index fe2e409..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
@@ -3084,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);