From: Haejeong Kim Date: Fri, 10 Feb 2012 01:51:45 +0000 (+0900) Subject: code clean up X-Git-Tag: 2.0_alpha~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2058e89dc20faf97853f4fc722079d57bd6862b8;p=platform%2Fcore%2Fmultimedia%2Flibmedia-service.git code clean up --- diff --git a/TC/utc/audio/Makefile b/TC/utc/audio/Makefile index 56f3cca..8004771 100755 --- a/TC/utc/audio/Makefile +++ b/TC/utc/audio/Makefile @@ -13,7 +13,6 @@ endif TS1=utc_audio_svc_add_item_to_playlist_func TS2=utc_audio_svc_add_playlist_func TS3=utc_audio_svc_check_duplicate_insertion_in_playlist_func -#TS4=utc_audio_svc_close_func TS5=utc_audio_svc_get_playlist_func TS7=utc_audio_svc_count_group_item_func TS8=utc_audio_svc_count_list_item_func @@ -37,7 +36,6 @@ TS30=utc_audio_svc_list_item_get_func TS31=utc_audio_svc_list_item_get_val_func TS32=utc_audio_svc_list_item_new_func TS34=utc_audio_svc_move_item_func -#TS35=utc_audio_svc_open_func TS36=utc_audio_svc_playlist_free_func TS37=utc_audio_svc_playlist_get_item_func TS38=utc_audio_svc_playlist_get_val_func diff --git a/TC/utc/audio/utc_audio_svc_close_func.c b/TC/utc/audio/utc_audio_svc_close_func.c deleted file mode 100755 index 28e3297..0000000 --- a/TC/utc/audio/utc_audio_svc_close_func.c +++ /dev/null @@ -1,81 +0,0 @@ -/* - * libmedia-service - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hyunjun Ko , Haejeong Kim - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - - -/** -* @file utc_audio_svc_close_func.c -* @brief This is a suit of unit test cases to test audio_svc_close API function -* @author -* @version Initial Creation Version 0.1 -* @date 2010-09-13 -*/ - -#include "utc_audio_svc_close_func.h" - -void startup() -{ - UTC_AUDIO_SVC_OPEN(); -} - - -/** -* @brief This tests int audio_svc_close() API with valid parameter -* Create a player handle with valid parameter & Test the handle by playing -* @par ID utc_audio_svc_close_func_01 -* @param [in] &player = handle of player to be populated -* @return This function returns zero on success, or negative value with error code -*/ -void utc_audio_svc_close_func_01() -{ - int ret = AUDIO_SVC_ERROR_NONE; - - ret = audio_svc_close(); - dts_check_eq("audio_svc_close", ret, AUDIO_SVC_ERROR_NONE, "fail to close music db."); - -} - -#if 0 -/** -* @brief This tests int audio_svc_close() API with invalid parameter -* Create a player handle with a NULL out param -* @par ID utc_audio_svc_close_func_02 -* @param [in] &player = NULL -* @return error code on success -*/ -void utc_audio_svc_close_func_02() -{ - int ret = AUDIO_SVC_ERROR_NONE; - UTC_AUDIO_SVC_OPEN(); - ret = audio_svc_close(); - if (!ret) - { - UTC_MM_LOG("abnormal condition test for null, error code->%x", ret); - tet_result(TET_PASS); - } - else - { - UTC_MM_LOG("Closing music db should be failed because of the NULL out parameter."); - tet_result(TET_FAIL); - } - - return ; -} -#endif diff --git a/TC/utc/audio/utc_audio_svc_close_func.h b/TC/utc/audio/utc_audio_svc_close_func.h deleted file mode 100755 index d48ad70..0000000 --- a/TC/utc/audio/utc_audio_svc_close_func.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * libmedia-service - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hyunjun Ko , Haejeong Kim - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - - -/** -* @file utc_audio_svc_close_func.h -* @author -* @brief This is the implementaion file for the test case of audio_svc_close API function -* @version Initial Creation Version 0.1 -* @date 2010-09-13 -*/ - -#ifndef __UTS_AUDIO_SVC_CLOSE_FUNC_H_ -#define __UTS_AUDIO_SVC_CLOSE_FUNC_H_ - - -#include "utc_audio_svc_common.h" - - -void startup(); - -/* Initialize TCM data structures */ -void (*tet_startup)() = startup; -void (*tet_cleanup)() = NULL; - -void utc_audio_svc_close_func_01(); -//void utc_audio_svc_close_func_02(); - -struct tet_testlist tet_testlist[] = { - {utc_audio_svc_close_func_01, 1}, -// {utc_audio_svc_close_func_02, 2}, - {NULL, 0} -}; - - -#endif //__UTS_AUDIO_SVC_CLOSE_FUNC_H_ diff --git a/TC/utc/audio/utc_audio_svc_create_table_func.c b/TC/utc/audio/utc_audio_svc_create_table_func.c deleted file mode 100755 index 11bfdf8..0000000 --- a/TC/utc/audio/utc_audio_svc_create_table_func.c +++ /dev/null @@ -1,84 +0,0 @@ -/* - * libmedia-service - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hyunjun Ko , Haejeong Kim - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - - -/** -* @file utc_audio_svc_create_table_func.c -* @brief This is a suit of unit test cases to test audio_svc_create_table API function -* @author -* @version Initial Creation Version 0.1 -* @date 2010-09-13 -*/ - -#include "utc_audio_svc_create_table_func.h" - -void startup() -{ - UTC_AUDIO_SVC_OPEN(); -} - - -void cleanup() -{ - UTC_AUDIO_SVC_CLOSE(); -} - -/** -* @brief This tests int audio_svc_create_table() API with valid parameter -* Create a player handle with valid parameter & Test the handle by playing -* @par ID utc_audio_svc_create_table_func_01 -* @param [in] &player = handle of player to be populated -* @return This function returns zero on success, or negative value with error code -*/ -void utc_audio_svc_create_table_func_01() -{ - int ret = AUDIO_SVC_ERROR_NONE; - - ret = audio_svc_create_table(db_handle); - dts_check_eq("audio_svc_create_table", ret, AUDIO_SVC_ERROR_NONE, "unable to create music phone table."); - -} - -#if 0 -/** -* @brief This tests int audio_svc_create_table() API with invalid parameter -* Create a player handle with a NULL out param -* @par ID utc_audio_svc_create_table_func_02 -* @param [in] &player = NULL -* @return error code on success -*/ -void utc_audio_svc_create_table_func_02() -{ - int ret = AUDIO_SVC_ERROR_NONE; - - ret = audio_svc_create_table(); - - if (ret != AUDIO_SVC_ERROR_NONE) - { - dts_pass("audio_svc_create_table","abnormal condition test for invalid storage type parameter."); - } - else - { - dts_fail("audio_svc_create_table","create music table should be failed because of the invalid storage type."); - } - -} -#endif diff --git a/TC/utc/audio/utc_audio_svc_open_func.c b/TC/utc/audio/utc_audio_svc_open_func.c deleted file mode 100755 index 8aa266a..0000000 --- a/TC/utc/audio/utc_audio_svc_open_func.c +++ /dev/null @@ -1,81 +0,0 @@ -/* - * libmedia-service - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hyunjun Ko , Haejeong Kim - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - - -/** -* @file utc_audio_svc_open_func.c -* @brief This is a suit of unit test cases to test audio_svc_open API function -* @author -* @version Initial Creation Version 0.1 -* @date 2010-09-13 -*/ -#include "utc_audio_svc_open_func.h" - - -void cleanup() -{ - UTC_AUDIO_SVC_CLOSE(); -} - -/** -* @brief This tests int audio_svc_open() API with valid parameter -* Create a player handle with valid parameter & Test the handle by playing -* @par ID utc_audio_svc_open_func_01 -* @param [in] &player = handle of player to be populated -* @return This function returns zero on success, or negative value with error code -*/ -void utc_audio_svc_open_func_01() -{ - int ret = AUDIO_SVC_ERROR_NONE; - - ret = audio_svc_open(); - dts_check_eq("audio_svc_open", ret, AUDIO_SVC_ERROR_NONE, "failed to open music db."); - -} - -#if 0 //there is no abnormal case -/** -* @brief This tests int audio_svc_open() API with invalid parameter -* Create a player handle with a NULL out param -* @par ID utc_audio_svc_open_func_02 -* @param [in] &player = NULL -* @return error code on success -*/ -void utc_audio_svc_open_func_02() -{ - int ret = AUDIO_SVC_ERROR_NONE; - - ret = audio_svc_open(); - - if (ret != AUDIO_SVC_ERROR_NONE) - { - UTC_MM_LOG("abnormal condition test for null, error code->%d", ret); - tet_result(TET_PASS); - } - else - { - UTC_MM_LOG("Open music db should be failed because of the NULL out parameter."); - tet_result(TET_FAIL); - } - - return ; -} -#endif diff --git a/TC/utc/audio/utc_audio_svc_open_func.h b/TC/utc/audio/utc_audio_svc_open_func.h deleted file mode 100755 index a1fdfdd..0000000 --- a/TC/utc/audio/utc_audio_svc_open_func.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * libmedia-service - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hyunjun Ko , Haejeong Kim - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -/** -* @file utc_audio_svc_open_func.h -* @author -* @brief This is the implementaion file for the test case of audio_svc_open API function -* @version Initial Creation Version 0.1 -* @date 2010-09-13 -*/ - -#ifndef __UTS_AUDIO_SVC_OPEN_FUNC_H_ -#define __UTS_AUDIO_SVC_OPEN_FUNC_H_ - - -#include "utc_audio_svc_common.h" - - -void cleanup(); - -/* Initialize TCM data structures */ -void (*tet_startup)() = NULL; -void (*tet_cleanup)() = cleanup; - -void utc_audio_svc_open_func_01(); -//void utc_audio_svc_open_func_02(); - -struct tet_testlist tet_testlist[] = { - {utc_audio_svc_open_func_01, 1}, -// {utc_audio_svc_open_func_02, 2}, - {NULL, 0} -}; - - -#endif //__UTS_AUDIO_SVC_OPEN_FUNC_H_ diff --git a/include/media-svc.h b/include/media-svc.h index 3129087..056bd91 100755 --- a/include/media-svc.h +++ b/include/media-svc.h @@ -48,77 +48,7 @@ extern "C" { manage the service database. */ -#if 0 -/** - * mediainfo_open: - * Open media information service library. This is the function that an user who wants to use media information service calls first. - * This function connects to the media database. - * - * @return This function returns zero(MEDIA_INFO_ERROR_NONE) on success, or negative value with error code. - * Please refer 'media-info-error.h' to know the exact meaning of the error. - * @see mediainfo_close - * @pre None. - * @post call mediainfo_close() to close the media database - * @remark The database name is "/opt/dbspace/.media.db". - * @par example - * @code - -#include -void open_media_db() -{ - int ret = MEDIA_INFO_ERROR_NONE; - // open media database - ret = mediainfo_open(); - // open failed - if (ret < 0) - { - printf( "Cannot open media db. error code->%d", ret); - return; - } - - return; -} - - * @endcode - */ -int mediainfo_open(void); - -/** - * mediainfo_close: - * Open media information service library. This is the function that an user who wants to finalize media information service calls before closing the application. - * This function disconnects to the media database. - * - * @return This function returns zero(MEDIA_INFO_ERROR_NONE) on success, or negative value with error code. - * Please refer 'media-info-error.h' to know the exact meaning of the error. - * @see mediainfo_open - * @pre None. - * @post call mediainfo_open() to open the media database - * @remark The database name is "/opt/dbspace/.media.db". - * @par example - * @code - -#include - -void close_media_db() -{ - int ret = MEDIA_INFO_ERROR_NONE; - // close media database - ret = mediainfo_close(); - // close failed - if (ret < 0) - { - printf( "Cannot close media db. error code->%d", ret); - return; - } - - return; -} - - * @endcode - */ -int mediainfo_close(void); -#endif /** * media_svc_connect: * Connect to the media database. This is the function that an user who wants to get a handle to access the media database. diff --git a/src/audio/audio-svc-db-utils.c b/src/audio/audio-svc-db-utils.c index 1e3bf1b..5865e82 100755 --- a/src/audio/audio-svc-db-utils.c +++ b/src/audio/audio-svc-db-utils.c @@ -55,13 +55,7 @@ int _audio_svc_sql_query(sqlite3 *handle, const char *sql_str) char *zErrMsg = NULL; audio_svc_debug("SQL = [%s]", sql_str); -#if 0 - sqlite3 *handle = _media_info_get_proper_handle(); - if (handle == NULL) { - audio_svc_error("handle is NULL"); - return AUDIO_SVC_ERROR_DB_INTERNAL; - } -#endif + err = sqlite3_exec(handle, sql_str, NULL, NULL, &zErrMsg); if (SQLITE_OK != err) { @@ -108,13 +102,7 @@ int _audio_svc_sql_prepare_to_step(sqlite3 *handle, const char *sql_str, sqlite3 int err = -1; audio_svc_debug("[SQL query] : %s", sql_str); -#if 0 - sqlite3 *handle = _media_info_get_proper_handle(); - if (handle == NULL) { - audio_svc_error("handle is NULL"); - return AUDIO_SVC_ERROR_DB_INTERNAL; - } -#endif + err = sqlite3_prepare_v2(handle, sql_str, -1, stmt, NULL); sqlite3_free((char *)sql_str); @@ -138,13 +126,7 @@ int _audio_svc_sql_begin_trans(sqlite3 *handle) char *err_msg = NULL; audio_svc_debug("========_audio_svc_sql_begin_trans"); -#if 0 - sqlite3 *handle = _media_info_get_proper_handle(); - if (handle == NULL) { - audio_svc_error("handle is NULL"); - return AUDIO_SVC_ERROR_DB_INTERNAL; - } -#endif + if (SQLITE_OK != sqlite3_exec(handle, "BEGIN IMMEDIATE;", NULL, NULL, &err_msg)) { audio_svc_error("Error:failed to begin transaction: error=%s", err_msg); sqlite3_free(err_msg); @@ -161,13 +143,7 @@ int _audio_svc_sql_end_trans(sqlite3 *handle) char *err_msg = NULL; audio_svc_debug("========_audio_svc_sql_end_trans"); -#if 0 - sqlite3 *handle = _media_info_get_proper_handle(); - if (handle == NULL) { - audio_svc_error("handle is NULL"); - return AUDIO_SVC_ERROR_DB_INTERNAL; - } -#endif + if (SQLITE_OK != sqlite3_exec(handle, "COMMIT;", NULL, NULL, &err_msg)) { audio_svc_error("Error:failed to end transaction: error=%s", err_msg); sqlite3_free(err_msg); @@ -184,14 +160,7 @@ int _audio_svc_sql_rollback_trans(sqlite3 *handle) char *err_msg = NULL; audio_svc_debug("========_audio_svc_sql_rollback_trans"); -#if 0 - sqlite3 *handle = _media_info_get_proper_handle(); - if (handle == NULL) { - audio_svc_error("handle is NULL"); - return AUDIO_SVC_ERROR_DB_INTERNAL; - } -#endif if (SQLITE_OK != sqlite3_exec(handle, "ROLLBACK;", NULL, NULL, &err_msg)) { audio_svc_error("Error:failed to rollback transaction: error=%s", err_msg); sqlite3_free(err_msg); diff --git a/src/audio/audio-svc-music-table.c b/src/audio/audio-svc-music-table.c index 492de8f..b14ae5a 100755 --- a/src/audio/audio-svc-music-table.c +++ b/src/audio/audio-svc-music-table.c @@ -253,13 +253,7 @@ __audio_svc_get_invalid_records_with_thumbnail(sqlite3 *handle, audio_svc_storag int err = -1; int idx = 0; sqlite3_stmt *sql_stmt = NULL; -#if 0 - sqlite3 *handle = _media_info_get_proper_handle(); - if (handle == NULL) { - audio_svc_debug("handle is NULL"); - return AUDIO_SVC_ERROR_DB_INTERNAL; - } -#endif + char *sql = sqlite3_mprintf ("select thumbnail_path from %s where valid=0 and storage_type=%d and thumbnail_path is not null", @@ -296,13 +290,7 @@ static int __audio_svc_get_records_with_thumbnail(sqlite3 *handle, audio_svc_sto int err = -1; int idx = 0; sqlite3_stmt *sql_stmt = NULL; -#if 0 - sqlite3 *handle = _media_info_get_proper_handle(); - if (handle == NULL) { - audio_svc_debug("handle is NULL"); - return AUDIO_SVC_ERROR_DB_INTERNAL; - } -#endif + char *sql = sqlite3_mprintf ("select thumbnail_path from %s where storage_type=%d and thumbnail_path is not null", @@ -479,13 +467,6 @@ int _audio_svc_insert_item_with_data(sqlite3 *handle, audio_svc_audio_item_s *it int year = -1; char *audio_id = NULL; -#if 0 - sqlite3 *handle = _media_info_get_proper_handle(); - if (handle == NULL) { - audio_svc_debug("handle is NULL"); - return AUDIO_SVC_ERROR_DB_INTERNAL; - } -#endif if (item == NULL) { audio_svc_error("Invalid handle"); return AUDIO_SVC_ERROR_INVALID_PARAMETER; @@ -1074,13 +1055,7 @@ int _audio_svc_count_music_group_records(sqlite3 *handle, audio_svc_group_type_e int text_bind = 1; sqlite3_stmt *sql_stmt = NULL; -#if 0 - sqlite3 *handle = _media_info_get_proper_handle(); - if (handle == NULL) { - audio_svc_debug("handle is NULL"); - return AUDIO_SVC_ERROR_DB_INTERNAL; - } -#endif + if (filter_string) { if (strlen(filter_string) > 0) { snprintf(filter_query, sizeof(filter_query), "%%%s%%", @@ -1432,13 +1407,7 @@ int _audio_svc_get_music_group_records(sqlite3 *handle, audio_svc_group_type_e g int idx = 0; sqlite3_stmt *sql_stmt = NULL; -#if 0 - sqlite3 *handle = _media_info_get_proper_handle(); - if (handle == NULL) { - audio_svc_debug("handle is NULL"); - return AUDIO_SVC_ERROR_DB_INTERNAL; - } -#endif + if (filter_string) { if (strlen(filter_string) > 0) { snprintf(filter_query, sizeof(filter_query), "%%%s%%", @@ -1837,13 +1806,7 @@ int _audio_svc_count_music_track_records(sqlite3 *handle, audio_svc_track_type_e int text_bind = 1; sqlite3_stmt *sql_stmt = NULL; -#if 0 - sqlite3 *handle = _media_info_get_proper_handle(); - if (handle == NULL) { - audio_svc_debug("handle is NULL"); - return AUDIO_SVC_ERROR_DB_INTERNAL; - } -#endif + if (filter_string) { if (strlen(filter_string) > 0) { snprintf(filter_query, sizeof(filter_query), "%%%s%%", @@ -2233,13 +2196,7 @@ int _audio_svc_get_music_track_records(sqlite3 *handle, audio_svc_track_type_e t int idx = 0; sqlite3_stmt *sql_stmt = NULL; -#if 0 - sqlite3 *handle = _media_info_get_proper_handle(); - if (handle == NULL) { - audio_svc_debug("handle is NULL"); - return AUDIO_SVC_ERROR_DB_INTERNAL; - } -#endif + #define filter_condition(filter_mode, filter_mode2, query) \ if ((filter_mode)) g_strlcat((query), " and title like ?", sizeof((query))); \ if ((filter_mode2)) g_strlcat((query), " and title like ?", sizeof((query))); @@ -2889,23 +2846,6 @@ int _audio_svc_delete_invalid_music_records(sqlite3 *handle, audio_svc_storage_t return AUDIO_SVC_ERROR_DB_INTERNAL; } -#if 0 - for (idx = 0; idx < invalid_count; idx++) { - if (strlen(thumbpath_record[idx].thumbnail_path) > 0) { - ret = - _audio_svc_check_and_remove_thumbnail - (thumbpath_record[idx].thumbnail_path); - if (ret != AUDIO_SVC_ERROR_NONE) { - audio_svc_error - ("error _audio_svc_check_and_remove_thumbnail"); - SAFE_FREE(thumbpath_record); - return ret; - } - } - } - - SAFE_FREE(thumbpath_record); -#endif for (idx = 0; idx < invalid_count; idx++) { if (strlen(thumbpath_record[idx].thumbnail_path) > 0) { if (_audio_svc_remove_file(thumbpath_record[idx].thumbnail_path) == FALSE) { @@ -3090,13 +3030,7 @@ int _audio_svc_append_audio_folder(sqlite3 *handle, audio_svc_storage_type_e sto const char *folder_id, const char *path_name, const char *folder_name, int modified_date) { int err = -1; -#if 0 - sqlite3 *handle = _media_info_get_proper_handle(); - if (handle == NULL) { - audio_svc_debug("handle is NULL"); - return AUDIO_SVC_ERROR_DB_INTERNAL; - } -#endif + char *sql = sqlite3_mprintf("insert into %s (folder_uuid, path, folder_name, storage_type, modified_date) values ('%q', '%q', '%q', '%d', '%d'); ", AUDIO_SVC_DB_TABLE_AUDIO_FOLDER, folder_id, path_name, folder_name, storage_type, modified_date); err = _audio_svc_sql_query(handle, sql); @@ -3308,13 +3242,7 @@ int _audio_svc_list_search(sqlite3 *handle, audio_svc_audio_item_s *item, char order_str[AUDIO_SVC_QUERY_SIZE] = { 0 }; sqlite3_stmt *sql_stmt = NULL; -#if 0 - sqlite3 *handle = _media_info_get_proper_handle(); - if (handle == NULL) { - audio_svc_debug("handle is NULL"); - return AUDIO_SVC_ERROR_DB_INTERNAL; - } -#endif + snprintf(query, sizeof(query), "SELECT * FROM audio_media WHERE %s", where_query); audio_svc_debug(""); diff --git a/src/audio/audio-svc-playlist-table.c b/src/audio/audio-svc-playlist-table.c index e9922fb..3a2c5ea 100755 --- a/src/audio/audio-svc-playlist-table.c +++ b/src/audio/audio-svc-playlist-table.c @@ -268,13 +268,7 @@ int _audio_svc_count_playlist_records(sqlite3 *handle, const char *filter_string bool filter_mode2 = FALSE; sqlite3_stmt *sql_stmt = NULL; -#if 0 - sqlite3 *handle = _media_info_get_proper_handle(); - if (handle == NULL) { - audio_svc_debug("handle is NULL"); - return AUDIO_SVC_ERROR_DB_INTERNAL; - } -#endif + const char *filter_1 = " where name like ?"; const char *filter_2 = " and name like ?"; if (filter_string) { @@ -375,13 +369,7 @@ int _audio_svc_get_playlist_records(sqlite3 *handle, int offset, int rows, int ret = AUDIO_SVC_ERROR_NONE; sqlite3_stmt *sql_stmt = NULL; -#if 0 - sqlite3 *handle = _media_info_get_proper_handle(); - if (handle == NULL) { - audio_svc_debug("handle is NULL"); - return AUDIO_SVC_ERROR_DB_INTERNAL; - } -#endif + if (filter_string) { if (strlen(filter_string) > 0) { filter_mode = TRUE; @@ -508,13 +496,7 @@ int _audio_svc_count_playlist_item_records(sqlite3 *handle, int playlist_id, int text_bind = 1; sqlite3_stmt *sql_stmt = NULL; -#if 0 - sqlite3 *handle = _media_info_get_proper_handle(); - if (handle == NULL) { - audio_svc_debug("handle is NULL"); - return AUDIO_SVC_ERROR_DB_INTERNAL; - } -#endif + if (filter_string) { if (strlen(filter_string) > 0) { snprintf(filter_query, sizeof(filter_query), "%%%s%%", @@ -612,13 +594,7 @@ int _audio_svc_get_playlist_item_records(sqlite3 *handle, int playlist_id, int idx = 0; sqlite3_stmt *sql_stmt = NULL; -#if 0 - sqlite3 *handle = _media_info_get_proper_handle(); - if (handle == NULL) { - audio_svc_debug("handle is NULL"); - return AUDIO_SVC_ERROR_DB_INTERNAL; - } -#endif + filter_mode = STRING_VALID(filter_string); filter_mode2 = STRING_VALID(filter_string2); diff --git a/src/audio/audio-svc-utils.c b/src/audio/audio-svc-utils.c index 3dc55d6..0f1c57a 100755 --- a/src/audio/audio-svc-utils.c +++ b/src/audio/audio-svc-utils.c @@ -147,11 +147,6 @@ int _audio_svc_extract_metadata_audio(audio_svc_storage_type_e storage_type, con bool thumb_extracted_from_drm = FALSE; char *err_attr_name = NULL; char *title = NULL; -#if 0 - bool extract_thumbnail = FALSE; - int album_id = -1; - char *thumbnail_path = NULL; -#endif int artwork_mime_size = -1; _strncpy_safe(item->pathname, path, sizeof(item->pathname)); @@ -555,18 +550,6 @@ int _audio_svc_extract_metadata_audio(audio_svc_storage_type_e storage_type, con /* extract thumbnail image */ /* remove thumbnail extract routine while db creating.*/ -#if 0 - album_id = _audio_svc_get_album_id(item->audio.album); - if (album_id < 0) { - audio_svc_debug("album does not exist. So start to make album art"); - extract_thumbnail = TRUE; - } else { - audio_svc_debug("album already exists. don't need to make album art"); - thumbnail_path = _audio_svc_get_thumbnail_path_by_album_id(album_id); - _strncpy_safe(item->thumbname, thumbnail_path, sizeof(item->thumbname)); - SAFE_FREE(thumbnail_path); - } -#endif if ((!thumb_extracted_from_drm)/* && (extract_thumbnail == TRUE)*/) { mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ARTWORK, &image, &size, NULL); if (mmf_error != 0) { diff --git a/src/audio/audio-svc.c b/src/audio/audio-svc.c index c406622..9335deb 100755 --- a/src/audio/audio-svc.c +++ b/src/audio/audio-svc.c @@ -45,184 +45,6 @@ static __thread int g_audio_svc_move_item_cur_data_cnt = 0; static __thread int g_audio_svc_insert_item_data_cnt = 1; static __thread int g_audio_svc_insert_item_cur_data_cnt = 0; -#if 0 -/** - * audio_svc_open:\n - * Open audio service library. This is the function that an user who wants to use music-service calls first. - * This function connects with the music database and initialize efreet mime libary. - * - * @return This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.\n - * Please refer 'audio-svc-types.h' to know the exact meaning of the error. - * @see audio_svc_close - * @pre None. - * @post call audio_svc_close() to close music database - * @remark The database name is "/opt/dbspace/.music.db". - * @par example - * @code - -#include - -void open_music_db() -{ - int ret = AUDIO_SVC_ERROR_NONE; - // open music database - ret = audio_svc_open(); - // open failed - if (ret < 0) - { - printf( "Cannot open music db. error code->%d", ret); - return; - } - - return; -} - - * @endcode - */ -int audio_svc_open(void); - - -/** - * audio_svc_close:\n - * Close audio service library. This is the function need to call before close the application. - * This function disconnects with the music database and shutdown the efreet mime libary. - * - * @return This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.\n - * Please refer 'audio-svc-types.h' to know the exact meaning of the error. - * @see audio_svc_open - * @pre music database already is opened. - * @post None - * @remark memory free before you call this function to close database. - * @par example - * @code - -#include - -void close_music_db() -{ - int ret = AUDIO_SVC_ERROR_NONE; - // close music database - ret = audio_svc_close(); - // close failed - if (ret < 0) - { - printf( "unable to close music db. error code->%d", ret); - return; - } - - return; -} - - * @endcode - */ -int audio_svc_close(void); - -int audio_svc_open(void) -{ - int err = -1; - int tid = -1; - - audio_svc_debug(""); - - err = _media_info_init_handle_tbl(); - if (err < 0) { - audio_svc_debug("Error:_media_info_init_handle_tbl\n"); - return AUDIO_SVC_ERROR_DB_CONNECT; - } - - tid = _media_info_get_thread_id(); - audio_svc_debug("Current thread id : %d", tid); - - HandleTable *handle_table = NULL; - handle_table = _media_info_search_handle(tid); - - if (handle_table == NULL) { - audio_svc_debug("A handle in thread [%d] does not exist. So now trying to make connection"); - int *key_tid = NULL; - - err = _media_info_insert_handle(&key_tid, tid, &handle_table); - if (err < 0) { - audio_svc_error("Fail to insert handle"); - if (key_tid) g_free(key_tid); - if (handle_table) g_free(handle_table); - return AUDIO_SVC_ERROR_DB_CONNECT; - } - - sqlite3 *handle = NULL; - - if (db_util_open(MEDIA_INFO_DATABASE_NAME, &handle, DB_UTIL_REGISTER_HOOK_METHOD) != SQLITE_OK) { - audio_svc_error("Unable to open database"); - if (handle) audio_svc_error("[sqlite] %s\n", sqlite3_errmsg(handle)); - if (key_tid) g_free(key_tid); - if (handle_table) g_free(handle_table); - return AUDIO_SVC_ERROR_DB_CONNECT; - } - - handle_table->handle = handle; - - /* Register Busy handler */ - err = sqlite3_busy_handler(handle, _audio_svc_sql_busy_handler, NULL); - if (SQLITE_OK != err) { - audio_svc_error("Fail to register busy handler\n"); - if (handle) audio_svc_error("[sqlite] %s\n", sqlite3_errmsg(handle)); - - db_util_close(handle); - handle = NULL; - - return AUDIO_SVC_ERROR_DB_CONNECT; - } - - } else { - audio_svc_debug("A handle in thread [%d] exists. "); - _media_info_atomic_add_counting(handle_table); - } - - audio_svc_debug("audio_svc_open succeed"); - return AUDIO_SVC_ERROR_NONE; -} - -int audio_svc_close(void) -{ - int ret = AUDIO_SVC_ERROR_NONE; - int err = -1; - int tid = -1; - audio_svc_debug(""); - - tid = _media_info_get_thread_id(); - audio_svc_debug("Current thread id : %d", tid); - - HandleTable *handle_table = NULL; - handle_table = _media_info_search_handle(tid); - - if (handle_table == NULL) { - audio_svc_error("handle_table is NULL"); - return AUDIO_SVC_ERROR_DB_DISCONNECT; - } else { - audio_svc_debug("ref count in thread[%d] is %d", tid, handle_table->ref_cnt); - - if (handle_table->ref_cnt > 1) { - _media_info_atomic_sub_counting(handle_table); - } else { - if (db_util_close(handle_table->handle) != SQLITE_OK) { - audio_svc_error("error closing database: %s\n", sqlite3_errmsg(handle_table->handle)); - ret = AUDIO_SVC_ERROR_DB_DISCONNECT; - } - - err = _media_info_remove_handle(tid); - if (err < 0) { - audio_svc_error - ("Error:_media_info_remove_handle\n"); - return AUDIO_SVC_ERROR_DB_DISCONNECT; - } - - _media_info_finalize_handle_tbl(); - } - } - - audio_svc_debug("audio_svc_close succeed"); - return ret; -} -#endif int audio_svc_create_table(MediaSvcHandle *handle) { int ret = AUDIO_SVC_ERROR_NONE; @@ -278,11 +100,6 @@ int audio_svc_delete_all(MediaSvcHandle *handle, audio_svc_storage_type_e storag ret = _audio_svc_delete_folder(db_handle, storage_type, NULL); audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret); -#if 0 - ret = _audio_svc_check_and_update_albums_table(NULL); - audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret); -#endif - return AUDIO_SVC_ERROR_NONE; } @@ -521,16 +338,6 @@ int audio_svc_delete_item_by_path(MediaSvcHandle *handle, const char *path) ret = _audio_svc_check_and_update_folder_table(db_handle, path); audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret); -#if 0 - ret = _audio_svc_check_and_update_albums_table(item.audio.album); - audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret); -#endif -#if 0 - if (strlen(item.thumbname) > 0) { - ret = _audio_svc_check_and_remove_thumbnail(item.thumbname); - audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret); - } -#endif if (strlen(item.thumbname) > 0) { if (_audio_svc_remove_file(item.thumbname) == FALSE) { audio_svc_error("fail to remove thumbnail file."); @@ -1427,11 +1234,6 @@ int audio_svc_delete_invalid_items(MediaSvcHandle *handle, audio_svc_storage_typ ret = _audio_svc_update_folder_table(db_handle); audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret); -#if 0 - ret = _audio_svc_check_and_update_albums_table(NULL); - audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret); -#endif - return AUDIO_SVC_ERROR_NONE; } @@ -1496,11 +1298,6 @@ int audio_svc_set_item_valid(MediaSvcHandle *handle, const char *path, int valid return AUDIO_SVC_ERROR_INVALID_PARAMETER; } -#if 0 //original code - return _audio_svc_update_valid_in_music_record(path, valid); - -#else //stack up querys and commit it at once when query counts are same as g_audio_svc_item_valid_data_cnt - audio_svc_debug("g_audio_svc_item_valid_data_cnt =[%d], g_audio_svc_item_valid_cur_data_cnt =[%d]", g_audio_svc_item_valid_data_cnt , g_audio_svc_item_valid_cur_data_cnt ); @@ -1530,7 +1327,6 @@ int audio_svc_set_item_valid(MediaSvcHandle *handle, const char *path, int valid } return AUDIO_SVC_ERROR_NONE; -#endif } int audio_svc_get_path_by_audio_id(MediaSvcHandle *handle, const char *audio_id, char *path, diff --git a/src/common/media-svc-util.c b/src/common/media-svc-util.c index d9e1d49..006f837 100755 --- a/src/common/media-svc-util.c +++ b/src/common/media-svc-util.c @@ -19,150 +19,8 @@ * */ -#if 0 -#include -#include -#include -#include - -#include "media-svc-util.h" -#include "media-svc-error.h" -#include "media-svc-debug.h" -#include "media-svc.h" -#include "audio-svc.h" -#include "audio-svc-error.h" -#endif #include "uuid.h" -#if 0 -static GHashTable *g_handle_table = NULL; -pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; - -int _media_info_get_thread_id() -{ - return syscall(__NR_gettid); -} - -int _media_info_init_handle_tbl() -{ - pthread_mutex_lock(&mutex); - - if (g_handle_table == NULL) - g_handle_table = g_hash_table_new(g_int_hash, g_int_equal); - - pthread_mutex_unlock(&mutex); - - if (g_handle_table == NULL) - return -1; - else - return 0; -} - -int _media_info_finalize_handle_tbl() -{ - pthread_mutex_lock(&mutex); - - if (g_handle_table != NULL) { - int size = g_hash_table_size(g_handle_table); - if (size == 0) { - g_hash_table_destroy(g_handle_table); - g_handle_table = NULL; - } else - mediainfo_dbg("handle table is not empty"); - } - - pthread_mutex_unlock(&mutex); - - return 0; -} - -int -_media_info_insert_handle(int **tid_key, int tid, HandleTable ** handle_table) -{ - *tid_key = g_malloc(sizeof **tid_key); - **tid_key = tid; - *handle_table = g_malloc(sizeof **handle_table); - - pthread_mutex_lock(&mutex); - - g_hash_table_insert(g_handle_table, (gpointer) * tid_key, - (gpointer) * handle_table); - - (*handle_table)->ref_cnt = 1; - - pthread_mutex_unlock(&mutex); - - return 0; -} - -int _media_info_remove_handle(int tid) -{ - int *key = NULL; - HandleTable *val = NULL; - - pthread_mutex_lock(&mutex); - - if (!g_hash_table_lookup_extended - (g_handle_table, &tid, (gpointer) & key, (gpointer) & val)) { - pthread_mutex_unlock(&mutex); - return -1; - } else { - if (g_hash_table_remove(g_handle_table, (gpointer) & tid)) - mediainfo_dbg("g_hash_table_remove done"); - else - mediainfo_dbg("g_hash_table_remove fails"); - - if (key) - g_free(key); - if (val) - g_free(val); - - pthread_mutex_unlock(&mutex); - return 0; - } -} - -HandleTable *_media_info_search_handle(int tid) -{ - pthread_mutex_lock(&mutex); - - HandleTable *value = - (HandleTable *) g_hash_table_lookup(g_handle_table, - (gpointer) & tid); - - pthread_mutex_unlock(&mutex); - - return value; -} - -sqlite3 *_media_info_get_proper_handle() -{ - int tid = _media_info_get_thread_id(); - HandleTable *value = - (HandleTable *) g_hash_table_lookup(g_handle_table, - (gpointer) & tid); - - if (value == NULL) { - return NULL; - } else { - return value->handle; - } -} -void _media_info_atomic_add_counting(HandleTable *handle_table) -{ - pthread_mutex_lock(&mutex); - handle_table->ref_cnt++; - pthread_mutex_unlock(&mutex); -} - - -void _media_info_atomic_sub_counting(HandleTable *handle_table) -{ - pthread_mutex_lock(&mutex); - handle_table->ref_cnt--; - pthread_mutex_unlock(&mutex); -} -#endif char *_media_info_generate_uuid(void) { uuid_t uuid_value; diff --git a/src/include/common/media-svc-util.h b/src/include/common/media-svc-util.h index ecafcb9..88bd774 100755 --- a/src/include/common/media-svc-util.h +++ b/src/include/common/media-svc-util.h @@ -28,42 +28,6 @@ extern "C" { #endif -#if 0 -typedef struct _handle_table { - int ref_cnt; - sqlite3* handle; -} HandleTable; - - -int -_media_info_get_thread_id(); - -/* To manage handles in each trhead, use GHashTable */ -int -_media_info_init_handle_tbl(); - -int -_media_info_finalize_handle_tbl(); - -int -_media_info_insert_handle(int** tid_key, int tid, HandleTable** handle_table); - -int -_media_info_remove_handle(int tid); - -HandleTable* -_media_info_search_handle(int tid); - -sqlite3* -_media_info_get_proper_handle(); - -void -_media_info_atomic_add_counting(HandleTable *handle_table); - -void -_media_info_atomic_sub_counting(HandleTable *handle_table); -#endif - char *_media_info_generate_uuid(void); #ifdef __cplusplus diff --git a/src/visual/media-svc-api.c b/src/visual/media-svc-api.c index 4197f9c..5c96c09 100755 --- a/src/visual/media-svc-api.c +++ b/src/visual/media-svc-api.c @@ -1768,108 +1768,6 @@ int mb_svc_update_cluster_name(MediaSvcHandle *mb_svc_handle, const char *cluste return 0; } -#if 0 -EXPORT_API int mb_svc_initialize() -{ - int err = -1; - int tid = -1; - mb_svc_debug("mb_svc_initialize-----------enter\n"); - - g_type_init(); - - err = _media_info_init_handle_tbl(); - if (err < 0) { - mb_svc_debug("Error:_media_info_init_handle_tbl\n"); - return MB_SVC_ERROR_DB_CONNECT; - } - - tid = _media_info_get_thread_id(); - mb_svc_debug("Current thread id : %d", tid); - - HandleTable *handle_table = NULL; - handle_table = _media_info_search_handle(tid); - - if (handle_table == NULL) { - mb_svc_debug - ("A handle in thread [%d] does not exist. So now trying to make connection"); - int *key_tid = NULL; - - err = _media_info_insert_handle(&key_tid, tid, &handle_table); - if (err < 0) { - mb_svc_debug("A handle in thread [%d] exists. ", tid); - if (key_tid) - g_free(key_tid); - if (handle_table) - g_free(handle_table); - return 0; - } - - sqlite3 *handle = NULL; - err = mb_svc_connect_db(&handle); - if (err < 0 || handle == NULL) { - mb_svc_debug("Error:failed to initialize DB\n"); - if (key_tid) - g_free(key_tid); - if (handle_table) - g_free(handle_table); - return MB_SVC_ERROR_DB_CONNECT; - } - - handle_table->handle = handle; - } else { - mb_svc_debug("A handle in thread [%d] exists. ", tid); - _media_info_atomic_add_counting(handle_table); - } - - mb_svc_debug("mb_svc_initialize-----------leave\n"); - return 0; -} - -EXPORT_API int mb_svc_finalize() -{ - int ret = 0; - int err = -1; - int tid = -1; - mb_svc_debug("mb_svc_finalize-----------enter\n"); - - tid = _media_info_get_thread_id(); - mb_svc_debug("Current thread id : %d", tid); - - HandleTable *handle_table = NULL; - handle_table = _media_info_search_handle(tid); - - if (handle_table == NULL) { - mb_svc_debug("handle_table is NULL"); - return MB_SVC_ERROR_DB_DISCONNECT; - } else { - mb_svc_debug("ref count in thread[%d] is %d", tid, - handle_table->ref_cnt); - - if (handle_table->ref_cnt > 1) { - _media_info_atomic_sub_counting(handle_table); - } else { - - err = mb_svc_disconnect_db(handle_table->handle); - if (err < 0) { - mb_svc_debug("Error:mb_svc_disconnect_db\n"); - ret = MB_SVC_ERROR_DB_DISCONNECT; - } - - err = _media_info_remove_handle(tid); - if (err < 0) { - mb_svc_debug - ("Error:_media_info_remove_handle\n"); - return MB_SVC_ERROR_DB_DISCONNECT; - } - - _media_info_finalize_handle_tbl(); - - } - } - - return ret; -} -#endif /* clock_t */ long mb_svc_get_clock(void) { diff --git a/src/visual/media-svc-db.c b/src/visual/media-svc-db.c index dbc5663..dc394e5 100755 --- a/src/visual/media-svc-db.c +++ b/src/visual/media-svc-db.c @@ -383,101 +383,10 @@ int field_num_max[MB_SVC_TABLE_CNT_MAX] = { MB_SVC_BOOKMARK_NUM, static __thread GList *g_sql_list = NULL; static __thread char g_last_updated_folder_uuid[MB_SVC_UUID_LEN_MAX + 1] = {0,}; -#if 0 -static int __mb_svc_create_tbl(bool external); -static int __mb_svc_drop_tbl(void); -#endif static int __mb_svc_delete_record(MediaSvcHandle *mb_svc_handle, int id, mb_svc_tbl_name_e tbl_name); static int __mb_svc_delete_record_by_uuid(MediaSvcHandle *mb_svc_handle, const char *id, mb_svc_tbl_name_e tbl_name); static int __mb_svc_db_get_next_id(MediaSvcHandle *mb_svc_handle, int table_id); -#if 0 -static int __mb_svc_create_tbl(bool external) -{ - int err = -1; - char table_name[MB_SVC_TABLE_NAME_MAX_LEN] = { 0, }; - char *primary_key = NULL; - int i, j; - mb_svc_tbl_field_s *mb_svc_field = NULL; - int field_count = 0; - GString *query_string = - g_string_sized_new(MB_SVC_DEFAULT_QUERY_SIZE + 1); - mb_svc_debug("__mb_svc_create_tbl--enter\n"); - - for (i = 0; i < MB_SVC_TABLE_CNT_MAX; ++i) { - field_count = field_num_max[i]; - memset(table_name, 0x00, MB_SVC_TABLE_NAME_MAX_LEN); - - snprintf(table_name, MB_SVC_TABLE_NAME_MAX_LEN, "%s", - mb_svc_tbl[i].table_name); - - mb_svc_field = mb_svc_tbl[i].mb_svc_field; - primary_key = mb_svc_tbl[i].primary_key; - - err = _mb_svc_table_exist(table_name); - if (err > 0) { - continue; - } - g_string_printf(query_string, "CREATE TABLE %s(", table_name); - - for (j = 0; j < field_count; ++j) { - if (j != 0) { - g_string_append(query_string, ", "); - } - g_string_append_printf(query_string, "%s %s", - mb_svc_field[j].field_name, - mb_svc_field[j].field_type); - } - - g_string_append(query_string, primary_key); - g_string_append(query_string, " );"); - - err = mb_svc_query_sql_gstring(query_string); - if (err < 0) { - mb_svc_debug("failed to create table\n"); - mb_svc_debug("query string is %s\n", query_string->str); - - g_string_free(query_string, TRUE); - return MB_SVC_ERROR_DB_INTERNAL; - } - } - - g_string_free(query_string, TRUE); - - mb_svc_debug("__mb_svc_create_tbl--leave\n"); - return 0; -} - -static int __mb_svc_drop_tbl(void) -{ - char query_string[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 }; - int i, err; - char *table_name; - mb_svc_debug("__mb_svc_drop_tbl--enter\n"); - - for (i = 0; i < MB_SVC_TABLE_CNT_MAX; ++i) { - table_name = mb_svc_tbl[i].table_name; - if (table_name == NULL) { - mb_svc_debug("table_name is null\n"); - return MB_SVC_ERROR_INVALID_PARAMETER; - } - err = _mb_svc_table_exist(table_name); - if (err > 0) { - snprintf(query_string, sizeof(query_string), - MB_SVC_TABLE_DROP_QUERY_STRING, table_name); - err = mb_svc_query_sql(query_string); - if (err < 0) { - mb_svc_debug("drop failed\n"); - mb_svc_debug("query string is %s\n", - query_string); - return MB_SVC_ERROR_DB_INTERNAL; - } - } - } - mb_svc_debug("__mb_svc_drop_tbl--leave\n"); - return 0; -} -#endif int mb_svc_set_folder_as_valid_sql_add(const char *folder_id, int valid) { @@ -567,71 +476,6 @@ int mb_svc_set_item_as_valid(MediaSvcHandle *mb_svc_handle) return 0; } -#if 0 -static int mb_svc_busy_handler(void *pData, int count) -{ - usleep(50000); - printf("mb_svc_busy_handler called : %d\n", count); - mb_svc_debug("mb_svc_busy_handler called : %d\n", count); - - return 100 - count; -} - -/* connect to database-server */ -int mb_svc_connect_db(sqlite3 **handle) -{ - mb_svc_debug("mb_svc_connect_db\n"); - int ret = 0; - - ret = - db_util_open(MEDIA_INFO_DATABASE_NAME, handle, - DB_UTIL_REGISTER_HOOK_METHOD); - if (SQLITE_OK != ret) { - mb_svc_debug("can not connect to db-server\n"); - if (*handle) mb_svc_debug("[sqlite] %s\n", sqlite3_errmsg(*handle)); - - *handle = NULL; - - return MB_SVC_ERROR_DB_CONNECT; - } - - /* Register Busy handler */ - ret = sqlite3_busy_handler(*handle, mb_svc_busy_handler, NULL); - if (SQLITE_OK != ret) { - mb_svc_debug("Fail to register busy handler\n"); - if (*handle) mb_svc_debug("[sqlite] %s\n", sqlite3_errmsg(*handle)); - - db_util_close(*handle); - *handle = NULL; - - return MB_SVC_ERROR_DB_CONNECT; - } - - mb_svc_debug("connected to db-server\n"); - - return 0; -} - -/* disconnect from database-server */ -int mb_svc_disconnect_db(sqlite3 *handle) -{ - /* disconnect from database-server */ - int ret = 0; - - ret = db_util_close(handle); - - if (SQLITE_OK != ret) { - mb_svc_debug("can not disconnect database\n"); - mb_svc_debug("[sqlite] %s\n", sqlite3_errmsg(handle)); - - return MB_SVC_ERROR_DB_DISCONNECT; - } - handle = NULL; - - mb_svc_debug("Disconnected successfully\n"); - return 0; -} -#endif mb_svc_tbl_s *mb_svc_search_matched_svc_tbl(mb_svc_tbl_name_e tbl_name) { int i; diff --git a/src/visual/minfo-api.c b/src/visual/minfo-api.c index 6697788..e2abae2 100755 --- a/src/visual/minfo-api.c +++ b/src/visual/minfo-api.c @@ -44,20 +44,6 @@ static __thread int g_cur_trans_insert_cnt = 0; static __thread int g_trans_move_cnt = 1; static __thread int g_cur_trans_move_cnt = 0; -#if 0 -EXPORT_API int minfo_init(void) -{ - mb_svc_debug(""); - return mb_svc_initialize(); -} - -EXPORT_API int minfo_finalize(void) -{ - mb_svc_debug(""); - return mb_svc_finalize(); -} -#endif - EXPORT_API int minfo_get_item_list(MediaSvcHandle *mb_svc_handle, const char *cluster_id, diff --git a/test/audio/audio_svc_test.c b/test/audio/audio_svc_test.c index 9a3b038..de58d7b 100755 --- a/test/audio/audio_svc_test.c +++ b/test/audio/audio_svc_test.c @@ -26,7 +26,7 @@ #include #include -void insert_into_db(const char * dir_path); +void insert_into_db(MediaSvcHandle * db_handle, const char * dir_path); void msg_print(int line, char *msg); int main() @@ -62,7 +62,7 @@ int main() msg_print(__LINE__, "error to delete all items on phone"); return -1; } - //insert_into_db("/opt/media/Sounds/Music"); + //insert_into_db(db_handle, "/opt/media/Sounds/Music"); #endif //iterate all tracks and get the info of tracks ================================================== msg_print(__LINE__, "iterate all tracks"); @@ -608,7 +608,7 @@ int main() } -void insert_into_db(const char * dir_path) +void insert_into_db(MediaSvcHandle * db_handle, const char * dir_path) { int audio_id = 300; char thumb_path[AUDIO_SVC_PATHNAME_SIZE+1] = {0}; @@ -626,12 +626,11 @@ void insert_into_db(const char * dir_path) fprintf(stderr,"[file path] : %s\n", fpath); - #if 0 - int ret = audio_svc_insert_item(AUDIO_SVC_STORAGE_PHONE, fpath, AUDIO_SVC_CATEGORY_MUSIC); + int ret = audio_svc_insert_item(db_handle, AUDIO_SVC_STORAGE_PHONE, fpath, AUDIO_SVC_CATEGORY_MUSIC); if (ret != AUDIO_SVC_ERROR_NONE) { fprintf(stderr,"[error to insert music] : %s\n", fpath); } - #endif + audio_id++; }