Merge "Block path replacement(temporary)" into tizen
[platform/core/api/media-content.git] / src / media_uhd.c
index a7b79ec..082f42c 100755 (executable)
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#ifdef _USE_TV_PROFILE
+#ifdef _USE_TVPD_MODE
 #include <media_info_private.h>
 #include <media_util_private.h>
 #include <media_uhd.h>
@@ -173,16 +173,13 @@ int media_uhd_get_uhd_from_db(const char *media_id, media_uhd_h *uhd)
 
        select_query = sqlite3_mprintf(SELECT_UHD_FROM_UHD, media_id);
 
-       ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
-       sqlite3_free(select_query);
+       ret = _content_get_result(select_query, &stmt);
+       SQLITE3_SAFE_FREE(select_query);
        media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
        media_uhd_s *_uhd = NULL;
 
-       while (sqlite3_step(stmt) == SQLITE_ROW) {
-               if (_uhd)
-                       media_uhd_destroy((media_uhd_h)_uhd);
-
+       if (sqlite3_step(stmt) == SQLITE_ROW) {
                _uhd = (media_uhd_s*)calloc(1, sizeof(media_uhd_s));
 
                if (_uhd == NULL) {
@@ -194,6 +191,9 @@ int media_uhd_get_uhd_from_db(const char *media_id, media_uhd_h *uhd)
                _media_uhd_item_get_detail(stmt, (media_uhd_h)_uhd);
 
                *uhd = (media_uhd_h)_uhd;
+       } else {
+               media_content_error("Nonexistent media id[%s]", media_id);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
        }
 
        SQLITE3_FINALIZE(stmt);