use tbm_bo to get albumart data 84/61684/2 accepted/tizen/common/20160311.201018 accepted/tizen/ivi/20160310.062559 accepted/tizen/mobile/20160310.062434 accepted/tizen/tv/20160310.062502 accepted/tizen/wearable/20160310.062529 submit/tizen/20160310.024054
authorEunhae Choi <eunhae1.choi@samsung.com>
Thu, 10 Mar 2016 00:38:31 +0000 (09:38 +0900)
committerEunhae Choi <eunhae1.choi@samsung.com>
Thu, 10 Mar 2016 00:39:45 +0000 (09:39 +0900)
Change-Id: I1d4b9cabad1400e92ca03589113d35a520d0fb29
Signed-off-by: Eunhae Choi <eunhae1.choi@samsung.com>
src/player.c
test/player_test.c

index 90d775c06dee0fa93be4afb69fc66a39bab88cd4..a71fc67088b8f670723127e159196ddc3faa2634 100644 (file)
@@ -2121,21 +2121,56 @@ int player_get_album_art(player_h player, void **palbum_art, int *psize)
        char *ret_buf = NULL;
        char *album_art;
        int size = 0;
+       tbm_bo bo;
+       tbm_bo_handle thandle;
+       tbm_key key;
 
        LOGD("ENTER");
 
        player_msg_send(api, pc, ret_buf, ret);
        if (ret == PLAYER_ERROR_NONE) {
                player_msg_get(size, ret_buf);
+               LOGD("size : %d", size);
                if (size > 0) {
+                       if (!player_msg_get(key, ret_buf)) {
+                               ret = PLAYER_ERROR_INVALID_OPERATION;
+                               goto exit;
+                       }
+
+                       bo = tbm_bo_import(pc->cb_info->bufmgr, key);
+                       if (bo == NULL) {
+                               LOGE("TBM get error : bo is NULL");
+                               ret = PLAYER_ERROR_INVALID_OPERATION;
+                               goto exit;
+                       }
+                       thandle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_WRITE | TBM_OPTION_READ);
+                       if (thandle.ptr == NULL) {
+                               LOGE("TBM get error : handle pointer is NULL");
+                               tbm_bo_unref(bo);
+                               ret = PLAYER_ERROR_INVALID_OPERATION;
+                               goto exit;
+                       }
                        album_art = _get_mem(pc, size);
-                       player_msg_get_array(album_art, ret_buf);
-                       *palbum_art = album_art;
+                       if (album_art) {
+                               memcpy(album_art, thandle.ptr, size);
+                               *palbum_art = album_art;
+                       } else {
+                               LOGE("g_new failure");
+                               ret = PLAYER_ERROR_INVALID_OPERATION;
+                       }
+
+                       /* mark to read */
+                       *((char *)thandle.ptr + size) = 0;
+
+                       tbm_bo_unmap(bo);
+                       tbm_bo_unref(bo);
                } else
                        *palbum_art = NULL;
 
                *psize = size;
        }
+exit:
+
        g_free(ret_buf);
        return ret;
 }
index 2ce8c92df7625e8e980a29f3a6635b2882d71394..9f48f047d4a79dbb272f2ab8261126a80b355d54 100644 (file)
@@ -574,7 +574,7 @@ static int _save(unsigned char *src, int length)
        char filename[256] = {0, };
        static int WRITE_COUNT = 0;
        /* gchar *filename  = CAPTUERD_IMAGE_SAVE_PATH; */
-       snprintf(filename, 256, "IMAGE_client%d", WRITE_COUNT);
+       snprintf(filename, 256, "/tmp/IMAGE_client%d", WRITE_COUNT);
        WRITE_COUNT++;
        fp = fopen(filename, "w+");
        if (fp == NULL) {
@@ -1314,6 +1314,7 @@ static void get_stream_info()
        int size;
        player_get_album_art(g_player[0], &album, &size);
        g_print("                                                            ==> [Player_Test] Album art : [ data : %p, size : %d ]\n", (unsigned int *)album, size);
+       _save(album, size);
        if (value != NULL) {
                free(value);
                value = NULL;