X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=mm_sound_bootsound.c;h=0924a250f4b11079d671846c24ea3d9e1c43fac8;hb=7fce6f2d6d480b3bd0e84a5ba3f72173a37e36db;hp=043edee6efde2efccd76b5f3b063b0eb893ca574;hpb=a06bc3beb6eb3e30d7f51c07fda097dd6be1b458;p=platform%2Fcore%2Fmultimedia%2Flibmm-sound.git diff --git a/mm_sound_bootsound.c b/mm_sound_bootsound.c index 043edee..0924a25 100644 --- a/mm_sound_bootsound.c +++ b/mm_sound_bootsound.c @@ -23,23 +23,13 @@ #include #include #include -#include -#include #include #include -#include -#include - #include -#include -#include #include -#include #include -#include -#include #define KEYTONE_PATH "/tmp/keytone" /* Keytone pipe path */ #define FILE_FULL_PATH 1024 /* File path lenth */ @@ -55,21 +45,21 @@ typedef struct { char volume_gain_type[VOLUME_GAIN_TYPE_LEN]; } ipc_t; -#define MMSOUND_STRNCPY(dst,src,size)\ +#define MMSOUND_STRNCPY(dst, src, size) \ do { \ - if(src != NULL && dst != NULL && size > 0) {\ - strncpy(dst,src,size); \ - dst[size-1] = '\0';\ - } else if(dst == NULL) { \ - debug_error("STRNCPY ERROR: Destination String is NULL\n"); \ - } \ - else if(size <= 0) { \ - debug_error("STRNCPY ERROR: Destination String is NULL\n"); \ - } \ - else { \ - debug_error("STRNCPY ERROR: Destination String is NULL\n"); \ - } \ -} while(0) + if (src != NULL && dst != NULL && size > 0) { \ + strncpy(dst, src, size - 1); \ + dst[size - 1] = '\0'; \ + } else if (dst == NULL) { \ + debug_error("STRNCPY ERROR: Destination String is NULL"); \ + } \ + else if (size <= 0) { \ + debug_error("STRNCPY ERROR: Destination String is NULL"); \ + } \ + else { \ + debug_error("STRNCPY ERROR: Destination String is NULL"); \ + } \ +} while (0) EXPORT_API int mm_sound_boot_ready(int timeout_sec) @@ -78,8 +68,8 @@ int mm_sound_boot_ready(int timeout_sec) sem_t* sem = NULL; debug_msg("[BOOT] check for sync...."); - if ((sem = sem_open ("booting-sound", O_CREAT, 0660, 0))== SEM_FAILED) { - debug_error ("error creating sem : %d", errno); + if ((sem = sem_open("booting-sound", O_CREAT, 0660, 0)) == SEM_FAILED) { + debug_error("error creating sem : %d", errno); return -1; } @@ -89,7 +79,7 @@ int mm_sound_boot_ready(int timeout_sec) if (sem_timedwait(sem, &ts) == -1) { if (errno == ETIMEDOUT) - debug_warning("[BOOT] timeout!\n"); + debug_warning("[BOOT] timeout!"); } else { debug_msg("[BOOT] ready wait success!!!!"); sem_post(sem); @@ -104,7 +94,7 @@ int mm_sound_boot_play_sound(char* path) int err = 0; int fd = -1; int size = 0; - ipc_t data = {{0,},{0,},{0,}}; + ipc_t data = { { 0, }, { 0, }, { 0, } }; debug_msg("[BOOT] play boot sound [%s]!!!!", path); if (path == NULL) @@ -113,7 +103,9 @@ int mm_sound_boot_play_sound(char* path) /* Check whether file exists */ fd = open(path, O_RDONLY); if (fd == -1) { - debug_error("file open failed with [%s][%d]\n", strerror(errno), errno); + char str_error[256]; + strerror_r(errno, str_error, sizeof(str_error)); + debug_error("file open failed with [%s][%d]", str_error, errno); switch (errno) { case ENOENT: return MM_ERROR_SOUND_FILE_NOT_FOUND; @@ -127,7 +119,7 @@ int mm_sound_boot_play_sound(char* path) /* Open PIPE */ fd = open(KEYTONE_PATH, O_WRONLY | O_NONBLOCK); if (fd == -1) { - debug_error("Fail to open pipe\n"); + debug_error("Fail to open pipe"); return MM_ERROR_SOUND_FILE_NOT_FOUND; } @@ -135,13 +127,15 @@ int mm_sound_boot_play_sound(char* path) MMSOUND_STRNCPY(data.role, "system", ROLE_NAME_LEN); MMSOUND_STRNCPY(data.volume_gain_type, "booting", VOLUME_GAIN_TYPE_LEN); - debug_msg("filepath=[%s], role=[%s], volume_gain_type=[%s]\n", data.filename, data.role, data.volume_gain_type); + debug_msg("filepath=[%s], role=[%s], volume_gain_type=[%s]", data.filename, data.role, data.volume_gain_type); size = sizeof(ipc_t); /* Write to PIPE */ err = write(fd, &data, size); if (err < 0) { - debug_error("Fail to write data: [%s][%d]\n", strerror(errno), errno); + char str_error[256]; + strerror_r(errno, str_error, sizeof(str_error)); + debug_error("Fail to write data: [%s][%d]", str_error, errno); close(fd); return MM_ERROR_SOUND_INTERNAL; }