#include <memory.h>
#include <unistd.h>
#include <pthread.h>
-#include <stdio.h>
-#include <sys/types.h>
#include <fcntl.h>
#include <vconf.h>
-#include <sys/stat.h>
-#include <errno.h>
-
#include <semaphore.h>
-#include <errno.h>
-#include <mm_types.h>
#include <mm_error.h>
-#include <mm_message.h>
#include <mm_debug.h>
-#include <mm_sound.h>
-#include <mm_sound_private.h>
#define KEYTONE_PATH "/tmp/keytone" /* Keytone pipe path */
#define FILE_FULL_PATH 1024 /* File path lenth */
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-1); \
- 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)
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;
}
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);
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)
/* 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;
/* 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;
}
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;
}