From: Eunhae Choi Date: Thu, 10 Mar 2016 00:38:31 +0000 (+0900) Subject: use tbm_bo to get albumart data X-Git-Tag: submit/tizen/20160310.024054^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=67ecfb4474ccd7c595bb0b9c2e3e3a4ebf1ba352;p=platform%2Fcore%2Fapi%2Fplayer.git use tbm_bo to get albumart data Change-Id: I1d4b9cabad1400e92ca03589113d35a520d0fb29 Signed-off-by: Eunhae Choi --- diff --git a/src/player.c b/src/player.c index 90d775c..a71fc67 100644 --- a/src/player.c +++ b/src/player.c @@ -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; } diff --git a/test/player_test.c b/test/player_test.c index 2ce8c92..9f48f04 100644 --- a/test/player_test.c +++ b/test/player_test.c @@ -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;