int media_content_disconnect(void)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
-
g_mutex_lock(&db_mutex);
media_content_debug("ref count : %d", ref_count);
- if (ref_count > 0) {
- if (db_handle != NULL) {
- ref_count--;
- } else {
- media_content_error("Wrong DB Handle status");
- ret = MEDIA_CONTENT_ERROR_DB_FAILED;
+
+ if (db_handle && ref_count > 0) {
+ if (--ref_count == 0) {
+ media_db_disconnect(db_handle);
+ db_handle = NULL;
}
} else {
- media_content_error("DB_FAILED(0x%08x) database is not connected", MEDIA_CONTENT_ERROR_DB_FAILED);
+ media_content_error("Database is not connected");
g_mutex_unlock(&db_mutex);
return MEDIA_CONTENT_ERROR_DB_FAILED;
}
- if (ref_count == 0) {
- if (db_handle != NULL) {
- ret = media_db_disconnect(db_handle);
- ret = _content_error_capi(ret);
- if (ret == MEDIA_CONTENT_ERROR_NONE) {
- db_handle = NULL;
- } else {
- media_content_error("database disconnect fail");
- ref_count++;
- }
- } else {
- media_content_error("Wrong DB Handle status");
- ret = MEDIA_CONTENT_ERROR_DB_FAILED;
- }
-
- g_mutex_unlock(&db_mutex);
-
- media_content_info("ref count changed to: %d", ref_count);
-
- return ret;
- }
-
g_mutex_unlock(&db_mutex);
media_content_info("ref count changed to: %d", ref_count);
- return ret;
+ return MEDIA_CONTENT_ERROR_NONE;
}
int media_content_scan_file(const char *path)