summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMinje Ahn <minje.ahn@samsung.com>2015-10-13 01:19:41 (GMT)
committerMinje Ahn <minje.ahn@samsung.com>2015-10-13 01:51:23 (GMT)
commite646e3b166173167a94b319b0a9889b22a55f2e7 (patch)
tree76ced7ed64ed9af47a2596074feebc1625614744 /src
parente787f69ce984b7b225c291ebe81664530a8284c9 (diff)
downloadlibmedia-thumbnail-e646e3b166173167a94b319b0a9889b22a55f2e7.zip
libmedia-thumbnail-e646e3b166173167a94b319b0a9889b22a55f2e7.tar.gz
libmedia-thumbnail-e646e3b166173167a94b319b0a9889b22a55f2e7.tar.bz2
Change-Id: I9bb372674a3fe257278b4867db0153d29b6a16da Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
Diffstat (limited to 'src')
-rwxr-xr-xsrc/ipc/media-thumb-ipc.c7
-rwxr-xr-xsrc/media-thumbnail.c8
-rwxr-xr-xsrc/util/media-thumb-db.c69
3 files changed, 18 insertions, 66 deletions
diff --git a/src/ipc/media-thumb-ipc.c b/src/ipc/media-thumb-ipc.c
index bf9e568..76e7d0a 100755
--- a/src/ipc/media-thumb-ipc.c
+++ b/src/ipc/media-thumb-ipc.c
@@ -32,6 +32,7 @@
#include <pwd.h>
#define THUMB_SOCK_BLOCK_SIZE 512
+#define THUMB_IPC_PATH "/var/run/media-server/media_ipc_thumbcreator.socket"
static GQueue *g_request_queue = NULL;
static GQueue *g_manage_queue = NULL;
@@ -513,7 +514,7 @@ _media_thumb_request(int msg_type, const char *origin_path, char *thumb_path, in
memset(&serv_addr, 0, sizeof(serv_addr));
sock = sock_info.sock_fd;
serv_addr.sun_family = AF_UNIX;
- strcpy(serv_addr.sun_path, "/var/run/media-server/media_ipc_thumbcreator.socket");
+ strncpy(serv_addr.sun_path, THUMB_IPC_PATH, strlen(THUMB_IPC_PATH));
/* Connecting to the thumbnail server */
if (connect(sock, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) {
@@ -752,7 +753,7 @@ int _media_thumb_send_request() {
memset(&serv_addr, 0, sizeof(serv_addr));
sock = sock_info.sock_fd;
serv_addr.sun_family = AF_UNIX;
- strcpy(serv_addr.sun_path, "/var/run/media-server/media_ipc_thumbcreator.socket");
+ strncpy(serv_addr.sun_path, THUMB_IPC_PATH, strlen(THUMB_IPC_PATH));
GIOChannel *channel = NULL;
channel = g_io_channel_unix_new(sock);
@@ -855,7 +856,7 @@ int _media_thumb_raw_data_send_request() {
memset(&serv_addr, 0, sizeof(serv_addr));
sock = sock_info.sock_fd;
serv_addr.sun_family = AF_UNIX;
- strcpy(serv_addr.sun_path, "/var/run/media-server/media_ipc_thumbcreator.socket");
+ strncpy(serv_addr.sun_path, THUMB_IPC_PATH, strlen(THUMB_IPC_PATH));
GIOChannel *channel = NULL;
channel = g_io_channel_unix_new(sock);
diff --git a/src/media-thumbnail.c b/src/media-thumbnail.c
index dd16356..0920eec 100755
--- a/src/media-thumbnail.c
+++ b/src/media-thumbnail.c
@@ -121,6 +121,10 @@ int thumbnail_request_from_db_async(const char *origin_path, ThumbFunc func, voi
thumb_dbg_slog("Path : %s", origin_path);
thumbUserData *userData = (thumbUserData*)malloc(sizeof(thumbUserData));
+ if (userData == NULL) {
+ thumb_err("memory allocation failed");
+ return MS_MEDIA_ERR_OUT_OF_MEMORY;
+ }
userData->func = (ThumbFunc)func;
userData->user_data = user_data;
@@ -152,6 +156,10 @@ int thumbnail_request_extract_raw_data_async(int request_id, const char *origin_
thumb_dbg_slog("Path : %s", origin_path);
thumbRawUserData *userData = (thumbRawUserData*)malloc(sizeof(thumbRawUserData));
+ if(userData == NULL) {
+ thumb_err("userData malloc failed : %d", err);
+ return MS_MEDIA_ERR_OUT_OF_MEMORY;
+ }
userData->func = func;
userData->user_data = user_data;
diff --git a/src/util/media-thumb-db.c b/src/util/media-thumb-db.c
index 8e77b95..06f028a 100755
--- a/src/util/media-thumb-db.c
+++ b/src/util/media-thumb-db.c
@@ -26,75 +26,23 @@
#include <glib.h>
#include <string.h>
#include <unistd.h>
-#include <util-func.h>
static __thread MediaDBHandle *db_handle;
-static int _media_thumb_busy_handler(void *pData, int count)
-{
- usleep(50000);
- thumb_dbg("_media_thumb_busy_handler called : %d\n", count);
-
- return 100 - count;
-}
-
sqlite3 *_media_thumb_db_get_handle()
{
return db_handle;
}
-int _media_thumb_sqlite_connect(sqlite3 **handle)
-{
- int err = MS_MEDIA_ERR_NONE;
-
- err = db_util_open(MEDIA_DATABASE_NAME, handle,
- DB_UTIL_REGISTER_HOOK_METHOD);
-
- if (SQLITE_OK != err) {
- *handle = NULL;
- return MS_MEDIA_ERR_INVALID_PARAMETER;
- }
-
- /*Register busy handler*/
- if (*handle) {
- err = sqlite3_busy_handler(*handle, _media_thumb_busy_handler, NULL);
- if (SQLITE_OK != err) {
- if (*handle) {
- thumb_err("[sqlite] %s\n", sqlite3_errmsg(*handle));
- db_util_close(*handle);
- }
- *handle = NULL;
-
- return MS_MEDIA_ERR_INVALID_PARAMETER;
- }
- } else {
- *handle = NULL;
- return MS_MEDIA_ERR_INVALID_PARAMETER;
- }
-
- return MS_MEDIA_ERR_NONE;
-}
-
-int _media_thumb_sqlite_disconnect(sqlite3 *handle)
-{
- int err = MS_MEDIA_ERR_NONE;
- if (handle != NULL) {
- err = db_util_close(handle);
-
- if (SQLITE_OK != err) {
- handle = NULL;
- return MS_MEDIA_ERR_INVALID_PARAMETER;
- }
- }
-
- return MS_MEDIA_ERR_NONE;
-}
-
-int
-_media_thumb_get_type_from_db(sqlite3 *handle,
+int _media_thumb_get_type_from_db(sqlite3 *handle,
const char *origin_path,
int *type)
{
+ int err = MS_MEDIA_ERR_NONE;
+ char *path_string = NULL;
+ char *query_string = NULL;
+ sqlite3_stmt *stmt = NULL;
+
thumb_dbg_slog("Origin path : %s", origin_path);
if (handle == NULL) {
@@ -102,11 +50,6 @@ _media_thumb_get_type_from_db(sqlite3 *handle,
return MS_MEDIA_ERR_INVALID_PARAMETER;
}
- int err = -1;
- char *path_string = NULL;
- char *query_string = NULL;
- sqlite3_stmt *stmt = NULL;
-
path_string = sqlite3_mprintf("%s", origin_path);
query_string = sqlite3_mprintf(SELECT_TYPE_BY_PATH, path_string);