Add protection code for focus-callback creation
[platform/core/multimedia/libmm-sound.git] / mm_sound_keysound.c
index 5098722..2daa6e9 100644 (file)
 #include <stdlib.h>
 #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 <gio/gio.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>
 
 #include "include/mm_sound_common.h"
 
@@ -69,7 +61,7 @@ static int _mm_sound_play_keysound(const char *filename, int volume_config, ipc_
 
 static const char* convert_volume_type_to_role(int volume_type)
 {
-       debug_warning ("volume_type(%d)", volume_type);
+       debug_log("volume_type(%d)", volume_type);
        switch(volume_type) {
        case VOLUME_TYPE_MEDIA:
                return "media";
@@ -81,6 +73,8 @@ static const char* convert_volume_type_to_role(int volume_type)
                return "alarm";
        case VOLUME_TYPE_VOICE:
                return "voice";
+       case VOLUME_TYPE_RINGTONE:
+               return "ringtone-call";
        default:
                debug_warning ("not supported type(%d), we change it SYSTEM type forcibly" );
                return "system";
@@ -89,10 +83,10 @@ static const char* convert_volume_type_to_role(int volume_type)
 
 static const char* convert_volume_gain_type_to_string(int volume_gain_type)
 {
-       debug_warning ("volume_gain_type(0x%x)", volume_gain_type);
+       debug_log("volume_gain_type(0x%x)", volume_gain_type);
        switch(volume_gain_type) {
        case VOLUME_GAIN_DEFAULT:
-               return NULL;
+               return "";
        case VOLUME_GAIN_DIALER:
                return "dialer";
        case VOLUME_GAIN_TOUCH:
@@ -114,14 +108,14 @@ static const char* convert_volume_gain_type_to_string(int volume_gain_type)
        case VOLUME_GAIN_TTS:
                return "tts";
        default:
-               return NULL;
+               return "";
        }
 }
 
 EXPORT_API
 int mm_sound_play_keysound(const char *filename, int volume_config)
 {
-       return _mm_sound_play_keysound(filename, volume_config, IPC_TYPE_DBUS);
+       return _mm_sound_play_keysound(filename, volume_config, IPC_TYPE_PIPE);
 }
 
 static int _mm_sound_play_keysound(const char *filename, int volume_config, ipc_type_t ipc_type)
@@ -148,7 +142,9 @@ static int _mm_sound_play_keysound(const char *filename, int volume_config, ipc_
                /* Check whether file exists */
                fd = open(filename, 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]\n", str_error, errno);
                        switch (errno) {
                        case ENOENT:
                                return MM_ERROR_SOUND_FILE_NOT_FOUND;
@@ -182,7 +178,9 @@ static int _mm_sound_play_keysound(const char *filename, int volume_config, ipc_
                /* Write to PIPE */
                res = write(fd, &data, size);
                if (res < 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]\n", str_error, errno);
                        ret = MM_ERROR_SOUND_INTERNAL;
                }
                /* Close PIPE */