Remove unused files 63/44863/2
authorSeungbae Shin <seungbae.shin@samsung.com>
Tue, 28 Jul 2015 08:15:55 +0000 (17:15 +0900)
committerSeungbae Shin <seungbae.shin@samsung.com>
Wed, 29 Jul 2015 08:14:19 +0000 (17:14 +0900)
Change-Id: I9e2b9a0b89ec07674ff00d4504ad53ad2c0be723
Signed-off-by: Seungbae Shin <seungbae.shin@samsung.com>
25 files changed:
common/mm_sound_utils.c
include/mm_sound_client_msgq.h [deleted file]
include/mm_sound_common.h
mm_sound_client_msgq.c [deleted file]
mm_sound_keysound.c
mm_sound_pcm.c
server/Makefile.am
server/include/mm_sound_mgr_device.h [deleted file]
server/include/mm_sound_mgr_device_dock.h [deleted file]
server/include/mm_sound_mgr_device_hdmi.h [deleted file]
server/include/mm_sound_mgr_device_headset.h [deleted file]
server/include/mm_sound_mgr_device_wfd.h [deleted file]
server/include/mm_sound_mgr_ipc_msgq.h [deleted file]
server/include/mm_sound_mgr_pulse.h [deleted file]
server/include/mm_sound_mgr_session.h [deleted file]
server/mm_sound_mgr_asm.c
server/mm_sound_mgr_device.c [deleted file]
server/mm_sound_mgr_device_dock.c [deleted file]
server/mm_sound_mgr_device_hdmi.c [deleted file]
server/mm_sound_mgr_device_headset.c [deleted file]
server/mm_sound_mgr_device_wfd.c [deleted file]
server/mm_sound_mgr_ipc.c
server/mm_sound_mgr_pulse.c [deleted file]
server/mm_sound_mgr_session.c [deleted file]
server/mm_sound_server.c

index c87ec74..396833d 100644 (file)
@@ -214,11 +214,8 @@ int mm_sound_util_get_dock_type (int *type)
 EXPORT_API
 bool mm_sound_util_is_recording (void)
 {
-       int capture_status = 0;
-       bool result = false;
-
-    /* FIXME */
-       return result;
+           /* FIXME : is this function needs anymore ??? */
+       return false;
 }
 
 EXPORT_API
diff --git a/include/mm_sound_client_msgq.h b/include/mm_sound_client_msgq.h
deleted file mode 100644 (file)
index ca76851..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * libmm-sound
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Seungbae Shin <seungbae.shin@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef __MM_SOUND_CLIENT_MSGQ_H__
-#define __MM_SOUND_CLIENT_MSGQ_H__
-
-#include "mm_sound_private.h"
-#include "mm_sound_device.h"
-#ifdef USE_FOCUS
-#include "mm_sound_focus.h"
-#endif
-
-//#define MEMTYPE_TRANS_PER_MAX (1024 * 1024) /* 1MB */
-
-int MMSoundClientMsgqInit(void);
-int MMSoundClientMsgqCallbackFini(void);
-int MMSoundClientMsgqPlayTone(int number, int volume_config, double volume, int time, int *handle, bool enable_session);
-int MMSoundClientMsgqPlaySound(MMSoundPlayParam *param, int tone, int keytone, int *handle);
-int MMSoundClientMsgqStopSound(int handle);
-int _mm_sound_client_msgq_is_route_available(mm_sound_route route, bool *is_available);
-int _mm_sound_client_msgq_foreach_available_route_cb(mm_sound_available_route_cb , void *user_data);
-int _mm_sound_client_msgq_set_active_route(mm_sound_route route, bool need_broadcast);
-int _mm_sound_client_msgq_get_active_device(mm_sound_device_in *device_in, mm_sound_device_out *device_out);
-int _mm_sound_client_msgq_add_active_device_changed_callback(const char *name, mm_sound_active_device_changed_cb func, void* user_data);
-int _mm_sound_client_msgq_remove_active_device_changed_callback(const char *name);
-int _mm_sound_client_msgq_add_available_route_changed_callback(mm_sound_available_route_changed_cb func, void* user_data);
-int _mm_sound_client_msgq_remove_available_route_changed_callback(void);
-int _mm_sound_client_msgq_add_volume_changed_callback(mm_sound_volume_changed_cb func, void* user_data);
-int _mm_sound_client_msgq_remove_volume_changed_callback(void);
-int _mm_sound_client_msgq_set_sound_path_for_active_device(mm_sound_device_out device_out, mm_sound_device_in device_in);
-int _mm_sound_client_msgq_get_current_connected_device_list(int device_flgas, mm_sound_device_list_t **device_list);
-int _mm_sound_client_msgq_add_device_connected_callback(int device_flags, mm_sound_device_connected_cb func, void* user_data);
-int _mm_sound_client_msgq_remove_device_connected_callback(void);
-int _mm_sound_client_msgq_add_device_info_changed_callback(int device_flags, mm_sound_device_info_changed_cb func, void* user_data);
-int _mm_sound_client_msgq_remove_device_info_changed_callback(void);
-#ifdef USE_FOCUS
-int _mm_sound_client_msgq_register_focus(int id, const char *stream_type, mm_sound_focus_changed_cb callback, void* user_data);
-int _mm_sound_client_msgq_unregister_focus(int id);
-int _mm_sound_client_msgq_acquire_focus(int id, mm_sound_focus_type_e type, const char *option);
-int _mm_sound_client_msgq_release_focus(int id, mm_sound_focus_type_e type, const char *option);
-int _mm_sound_client_msgq_set_focus_watch_callback(mm_sound_focus_type_e type, mm_sound_focus_changed_watch_cb callback, void* user_data);
-int _mm_sound_client_msgq_unset_focus_watch_callback(void);
-#endif
-
-#ifdef PULSE_CLIENT
-int MMSoundClientMsgqIsBtA2dpOn (bool *connected, char** bt_name);
-#endif
-int _mm_sound_client_msgq_set_active_route_auto(void);
-int _mm_sound_client_msgq_get_audio_path(mm_sound_device_in *device_in, mm_sound_device_out *device_out);
-
-#endif /* __MM_SOUND_CLIENT_MSGQ_H__ */
index 6e40cf3..bf62965 100644 (file)
@@ -38,7 +38,6 @@
 #define VCONF_KEY_VOLUME_TYPE_VOICE            VCONF_KEY_VOLUME_PREFIX"/voice"
 #define VCONF_KEY_VOLUME_TYPE_ANDROID          VCONF_KEY_VOLUME_PREFIX"/fixed"
 
-#define VCONFKEY_SOUND_PRIMARY_VOLUME_TYPE     "memory/private/sound/PrimaryVolumeType"
 #ifndef _TIZEN_PUBLIC_
 #ifdef TIZEN_MICRO
 #define VCONF_KEY_VR_LEFTHAND_ENABLED          VCONFKEY_SETAPPL_PERFERED_ARM_LEFT_BOOL
diff --git a/mm_sound_client_msgq.c b/mm_sound_client_msgq.c
deleted file mode 100644 (file)
index 33d9359..0000000
+++ /dev/null
@@ -1,2646 +0,0 @@
-/*
- * libmm-sound
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Seungbae Shin <seungbae.shin@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <sys/shm.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/msg.h>
-#include <assert.h>
-#include <errno.h>
-
-#include <pthread.h>
-#include <semaphore.h>
-
-#include <mm_error.h>
-#include <mm_debug.h>
-
-#include "include/mm_sound.h"
-#include "include/mm_sound_msg.h"
-#include "include/mm_sound_client.h"
-#include "include/mm_sound_client_msgq.h"
-#include "include/mm_sound_common.h"
-#include "include/mm_sound_device.h"
-#ifdef USE_FOCUS
-#include "include/mm_sound_focus.h"
-#endif
-
-#include <mm_session.h>
-#include <mm_session_private.h>
-
-#define __DIRECT_CALLBACK__
-//#define __GIDLE_CALLBACK__
-
-#include <glib.h>
-#if defined(__GSOURCE_CALLBACK__)
-#include <sys/poll.h>
-#endif
-
-#define MEMTYPE_SUPPORT_MAX (1024 * 1024) /* 1MB */
-#define MEMTYPE_TRANS_PER_MAX (128 * 1024) /* 128K */
-
-int g_msg_scsnd;     /* global msg queue id for sending msg to sound client */
-int g_msg_scrcv;     /* global msg queue id for receiving msg from sound client */
-int g_msg_sccb;      /* global msg queue id for triggering callback to sound client */
-int g_msg_scsndcb;   /* global msg queue id for triggering callback to sound client in case of synchronous API */
-int g_msg_scrcvcb;   /* global msg queue id for replying callback result from sound client in case of synchronous API */
-
-/* global variables for device list */
-static GList *g_device_list = NULL;
-static mm_sound_device_list_t g_device_list_t;
-static pthread_mutex_t g_device_list_mutex = PTHREAD_MUTEX_INITIALIZER;
-
-/* callback */
-struct __callback_param
-{
-       mm_sound_stop_callback_func     callback;
-    void                    *data;
-};
-
-pthread_t g_thread;
-pthread_t g_thread2;
-static int g_exit_thread = 0;
-int g_thread_id = -1;
-int g_thread_id2 = -1;
-pthread_mutex_t g_thread_mutex = PTHREAD_MUTEX_INITIALIZER;
-pthread_mutex_t g_thread_mutex2 = PTHREAD_MUTEX_INITIALIZER;
-
-static void* callbackfunc(void *param);
-
-/* manage IPC (msg contorl) */
-static int __MMIpcCBSndMsg(mm_ipc_msg_t *msg);
-static int __MMIpcRecvMsg(int msgtype, mm_ipc_msg_t *msg);
-static int __MMIpcSndMsg(mm_ipc_msg_t *msg);
-static int __MMIpcCBRecvMsg(int msgtype, mm_ipc_msg_t *msg);
-static int __MMIpcCBRecvMsgForReply(int msgtype, mm_ipc_msg_t *msg);
-static int __MMIpcCBSndMsgReply(mm_ipc_msg_t *msg);
-static int __MMSoundGetMsg(void);
-
-int MMSoundClientMsgqInit(void)
-{
-       int ret = MM_ERROR_NONE;
-       debug_fenter();
-
-       debug_fleave();
-       return ret;
-}
-
-int MMSoundClientMsgqCallbackFini(void)
-{
-       mm_ipc_msg_t msgsnd={0,};
-       int ret = MM_ERROR_NONE;
-
-       debug_fenter();
-
-       /* When the the callback thread is not created, do not wait destroy thread */
-       /* g_thread_id is initialized : -1 */
-       /* g_thread_id is set to 0, when the callback thread is created */
-       if (g_thread_id != -1) {
-               msgsnd.sound_msg.msgtype = MM_SOUND_MSG_INF_DESTROY_CB;
-               msgsnd.sound_msg.msgid = getpid();
-               ret = __MMIpcCBSndMsg(&msgsnd);
-               if (ret != MM_ERROR_NONE)
-               {
-                       debug_critical("[Client] Fail to send message\n");
-               }
-               pthread_join(g_thread, 0);
-       }
-       if (g_thread_id2 != -1) {
-               pthread_join(g_thread2, 0);
-       }
-
-       pthread_mutex_destroy(&g_thread_mutex);
-       pthread_mutex_destroy(&g_thread_mutex2);
-
-       debug_fleave();
-       return MM_ERROR_NONE;
-}
-
-#if defined(__GSOURCE_CALLBACK__)
-gboolean sndcb_fd_check(GSource * source)
-{
-       GSList *fd_list;
-       fd_list = source->poll_fds;
-       GPollFD* temp;
-
-       do
-       {
-               temp = (GPollFD*)fd_list->data;
-               if (temp->revents & (POLLIN|POLLPRI))
-                       return TRUE;
-               fd_list = fd_list->next;
-       }while(fd_list);
-
-       return FALSE; /* there is no change in any fd state */
-}
-
-gboolean sndcb_fd_prepare(GSource *source, gint *timeout)
-{
-       return FALSE;
-}
-
-gboolean sndcb_fd_dispatch(GSource *source,    GSourceFunc callback, gpointer user_data)
-{
-       callback(user_data);
-       return TRUE;
-}
-#endif
-gboolean RunCallback(gpointer data)
-{
-       mm_ipc_msg_t* msg = NULL;
-
-       debug_msg("[Client] execute mm_sound stop callback function\n");
-
-       msg = (mm_ipc_msg_t*)data;
-       ((mm_sound_stop_callback_func)msg->sound_msg.callback)(msg->sound_msg.cbdata, msg->sound_msg.handle);
-
-       return FALSE;
-}
-
-gboolean _volume_change_cb(gpointer data)
-{
-       mm_ipc_msg_t* msg = NULL;
-
-       if (!data) {
-               debug_error("[Client] NULL param\n");
-               return FALSE;
-       }
-       msg = (mm_ipc_msg_t*)data;
-
-       ((mm_sound_volume_changed_cb)msg->sound_msg.callback)(msg->sound_msg.type, msg->sound_msg.val, msg->sound_msg.cbdata);
-
-       if(msg != NULL) {
-               free(msg);
-               msg = NULL;
-       }
-       return FALSE;
-}
-
-static void* callbackfunc(void *param)
-{
-       int ret = MM_ERROR_SOUND_INTERNAL;
-       mm_ipc_msg_t *msgrcv = NULL;
-       int run = 1;
-       int instance;
-
-       debug_fenter();
-
-       instance = getpid();
-       debug_msg("[Client] callback thread for [%d] is created\n", instance);
-
-       msgrcv = (mm_ipc_msg_t*)malloc(sizeof(mm_ipc_msg_t));
-       if(NULL == msgrcv)
-       {
-               debug_critical("[Client] Failed to memory allocation\n");
-               return NULL;
-       }
-
-       while(run)
-       {
-#if defined(__GSOURCE_CALLBACK__)
-               int eventFd = 0;
-               gchar* eventFile = NULL;
-               GSource* cmd_fd_gsrc = NULL;
-               GSourceFuncs *src_funcs = NULL;         // handler function
-               guint gsource_handle;
-               GPollFD *g_fd_cmd = NULL;                       // file descriptor
-#endif
-
-               debug_msg("[Client] Waiting message\n");
-               ret = __MMIpcCBRecvMsg(instance, msgrcv);
-               if (ret != MM_ERROR_NONE)
-               {
-                       debug_error("[Client] Fail to receive msg in callback\n");
-                       continue;
-               }
-
-               debug_msg("[Client] Receive msgtype : [%d]\n", msgrcv->sound_msg.msgtype);
-
-               switch (msgrcv->sound_msg.msgtype)
-               {
-               case MM_SOUND_MSG_INF_STOP_CB:
-                       debug_msg("[Client] callback : %p, data : %p\n", msgrcv->sound_msg.callback, msgrcv->sound_msg.cbdata);
-
-                       if (msgrcv->sound_msg.callback)
-                       {
-#if defined(__DIRECT_CALLBACK__)
-                               ((mm_sound_stop_callback_func)msgrcv->sound_msg.callback)(msgrcv->sound_msg.cbdata, msgrcv->sound_msg.handle);
-#elif defined(__GIDLE_CALLBACK__)
-                               guint eventid = 0;
-                               eventid = g_idle_add((GSourceFunc)RunCallback, (gpointer)msgrcv);
-                               debug_msg("[Client] Event Source ID : %d\n", eventid);
-
-#elif defined(__GSOURCE_CALLBACK__)
-                               char eventBuf[3]="OK";
-                               ////////////////////////
-                               // 0. Make event source
-                               eventFile = g_strdup_printf("/tmp/%d_0x%08x_0x%08x", instance, (unsigned int)msgrcv->sound_msg.callback, (unsigned int)msgrcv->sound_msg.cbdata);
-                               eventFd = open(eventFile, O_RDWR|O_CREAT);
-                               if(eventFd == -1)
-                               {
-                                       debug_critical("Event File creation failed\n");
-                                       break;
-                               }
-
-                               // 1. make GSource Object
-                               src_funcs = (GSourceFuncs *)g_malloc(sizeof(GSourceFuncs));
-                               if(!src_funcs){
-                                       debug_error("MMSoundCallback :  g_malloc failed on g_src_funcs");
-                                       break;
-                               }
-                               src_funcs->prepare = sndcb_fd_prepare;
-                               src_funcs->check = sndcb_fd_check;
-                               src_funcs->dispatch = sndcb_fd_dispatch;
-                               src_funcs->finalize = NULL;
-                               cmd_fd_gsrc = g_source_new(src_funcs,sizeof(GSource));
-                               if(!cmd_fd_gsrc){
-                                       debug_error("MMSoundCallback : g_malloc failed on m_readfd");
-                                       break;
-                               }
-
-                               // 2. add file description which used in g_loop()
-                               g_fd_cmd = (GPollFD*)g_malloc(sizeof(GPollFD));
-                               g_fd_cmd->fd = eventFd;
-                               g_fd_cmd->events = POLLIN|POLLPRI;
-
-                               // 3. combine g_source object and file descriptor
-                               g_source_add_poll(cmd_fd_gsrc,g_fd_cmd);
-                               gsource_handle = g_source_attach(cmd_fd_gsrc, NULL);
-                               if(!gsource_handle){
-                                       debug_error("MMSoundCallback : Error: Failed to attach the source to context");
-                                       break;
-                               }
-
-                               // 4. set callback
-                               g_source_set_callback(cmd_fd_gsrc,RunCallback,(gpointer)g_fd_cmd,NULL);
-                               debug_msg("MMSoundCallback : g_source_set_callback() done\n")
-
-                               // 5. Set Event
-                               write(eventFd, eventBuf, sizeof(eventBuf));
-                               sleep(1);
-                               // 6. Cleanup
-                               close(eventFd);
-                               unlink(eventFile);
-                               g_source_remove_poll(cmd_fd_gsrc, g_fd_cmd);
-                               g_source_remove(gsource_handle);
-                               if(g_fd_cmd)
-                                       free(g_fd_cmd);
-                               if(src_funcs)
-                                       free(src_funcs);
-                               if(eventFile)
-                                       g_free(eventFile);
-                               ////////////////////////
-#endif
-                       }
-                       break;
-               case MM_SOUND_MSG_INF_DESTROY_CB:
-                       run = 0;
-                       break;
-
-               case MM_SOUND_MSG_INF_DEVICE_CONNECTED_CB:
-                       debug_msg("[Client] device handle : %x, is_connected : %d, callback : %p, data : %p\n",
-                               &msgrcv->sound_msg.device_handle, msgrcv->sound_msg.is_connected, msgrcv->sound_msg.callback, msgrcv->sound_msg.cbdata);
-                       if (msgrcv->sound_msg.callback) {
-                               ((mm_sound_device_connected_cb)msgrcv->sound_msg.callback)(&msgrcv->sound_msg.device_handle, msgrcv->sound_msg.is_connected, msgrcv->sound_msg.cbdata);
-                       }
-                       break;
-
-               case MM_SOUND_MSG_INF_DEVICE_INFO_CHANGED_CB:
-                       debug_msg("[Client] device handle : %x, changed_info_type : %d, callback : %p, data : %p\n",
-                               &msgrcv->sound_msg.device_handle, msgrcv->sound_msg.changed_device_info_type, msgrcv->sound_msg.callback, msgrcv->sound_msg.cbdata);
-                       if (msgrcv->sound_msg.callback) {
-                               ((mm_sound_device_info_changed_cb)msgrcv->sound_msg.callback)(&msgrcv->sound_msg.device_handle, msgrcv->sound_msg.changed_device_info_type, msgrcv->sound_msg.cbdata);
-                       }
-                       break;
-
-               case MM_SOUND_MSG_INF_ACTIVE_DEVICE_CB:
-                       debug_msg("[Client] device_in : %d, device_out : %d\n", msgrcv->sound_msg.device_in, msgrcv->sound_msg.device_out);
-                       debug_log("[Client] callback : %p, data : %p\n", msgrcv->sound_msg.callback, msgrcv->sound_msg.cbdata);
-
-                       if (msgrcv->sound_msg.callback)
-                       {
-                               ((mm_sound_active_device_changed_cb)msgrcv->sound_msg.callback)(msgrcv->sound_msg.device_in, msgrcv->sound_msg.device_out, msgrcv->sound_msg.cbdata);
-                       }
-                       break;
-               case MM_SOUND_MSG_INF_AVAILABLE_ROUTE_CB:
-                       debug_log("[Client] callback : %p, data : %p\n", msgrcv->sound_msg.callback, msgrcv->sound_msg.cbdata);
-
-                       if (msgrcv->sound_msg.callback)
-                       {
-                               int route_index;
-                               mm_sound_route route;
-
-                               int list_count = sizeof(msgrcv->sound_msg.route_list) / sizeof(int);
-
-                               for (route_index = list_count-1; route_index >= 0; route_index--) {
-                                       route = msgrcv->sound_msg.route_list[route_index];
-                                       if (route == 0)
-                                               continue;
-                                       if (msgrcv->sound_msg.is_available) {
-                                               debug_msg("[Client] available route : 0x%x\n", route);
-                                       } else {
-                                               debug_msg("[Client] unavailable route : 0x%x\n", route);
-                                       }
-                                       ((mm_sound_available_route_changed_cb)msgrcv->sound_msg.callback)(route, msgrcv->sound_msg.is_available, msgrcv->sound_msg.cbdata);
-
-                                       if (route == MM_SOUND_ROUTE_INOUT_HEADSET || route == MM_SOUND_ROUTE_IN_MIC_OUT_HEADPHONE) {
-                                               debug_msg("[Client] no need to proceed further more....\n");
-                                               break;
-                                       }
-                               }
-                       }
-                       break;
-               case MM_SOUND_MSG_INF_VOLUME_CB:
-                       debug_msg("[Client] type: %d, volume value : %d, callback : %p, data : %p\n", msgrcv->sound_msg.type, msgrcv->sound_msg.val, msgrcv->sound_msg.callback, msgrcv->sound_msg.cbdata);
-
-                       if (msgrcv->sound_msg.callback)
-                       {
-                               mm_ipc_msg_t* tmp = NULL;
-                               tmp = (mm_ipc_msg_t*)malloc(sizeof(mm_ipc_msg_t));
-                               if(tmp == NULL) {
-                                       debug_critical("Fail malloc");
-                                       break;
-                               }
-                               memcpy(tmp, msgrcv, sizeof(mm_ipc_msg_t));
-                               g_idle_add((GSourceFunc)_volume_change_cb, (gpointer)tmp);
-                       }
-                       break;
-
-               default:
-                       /* Unexpected msg */
-                       debug_msg("Receive wrong msg in callback func\n");
-                       break;
-               }
-       }
-       if(msgrcv) {
-               free(msgrcv);
-       }
-
-       g_exit_thread = 1;
-       debug_msg("[Client] callback [%d] is leaved\n", instance);
-       debug_fleave();
-       return NULL;
-}
-
-static void* callbackfunc_send_reply(void *param)
-{
-       int ret = MM_ERROR_SOUND_INTERNAL;
-       mm_ipc_msg_t *msgrcv = NULL;
-       mm_ipc_msg_t *msgret = NULL;
-       int run = 1;
-       int instance;
-#ifdef USE_FOCUS
-       struct timeval time;
-       int starttime = 0;
-       int endtime = 0;
-#endif
-
-       debug_fenter();
-
-       instance = getpid();
-       debug_msg("[Client] callback thread for [%d] is created\n", instance);
-
-       msgrcv = (mm_ipc_msg_t*)malloc(sizeof(mm_ipc_msg_t));
-       msgret = (mm_ipc_msg_t*)malloc(sizeof(mm_ipc_msg_t));
-       memset (msgret, 0, sizeof(mm_ipc_msg_t));
-       if(msgrcv == NULL || msgret == NULL) {
-               debug_error("[Client] Failed to memory allocation\n");
-               return NULL;
-       }
-
-       while(run) {
-               debug_msg("[Client] Waiting message\n");
-               ret = __MMIpcCBRecvMsgForReply(instance, msgrcv);
-               if (ret != MM_ERROR_NONE) {
-                       debug_error("[Client] Fail to receive msg in callback\n");
-                       continue;
-               }
-
-               debug_msg("[Client] Receive msgtype : [%d]\n", msgrcv->sound_msg.msgtype);
-
-               switch (msgrcv->sound_msg.msgtype) {
-#ifdef USE_FOCUS
-               case MM_SOUND_MSG_INF_FOCUS_CHANGED_CB:
-                       /* Set start time */
-                       gettimeofday(&time, NULL);
-                       starttime = time.tv_sec * 1000000 + time.tv_usec;
-                       debug_warning("[Client][Focus Callback(0x%x) START][handle_id(%d),focus_type(%d), state(%d),reason(%s),info(%s)][Time:%.3f]\n",
-                               msgrcv->sound_msg.callback, msgrcv->sound_msg.focus_type, msgrcv->sound_msg.changed_state, msgrcv->sound_msg.stream_type, msgrcv->sound_msg.name, starttime/1000000.);
-                       if (msgrcv->sound_msg.callback) {
-                               ((mm_sound_focus_changed_cb)msgrcv->sound_msg.callback)(msgrcv->sound_msg.handle_id, msgrcv->sound_msg.focus_type, msgrcv->sound_msg.changed_state, msgrcv->sound_msg.stream_type, msgrcv->sound_msg.name, msgrcv->sound_msg.cbdata);
-                       }
-                       /* Calculate endtime and display*/
-                       gettimeofday(&time, NULL);
-                       endtime = time.tv_sec * 1000000 + time.tv_usec;
-                       debug_warning("[Client][Focus Callback END][Time:%.3f, TimeLab=%3.3f(sec)]\n", endtime/1000000., (endtime-starttime)/1000000.);
-
-                       /* send reply */
-                       msgret->sound_msg.msgtype = msgrcv->sound_msg.msgtype;
-                       msgret->sound_msg.msgid = msgrcv->sound_msg.msgid;
-                       msgret->sound_msg.handle_id = msgrcv->sound_msg.handle_id;
-                       ret = __MMIpcCBSndMsgReply(msgret);
-                       if (ret != MM_ERROR_NONE) {
-                               debug_error("[Client] Fail to send reply msg in callback\n");
-                               continue;
-                       }
-                       break;
-
-               case MM_SOUND_MSG_INF_FOCUS_WATCH_CB:
-                       /* Set start time */
-                       gettimeofday(&time, NULL);
-                       starttime = time.tv_sec * 1000000 + time.tv_usec;
-                       debug_warning("[Client][Focus Watch Callback(0x%x) START][focus_type(%d),state(%d),reason(%s),info(%s)][Time:%.3f]\n",
-                               msgrcv->sound_msg.callback, msgrcv->sound_msg.focus_type, msgrcv->sound_msg.changed_state, msgrcv->sound_msg.stream_type, msgrcv->sound_msg.name, starttime/1000000.);
-                       if (msgrcv->sound_msg.callback) {
-                               ((mm_sound_focus_changed_watch_cb)msgrcv->sound_msg.callback)(msgrcv->sound_msg.focus_type, msgrcv->sound_msg.changed_state, msgrcv->sound_msg.stream_type, msgrcv->sound_msg.name, msgrcv->sound_msg.cbdata);
-                       }
-                       /* Calculate endtime and display*/
-                       gettimeofday(&time, NULL);
-                       endtime = time.tv_sec * 1000000 + time.tv_usec;
-                       debug_warning("[Client][Focus Watch Callback END][Time:%.3f, TimeLab=%3.3f(sec)]\n", endtime/1000000., (endtime-starttime)/1000000.);
-
-                       /* send reply */
-                       msgret->sound_msg.msgtype = msgrcv->sound_msg.msgtype;
-                       msgret->sound_msg.msgid = msgrcv->sound_msg.msgid;
-                       ret = __MMIpcCBSndMsgReply(msgret);
-                       if (ret != MM_ERROR_NONE) {
-                               debug_error("[Client] Fail to send reply msg in callback\n");
-                               continue;
-                       }
-                       break;
-#endif
-
-               default:
-                       /* Unexpected msg */
-                       debug_msg("Receive wrong msg in callback func\n");
-                       break;
-               }
-       }
-       if(msgrcv) {
-               free(msgrcv);
-       }
-       if(msgret) {
-               free(msgret);
-       }
-
-       debug_msg("[Client] callback [%d] is leaved\n", instance);
-       debug_fleave();
-       return NULL;
-
-}
-
-static int __mm_sound_client_get_msg_queue(void)
-{
-       int ret = MM_ERROR_NONE;
-
-       if(pthread_mutex_init(&g_thread_mutex, NULL)) {
-               debug_error("pthread_mutex_init failed\n");
-               return MM_ERROR_SOUND_INTERNAL;
-       }
-       if(pthread_mutex_init(&g_thread_mutex2, NULL)) {
-               debug_error("pthread_mutex_init failed\n");
-               return MM_ERROR_SOUND_INTERNAL;
-       }
-       debug_log("[Client] mutex initialized. \n");
-
-       /* Get msg queue id */
-       ret = __MMSoundGetMsg();
-       if(ret != MM_ERROR_NONE) {
-               debug_error("[Client] Fail to get message queue id. sound_server is not initialized.\n");
-               pthread_mutex_destroy(&g_thread_mutex);
-               pthread_mutex_destroy(&g_thread_mutex2);
-       }
-
-       return ret;
-}
-
-int MMSoundClientMsgqPlayTone(int number, int volume_config, double volume, int time, int *handle, bool enable_session)
-{
-       mm_ipc_msg_t msgrcv = {0,};
-       mm_ipc_msg_t msgsnd = {0,};
-
-       int ret = MM_ERROR_NONE;
-       int instance = -1;      /* instance is unique to communicate with server : client message queue filter type */
-
-       debug_fenter();
-
-       ret = __mm_sound_client_get_msg_queue();
-       if (ret  != MM_ERROR_NONE) {
-               return ret;
-       }
-       /* read session information */
-       int session_type = MM_SESSION_TYPE_MEDIA;
-       int session_options = 0;
-       if (enable_session)
-       {
-               if (MM_ERROR_NONE != _mm_session_util_read_information(-1, &session_type, &session_options))
-               {
-                       debug_warning("[Client] Read Session Information failed. use default \"media\" type\n");
-                       session_type = MM_SESSION_TYPE_MEDIA;
-
-                       if(MM_ERROR_NONE != mm_session_init(session_type))
-                       {
-                               debug_critical("[Client] MMSessionInit() failed\n");
-                               return MM_ERROR_POLICY_INTERNAL;
-                       }
-               }
-       }
-
-       instance = getpid();
-       debug_log("[Client] pid for client ::: [%d]\n", instance);
-
-       pthread_mutex_lock(&g_thread_mutex);
-
-       /* Send msg */
-       debug_msg("[Client] Input number : %d\n", number);
-       /* Send req memory */
-       msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_DTMF;
-       msgsnd.sound_msg.msgid = instance;
-       msgsnd.sound_msg.session_type = session_type;       //session type
-       msgsnd.sound_msg.session_options = session_options; //session options
-       msgsnd.sound_msg.volume = volume;                   //This does not effect anymore
-       msgsnd.sound_msg.volume_config = volume_config;
-       msgsnd.sound_msg.tone = number;
-       msgsnd.sound_msg.handle = -1;
-       msgsnd.sound_msg.repeat = time;
-       msgsnd.sound_msg.enable_session = enable_session;
-
-       ret = __MMIpcSndMsg(&msgsnd);
-       if (ret != MM_ERROR_NONE)
-       {
-               debug_error("[Client] Fail to send msg\n");
-               goto cleanup;
-       }
-
-       /* Receive */
-       ret = __MMIpcRecvMsg(instance, &msgrcv);
-       if (ret != MM_ERROR_NONE)
-       {
-               debug_error("[Client] Fail to recieve msg\n");
-               goto cleanup;
-       }
-
-       switch (msgrcv.sound_msg.msgtype)
-       {
-       case MM_SOUND_MSG_RES_DTMF:
-               *handle = msgrcv.sound_msg.handle;
-               if(*handle == -1) {
-                       debug_error("[Client] The handle is not get\n");
-               } else {
-                       debug_msg("[Client] Success to play sound sound handle : [%d]\n", *handle);
-               }
-               break;
-
-       case MM_SOUND_MSG_RES_ERROR:
-               debug_error("[Client] Error occurred \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-
-       default:
-               debug_critical("[Client] Unexpected state with communication \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       }
-cleanup:
-       pthread_mutex_unlock(&g_thread_mutex);
-
-       debug_fleave();
-       return ret;
-}
-
-
-int MMSoundClientMsgqPlaySound(MMSoundPlayParam *param, int tone, int keytone, int *handle)
-{
-       mm_ipc_msg_t msgrcv = {0,};
-       mm_ipc_msg_t msgsnd = {0,};
-
-       int ret = MM_ERROR_NONE;
-       int instance = -1;      /* instance is unique to communicate with server : client message queue filter type */
-
-       debug_fenter();
-
-       ret = __mm_sound_client_get_msg_queue();
-       if (ret  != MM_ERROR_NONE) {
-               return ret;
-       }
-       /* read session information */
-       int session_type = MM_SESSION_TYPE_MEDIA;
-       int session_options = 0;
-
-       if (param->skip_session == false) {
-               if(MM_ERROR_NONE != _mm_session_util_read_information(-1, &session_type, &session_options))
-               {
-                       debug_warning("[Client] Read MMSession Type failed. use default \"media\" type\n");
-                       session_type = MM_SESSION_TYPE_MEDIA;
-
-                       if(MM_ERROR_NONE != mm_session_init(session_type))
-                       {
-                               debug_critical("[Client] MMSessionInit() failed\n");
-                               return MM_ERROR_POLICY_INTERNAL;
-                       }
-               }
-       }
-
-       instance = getpid();
-       debug_msg("[Client] pid for client ::: [%d]\n", instance);
-
-       /* Send msg */
-       if ((param->mem_ptr && param->mem_size))
-       {
-               // memory play
-       }
-       else
-       {
-               /* File type set for send msg */
-               msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_FILE;
-               msgsnd.sound_msg.msgid = instance;
-               msgsnd.sound_msg.callback = (void*)(param->callback);
-               msgsnd.sound_msg.cbdata = (void*)(param->data);
-               msgsnd.sound_msg.volume = param->volume;
-               msgsnd.sound_msg.tone = tone;
-               msgsnd.sound_msg.handle = -1;
-               msgsnd.sound_msg.repeat = param->loop;
-               msgsnd.sound_msg.volume_config = param->volume_config;
-               msgsnd.sound_msg.session_type = session_type;       //session type
-               msgsnd.sound_msg.session_options = session_options; //session options
-               msgsnd.sound_msg.priority = param->priority;
-               msgsnd.sound_msg.handle_route = param->handle_route;
-               msgsnd.sound_msg.enable_session = !param->skip_session;
-
-               if((strlen(param->filename)) < FILE_PATH)
-               {
-                       MMSOUND_STRNCPY(msgsnd.sound_msg.filename, param->filename, FILE_PATH);
-               }
-               else
-               {
-                       debug_error("File name is over count\n");
-                       ret = MM_ERROR_SOUND_INVALID_PATH;
-               }
-
-               msgsnd.sound_msg.keytone = keytone;
-
-               debug_msg("[Client] callback : %p\n", msgsnd.sound_msg.callback);
-               debug_msg("[Client] cbdata : %p\n", msgsnd.sound_msg.cbdata);
-
-               ret = __MMIpcSndMsg(&msgsnd);
-               if (ret != MM_ERROR_NONE)
-               {
-                       debug_error("[Client] Fail to send msg\n");
-                       goto cleanup;
-               }
-       }
-
-
-       /* Receive */
-       ret = __MMIpcRecvMsg(instance, &msgrcv);
-       if (ret != MM_ERROR_NONE)
-       {
-               debug_error("[Client] Fail to recieve msg\n");
-               goto cleanup;
-       }
-
-       switch (msgrcv.sound_msg.msgtype)
-       {
-       case MM_SOUND_MSG_RES_FILE:
-               *handle = msgrcv.sound_msg.handle;
-               debug_msg("[Client] Success to play sound sound handle : [%d]\n", *handle);
-               break;
-       case MM_SOUND_MSG_RES_MEMORY:
-               // deprecated
-               break;
-       case MM_SOUND_MSG_RES_ERROR:
-               debug_error("[Client] Error occurred \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       default:
-               debug_critical("[Client] Unexpected state with communication \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       }
-cleanup:
-
-       debug_fleave();
-       return ret;
-}
-
-int MMSoundClientMsgqStopSound(int handle)
-{
-       mm_ipc_msg_t msgrcv = {0,};
-       mm_ipc_msg_t msgsnd = {0,};
-       int ret = MM_ERROR_NONE;
-       int instance;
-
-       debug_fenter();
-       debug_msg("[Client] The stop audio handle ::: [%d]\n", handle);
-
-       instance = getpid();
-
-       if (handle < 0)
-       {
-               ret = MM_ERROR_INVALID_ARGUMENT;
-               return ret;
-       }
-
-       ret = __mm_sound_client_get_msg_queue();
-       if (ret  != MM_ERROR_NONE) {
-               return ret;
-       }
-
-       pthread_mutex_lock(&g_thread_mutex);
-
-       /* Send req STOP */
-       msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_STOP;
-       msgsnd.sound_msg.msgid = instance;
-       msgsnd.sound_msg.handle = handle;               /* handle means audio handle slot id */
-
-       ret = __MMIpcSndMsg(&msgsnd);
-       if (ret != MM_ERROR_NONE)
-       {
-               debug_error("Fail to send msg\n");
-               goto cleanup;
-       }
-
-       /* Receive */
-       ret = __MMIpcRecvMsg(instance, &msgrcv);
-       if (ret != MM_ERROR_NONE)
-       {
-               debug_error("[Client] Fail to recieve msg\n");
-               goto cleanup;
-       }
-       switch (msgrcv.sound_msg.msgtype)
-       {
-       case MM_SOUND_MSG_RES_STOP:
-               debug_msg("[Client] Success to stop sound\n");
-               break;
-       case MM_SOUND_MSG_RES_ERROR:
-               debug_error("[Client] Error occurred \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       default:
-               debug_critical("[Client] Unexpected state with communication \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       }
-
-cleanup:
-       pthread_mutex_unlock(&g_thread_mutex);
-
-
-       debug_fleave();
-       return ret;
-}
-
-static int __mm_sound_device_check_flags_to_append (int device_flags, mm_sound_device_t *device_h, bool *is_good_to_append)
-{
-       bool need_to_append = false;
-       int need_to_check_for_io_direction = device_flags & DEVICE_IO_DIRECTION_FLAGS;
-       int need_to_check_for_state = device_flags & DEVICE_STATE_FLAGS;
-       int need_to_check_for_type = device_flags & DEVICE_TYPE_FLAGS;
-
-       debug_warning("device_h[0x%x], device_flags[0x%x], need_to_check(io_direction[0x%x],state[0x%x],type[0x%x])\n",
-                       device_h, device_flags, need_to_check_for_io_direction, need_to_check_for_state, need_to_check_for_type);
-
-       if(!device_h) {
-               return MM_ERROR_INVALID_ARGUMENT;
-       }
-       if (device_flags == DEVICE_ALL_FLAG) {
-               *is_good_to_append = true;
-               return MM_ERROR_NONE;
-       }
-
-       if (need_to_check_for_io_direction) {
-               if ((device_h->io_direction == DEVICE_IO_DIRECTION_IN) && (device_flags & DEVICE_IO_DIRECTION_IN_FLAG)) {
-                       need_to_append = true;
-               } else if ((device_h->io_direction == DEVICE_IO_DIRECTION_OUT) && (device_flags & DEVICE_IO_DIRECTION_OUT_FLAG)) {
-                       need_to_append = true;
-               } else if ((device_h->io_direction == DEVICE_IO_DIRECTION_BOTH) && (device_flags & DEVICE_IO_DIRECTION_BOTH_FLAG)) {
-                       need_to_append = true;
-               }
-               if (need_to_append) {
-                       if (!need_to_check_for_state && !need_to_check_for_type) {
-                               *is_good_to_append = true;
-                               return MM_ERROR_NONE;
-                       }
-               } else {
-                       *is_good_to_append = false;
-                       return MM_ERROR_NONE;
-               }
-       }
-       if (need_to_check_for_state) {
-               need_to_append = false;
-               if ((device_h->state == DEVICE_STATE_DEACTIVATED) && (device_flags & DEVICE_STATE_DEACTIVATED_FLAG)) {
-                       need_to_append = true;
-               } else if ((device_h->state == DEVICE_STATE_ACTIVATED) && (device_flags & DEVICE_STATE_ACTIVATED_FLAG)) {
-                       need_to_append = true;
-               }
-               if (need_to_append) {
-                       if (!need_to_check_for_type) {
-                               *is_good_to_append = true;
-                               return MM_ERROR_NONE;
-                       }
-               } else {
-                       *is_good_to_append = false;
-                       return MM_ERROR_NONE;
-               }
-       }
-       if (need_to_check_for_type) {
-               need_to_append = false;
-               bool is_internal_device = IS_INTERNAL_DEVICE(device_h->type);
-               if (is_internal_device && (device_flags & DEVICE_TYPE_INTERNAL_FLAG)) {
-                       need_to_append = true;
-               } else if (!is_internal_device && (device_flags & DEVICE_TYPE_EXTERNAL_FLAG)) {
-                       need_to_append = true;
-               }
-               if (need_to_append) {
-                       *is_good_to_append = true;
-                       return MM_ERROR_NONE;
-               } else {
-                       *is_good_to_append = false;
-                       return MM_ERROR_NONE;
-               }
-       }
-       return MM_ERROR_NONE;
-}
-
-static int __mm_sound_client_device_list_clear ()
-{
-       int ret = MM_ERROR_NONE;
-
-       MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_device_list_mutex, MM_ERROR_SOUND_INTERNAL);
-
-       if (g_device_list) {
-               g_list_free_full(g_device_list, g_free);
-               g_device_list = NULL;
-       }
-
-       MMSOUND_LEAVE_CRITICAL_SECTION(&g_device_list_mutex);
-
-       return ret;
-}
-
-static int __mm_sound_client_device_list_append_item (mm_sound_device_t *device_h)
-{
-       int ret = MM_ERROR_NONE;
-       mm_sound_device_t *device_node = g_malloc0(sizeof(mm_sound_device_t));
-       memcpy(device_node, device_h, sizeof(mm_sound_device_t));
-
-       MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_device_list_mutex, MM_ERROR_SOUND_INTERNAL);
-
-       g_device_list = g_list_append(g_device_list, device_node);
-       debug_log("[Client] g_device_list[0x%x], new device_node[0x%x] is appended, type[%d], id[%d]\n", g_device_list, device_node, device_node->type, device_node->id);
-
-       MMSOUND_LEAVE_CRITICAL_SECTION(&g_device_list_mutex);
-
-       return ret;
-}
-
-static int _mm_sound_client_device_list_dump (GList *device_list)
-{
-       int ret = MM_ERROR_NONE;
-       GList *list = NULL;
-       mm_sound_device_t *device_node = NULL;
-       int count = 0;
-
-       debug_log("======================== device list : start ==========================\n");
-       for (list = device_list; list != NULL; list = list->next) {
-               device_node = (mm_sound_device_t *)list->data;
-               if (device_node) {
-                       debug_log(" list idx[%d]: type[%02d], id[%02d], io_direction[%d], state[%d], name[%s]\n",
-                                               count++, device_node->type, device_node->id, device_node->io_direction, device_node->state, device_node->name);
-               }
-       }
-       debug_log("======================== device list : end ============================\n");
-
-       return ret;
-}
-
-int _mm_sound_client_msgq_get_current_connected_device_list(int device_flags, mm_sound_device_list_t **device_list)
-{
-       mm_ipc_msg_t msgrcv = {0,};
-       mm_ipc_msg_t msgsnd = {0,};
-       int ret = MM_ERROR_NONE;
-       int instance;
-
-       debug_fenter();
-
-       ret = __mm_sound_client_get_msg_queue();
-       if (ret  != MM_ERROR_NONE) {
-               return ret;
-       }
-       pthread_mutex_lock(&g_thread_mutex);
-
-       instance = getpid();
-
-       /* Send REQ_ADD_ACTIVE_DEVICE_CB */
-       msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_GET_CONNECTED_DEVICE_LIST;
-       msgsnd.sound_msg.msgid = instance;
-       msgsnd.sound_msg.device_flags = device_flags;
-
-       if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-
-       if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-
-       switch (msgrcv.sound_msg.msgtype)
-       {
-       case MM_SOUND_MSG_RES_GET_CONNECTED_DEVICE_LIST:
-       {
-               int i = 0;
-               int ret = MM_ERROR_NONE;
-               int total_device_num = msgrcv.sound_msg.total_device_num;
-               bool is_good_to_append = false;
-               mm_sound_device_t* device_h = &msgrcv.sound_msg.device_handle;
-
-               ret = __mm_sound_client_device_list_clear();
-               if (ret) {
-                       debug_error("[Client] failed to __mm_sound_client_device_list_clear(), ret[0x%x]\n", ret);
-                       goto cleanup;
-               }
-
-               debug_msg("[Client] supposed to receive %d messages\n", total_device_num);
-               for (i = 0; i < total_device_num; i++) {
-                       /* check if this device_handle is suitable according to flags */
-                       ret = __mm_sound_device_check_flags_to_append (device_flags, device_h, &is_good_to_append);
-                       if (is_good_to_append) {
-                               ret = __mm_sound_client_device_list_append_item(device_h);
-                               if (ret) {
-                                       debug_error("[Client] failed to __mm_sound_client_device_list_append_item(), ret[0x%x]\n", ret);
-                               }
-                       }
-                       if (total_device_num-i > 1) {
-                               if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) {
-                                       debug_error("[Client] failed to [%d]th of __MMIpcRecvMsg()\n", i);
-                                       goto cleanup;
-                               }
-                               switch (msgrcv.sound_msg.msgtype)
-                               {
-                               case MM_SOUND_MSG_RES_GET_CONNECTED_DEVICE_LIST:
-                                       break;
-                               default:
-                                       debug_error("[Client] failed to [%d]th of __MMIpcRecvMsg(), msgtype[%d] is not expected\n", msgrcv.sound_msg.msgtype);
-                                       goto cleanup;
-                                       break;
-                               }
-                       }
-               }
-               g_device_list_t.list = g_device_list;
-               *device_list = &g_device_list_t;
-               debug_msg("[Client] Success to get connected device list, g_device_list_t[0x%x]->list[0x%x], device_list[0x%x]\n", &g_device_list_t, g_device_list_t.list, *device_list);
-               _mm_sound_client_device_list_dump((*device_list)->list);
-       }
-               break;
-       case MM_SOUND_MSG_RES_ERROR:
-               debug_error("[Client] Error occurred \n");
-               ret = msgrcv.sound_msg.code; // no data is possible
-               goto cleanup;
-               break;
-       default:
-               debug_error("[Client] Unexpected state with communication \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       }
-
-cleanup:
-       pthread_mutex_unlock(&g_thread_mutex);
-
-       debug_fleave();
-       return ret;
-}
-
-int _mm_sound_client_msgq_add_device_connected_callback(int device_flags, mm_sound_device_connected_cb func, void* user_data)
-{
-       mm_ipc_msg_t msgrcv = {0,};
-       mm_ipc_msg_t msgsnd = {0,};
-       int ret = MM_ERROR_NONE;
-       int instance;
-
-       debug_fenter();
-
-       ret = __mm_sound_client_get_msg_queue();
-       if (ret  != MM_ERROR_NONE) {
-               return ret;
-       }
-
-       pthread_mutex_lock(&g_thread_mutex);
-
-       instance = getpid();
-       /* Send REQ_ADD_ACTIVE_DEVICE_CB */
-       msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_ADD_DEVICE_CONNECTED_CB;
-       msgsnd.sound_msg.msgid = instance;
-       msgsnd.sound_msg.device_flags = device_flags;
-       msgsnd.sound_msg.callback = func;
-       msgsnd.sound_msg.cbdata = user_data;
-
-       if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-
-       /* Recieve */
-       if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-
-       switch (msgrcv.sound_msg.msgtype)
-       {
-       case MM_SOUND_MSG_RES_ADD_DEVICE_CONNECTED_CB:
-               debug_msg("[Client] Success to add device connected callback\n");
-               if (g_thread_id == -1)
-               {
-                       g_thread_id = pthread_create(&g_thread, NULL, callbackfunc, NULL);
-                       if (g_thread_id == -1)
-                       {
-                               debug_critical("[Client] Fail to create thread %s\n", strerror(errno));
-                               ret = MM_ERROR_SOUND_INTERNAL;
-                               goto cleanup;
-                       }
-               }
-               break;
-       case MM_SOUND_MSG_RES_ERROR:
-               debug_error("[Client] Error occurred \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       default:
-               debug_critical("[Client] Unexpected state with communication \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       }
-
-cleanup:
-       pthread_mutex_unlock(&g_thread_mutex);
-
-       debug_fleave();
-       return ret;
-}
-
-int _mm_sound_client_msgq_remove_device_connected_callback(void)
-{
-       mm_ipc_msg_t msgrcv = {0,};
-       mm_ipc_msg_t msgsnd = {0,};
-       int ret = MM_ERROR_NONE;
-       int instance;
-
-       debug_fenter();
-
-       ret = __mm_sound_client_get_msg_queue();
-       if (ret  != MM_ERROR_NONE) {
-               return ret;
-       }
-
-       pthread_mutex_lock(&g_thread_mutex);
-
-       instance = getpid();
-       /* Send REQ_REMOVE_ACTIVE_DEVICE_CB */
-       msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_REMOVE_DEVICE_CONNECTED_CB;
-       msgsnd.sound_msg.msgid = instance;
-
-       if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-       /* Recieve */
-       if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-       switch (msgrcv.sound_msg.msgtype)
-       {
-       case MM_SOUND_MSG_RES_REMOVE_DEVICE_CONNECTED_CB:
-               debug_msg("[Client] Success to remove device connected callback\n");
-               break;
-       case MM_SOUND_MSG_RES_ERROR:
-               debug_error("[Client] Error occurred \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       default:
-               debug_critical("[Client] Unexpected state with communication \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       }
-
-cleanup:
-       pthread_mutex_unlock(&g_thread_mutex);
-
-       debug_fleave();
-       return ret;
-}
-
-int _mm_sound_client_msgq_add_device_info_changed_callback(int device_flags, mm_sound_device_info_changed_cb func, void* user_data)
-{
-       mm_ipc_msg_t msgrcv = {0,};
-       mm_ipc_msg_t msgsnd = {0,};
-       int ret = MM_ERROR_NONE;
-       int instance;
-
-       debug_fenter();
-
-       ret = __mm_sound_client_get_msg_queue();
-       if (ret  != MM_ERROR_NONE) {
-               return ret;
-       }
-
-       pthread_mutex_lock(&g_thread_mutex);
-
-       instance = getpid();
-       /* Send REQ_ADD_ACTIVE_DEVICE_CB */
-       msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_ADD_DEVICE_INFO_CHANGED_CB;
-       msgsnd.sound_msg.msgid = instance;
-       msgsnd.sound_msg.device_flags = device_flags;
-       msgsnd.sound_msg.callback = func;
-       msgsnd.sound_msg.cbdata = user_data;
-
-       if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-
-       /* Recieve */
-       if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-
-       switch (msgrcv.sound_msg.msgtype)
-       {
-       case MM_SOUND_MSG_RES_ADD_DEVICE_INFO_CHANGED_CB:
-               debug_msg("[Client] Success to add device connected callback\n");
-               if (g_thread_id == -1)
-               {
-                       g_thread_id = pthread_create(&g_thread, NULL, callbackfunc, NULL);
-                       if (g_thread_id == -1)
-                       {
-                               debug_critical("[Client] Fail to create thread %s\n", strerror(errno));
-                               ret = MM_ERROR_SOUND_INTERNAL;
-                               goto cleanup;
-                       }
-               }
-               break;
-       case MM_SOUND_MSG_RES_ERROR:
-               debug_error("[Client] Error occurred \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       default:
-               debug_critical("[Client] Unexpected state with communication \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       }
-
-cleanup:
-       pthread_mutex_unlock(&g_thread_mutex);
-
-       debug_fleave();
-       return ret;
-}
-
-int _mm_sound_client_msgq_remove_device_info_changed_callback(void)
-{
-       mm_ipc_msg_t msgrcv = {0,};
-       mm_ipc_msg_t msgsnd = {0,};
-       int ret = MM_ERROR_NONE;
-       int instance;
-
-       debug_fenter();
-
-       ret = __mm_sound_client_get_msg_queue();
-       if (ret  != MM_ERROR_NONE) {
-               return ret;
-       }
-
-       pthread_mutex_lock(&g_thread_mutex);
-
-       instance = getpid();
-       /* Send REQ_REMOVE_ACTIVE_DEVICE_CB */
-       msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_REMOVE_DEVICE_INFO_CHANGED_CB;
-       msgsnd.sound_msg.msgid = instance;
-
-       if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-
-       /* Recieve */
-       if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-
-       switch (msgrcv.sound_msg.msgtype)
-       {
-       case MM_SOUND_MSG_RES_REMOVE_DEVICE_INFO_CHANGED_CB:
-               debug_msg("[Client] Success to remove device info changed callback\n");
-               break;
-       case MM_SOUND_MSG_RES_ERROR:
-               debug_error("[Client] Error occurred \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       default:
-               debug_critical("[Client] Unexpected state with communication \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       }
-
-cleanup:
-       pthread_mutex_unlock(&g_thread_mutex);
-
-       debug_fleave();
-       return ret;
-}
-
-#ifdef USE_FOCUS
-int _mm_sound_client_msgq_register_focus(int id, const char *stream_type, mm_sound_focus_changed_cb callback, void* user_data)
-{
-       mm_ipc_msg_t msgrcv = {0,};
-       mm_ipc_msg_t msgsnd = {0,};
-       int ret = MM_ERROR_NONE;
-       int instance;
-
-       debug_fenter();
-
-       ret = __mm_sound_client_get_msg_queue();
-       if (ret  != MM_ERROR_NONE) {
-               return ret;
-       }
-
-       pthread_mutex_lock(&g_thread_mutex2);
-
-       instance = getpid();
-       /* Send REQ_REGISTER_FOCUS */
-       msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_REGISTER_FOCUS;
-       msgsnd.sound_msg.msgid = instance;
-       msgsnd.sound_msg.handle_id = id;
-       msgsnd.sound_msg.callback = callback;
-       msgsnd.sound_msg.cbdata = user_data;
-       MMSOUND_STRNCPY(msgsnd.sound_msg.stream_type, stream_type, MAX_STREAM_TYPE_LEN);
-
-       if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-
-       /* Recieve */
-       if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-
-       switch (msgrcv.sound_msg.msgtype)       {
-       case MM_SOUND_MSG_RES_REGISTER_FOCUS:
-               debug_msg("[Client] Success to register focus\n");
-               if (g_thread_id2 == -1) {
-                       g_thread_id2 = pthread_create(&g_thread2, NULL, callbackfunc_send_reply, NULL);
-                       if (g_thread_id2 == -1) {
-                               debug_error("[Client] Fail to create thread %s\n", strerror(errno));
-                               ret = MM_ERROR_SOUND_INTERNAL;
-                               goto cleanup;
-                       }
-               }
-               break;
-       case MM_SOUND_MSG_RES_ERROR:
-               debug_error("[Client] Error occurred \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       default:
-               debug_error("[Client] Unexpected state with communication \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       }
-
-cleanup:
-       pthread_mutex_unlock(&g_thread_mutex2);
-
-       debug_fleave();
-       return ret;
-}
-
-int _mm_sound_client_msgq_unregister_focus(int id)
-{
-       mm_ipc_msg_t msgrcv = {0,};
-       mm_ipc_msg_t msgsnd = {0,};
-       int ret = MM_ERROR_NONE;
-       int instance;
-
-       debug_fenter();
-
-       ret = __mm_sound_client_get_msg_queue();
-       if (ret  != MM_ERROR_NONE) {
-               return ret;
-       }
-
-       pthread_mutex_lock(&g_thread_mutex2);
-
-       instance = getpid();
-       /* Send REQ_UNREGISTER_FOCUS */
-       msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_UNREGISTER_FOCUS;
-       msgsnd.sound_msg.msgid = instance;
-       msgsnd.sound_msg.handle_id = id;
-
-       if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-
-       /* Recieve */
-       if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-
-       switch (msgrcv.sound_msg.msgtype)       {
-       case MM_SOUND_MSG_RES_UNREGISTER_FOCUS:
-               debug_msg("[Client] Success to unregister focus\n");
-               break;
-       case MM_SOUND_MSG_RES_ERROR:
-               debug_error("[Client] Error occurred \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       default:
-               debug_error("[Client] Unexpected state with communication \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       }
-
-cleanup:
-       pthread_mutex_unlock(&g_thread_mutex2);
-
-       debug_fleave();
-       return ret;
-}
-
-int _mm_sound_client_msgq_acquire_focus(int id, mm_sound_focus_type_e type, const char *option)
-{
-       mm_ipc_msg_t msgrcv = {0,};
-       mm_ipc_msg_t msgsnd = {0,};
-       int ret = MM_ERROR_NONE;
-       int instance;
-
-       debug_fenter();
-
-       ret = __mm_sound_client_get_msg_queue();
-       if (ret  != MM_ERROR_NONE) {
-               return ret;
-       }
-
-       pthread_mutex_lock(&g_thread_mutex2);
-
-       instance = getpid();
-       /* Send REQ_ACQUIRE_FOCUS */
-       msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_ACQUIRE_FOCUS;
-       msgsnd.sound_msg.msgid = instance;
-       msgsnd.sound_msg.handle_id = id;
-       msgsnd.sound_msg.focus_type = (int)type;
-       MMSOUND_STRNCPY(msgsnd.sound_msg.name, option, MM_SOUND_NAME_NUM);
-
-       if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-
-       /* Recieve */
-       if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-
-       switch (msgrcv.sound_msg.msgtype)       {
-       case MM_SOUND_MSG_RES_ACQUIRE_FOCUS:
-               debug_msg("[Client] Success to acquire focus\n");
-               break;
-       case MM_SOUND_MSG_RES_ERROR:
-               debug_error("[Client] Error occurred \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       default:
-               debug_error("[Client] Unexpected state with communication \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       }
-
-cleanup:
-       pthread_mutex_unlock(&g_thread_mutex2);
-
-       debug_fleave();
-       return ret;
-}
-
-int _mm_sound_client_msgq_release_focus(int id, mm_sound_focus_type_e type, const char *option)
-{
-       mm_ipc_msg_t msgrcv = {0,};
-       mm_ipc_msg_t msgsnd = {0,};
-       int ret = MM_ERROR_NONE;
-       int instance;
-
-       debug_fenter();
-
-       ret = __mm_sound_client_get_msg_queue();
-       if (ret  != MM_ERROR_NONE) {
-               return ret;
-       }
-
-       pthread_mutex_lock(&g_thread_mutex2);
-
-       instance = getpid();
-       /* Send REQ_RELEASE_FOCUS */
-       msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_RELEASE_FOCUS;
-       msgsnd.sound_msg.msgid = instance;
-       msgsnd.sound_msg.handle_id = id;
-       msgsnd.sound_msg.focus_type = (int)type;
-       MMSOUND_STRNCPY(msgsnd.sound_msg.name, option, MM_SOUND_NAME_NUM);
-
-       if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-
-       /* Recieve */
-       if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-
-       switch (msgrcv.sound_msg.msgtype)       {
-       case MM_SOUND_MSG_RES_RELEASE_FOCUS:
-               debug_msg("[Client] Success to release focus\n");
-               break;
-       case MM_SOUND_MSG_RES_ERROR:
-               debug_error("[Client] Error occurred \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       default:
-               debug_error("[Client] Unexpected state with communication \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       }
-
-cleanup:
-       pthread_mutex_unlock(&g_thread_mutex2);
-
-       debug_fleave();
-       return ret;
-}
-
-int _mm_sound_client_msgq_set_focus_watch_callback(mm_sound_focus_type_e focus_type, mm_sound_focus_changed_watch_cb callback, void* user_data)
-{
-       mm_ipc_msg_t msgrcv = {0,};
-       mm_ipc_msg_t msgsnd = {0,};
-       int ret = MM_ERROR_NONE;
-       int instance;
-
-       debug_fenter();
-
-       ret = __mm_sound_client_get_msg_queue();
-       if (ret  != MM_ERROR_NONE) {
-               return ret;
-       }
-
-       pthread_mutex_lock(&g_thread_mutex2);
-
-       instance = getpid();
-       /* Send REQ_SET_FOCUS_WATCH_CB */
-       msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_SET_FOCUS_WATCH_CB;
-       msgsnd.sound_msg.msgid = instance;
-       msgsnd.sound_msg.focus_type = focus_type;
-       msgsnd.sound_msg.callback = callback;
-       msgsnd.sound_msg.cbdata = user_data;
-
-       if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-
-       /* Recieve */
-       if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-
-       switch (msgrcv.sound_msg.msgtype)       {
-       case MM_SOUND_MSG_RES_SET_FOCUS_WATCH_CB:
-               debug_msg("[Client] Success to set focus watch callback\n");
-               if (g_thread_id2 == -1) {
-                       g_thread_id2 = pthread_create(&g_thread2, NULL, callbackfunc_send_reply, NULL);
-                       if (g_thread_id2 == -1) {
-                               debug_error("[Client] Fail to create thread %s\n", strerror(errno));
-                               ret = MM_ERROR_SOUND_INTERNAL;
-                               goto cleanup;
-                       }
-               }
-               break;
-       case MM_SOUND_MSG_RES_ERROR:
-               debug_error("[Client] Error occurred \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       default:
-               debug_error("[Client] Unexpected state with communication \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       }
-
-cleanup:
-       pthread_mutex_unlock(&g_thread_mutex2);
-
-       debug_fleave();
-       return ret;
-}
-
-int _mm_sound_client_msgq_unset_focus_watch_callback(void)
-{
-       mm_ipc_msg_t msgrcv = {0,};
-       mm_ipc_msg_t msgsnd = {0,};
-       int ret = MM_ERROR_NONE;
-       int instance;
-
-       debug_fenter();
-
-       ret = __mm_sound_client_get_msg_queue();
-       if (ret  != MM_ERROR_NONE) {
-               return ret;
-       }
-
-       pthread_mutex_lock(&g_thread_mutex2);
-
-       instance = getpid();
-       /* Send REQ_UNREGISTER_FOCUS */
-       msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_UNSET_FOCUS_WATCH_CB;
-       msgsnd.sound_msg.msgid = instance;
-
-       if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-
-       /* Recieve */
-       if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-
-       switch (msgrcv.sound_msg.msgtype)       {
-       case MM_SOUND_MSG_RES_UNSET_FOCUS_WATCH_CB:
-               debug_msg("[Client] Success to unset focus watch callback\n");
-               break;
-       case MM_SOUND_MSG_RES_ERROR:
-               debug_error("[Client] Error occurred \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       default:
-               debug_error("[Client] Unexpected state with communication \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       }
-
-cleanup:
-       pthread_mutex_unlock(&g_thread_mutex2);
-
-       debug_fleave();
-       return ret;
-}
-#endif
-
-int _mm_sound_client_msgq_is_route_available(mm_sound_route route, bool *is_available)
-{
-       mm_ipc_msg_t msgrcv = {0,};
-       mm_ipc_msg_t msgsnd = {0,};
-       int ret = MM_ERROR_NONE;
-       int instance;
-
-       debug_fenter();
-
-       *is_available = FALSE;
-
-       ret = __mm_sound_client_get_msg_queue();
-       if (ret  != MM_ERROR_NONE) {
-               return ret;
-       }
-
-       pthread_mutex_lock(&g_thread_mutex);
-
-       instance = getpid();
-       /* Send REQ_IS_ROUTE_AVAILABLE */
-       msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_IS_ROUTE_AVAILABLE;
-       msgsnd.sound_msg.msgid = instance;
-       msgsnd.sound_msg.route = route;
-
-       if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-
-       /* Receive */
-       if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-
-       switch (msgrcv.sound_msg.msgtype)
-       {
-       case MM_SOUND_MSG_RES_IS_ROUTE_AVAILABLE:
-               *is_available = msgrcv.sound_msg.is_available;
-               debug_msg("[Client] Success to check given route is available %d\n", *is_available);
-               break;
-       case MM_SOUND_MSG_RES_ERROR:
-               debug_error("[Client] Error occurred \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       default:
-               debug_critical("[Client] Unexpected state with communication \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       }
-
-cleanup:
-       pthread_mutex_unlock(&g_thread_mutex);
-
-       debug_fleave();
-       return ret;
-}
-
-static int _handle_foreach_callback(mm_ipc_msg_t *msg)
-{
-       int route_index;
-       mm_sound_route route;
-
-       debug_fenter();
-
-       if (msg->sound_msg.callback == NULL) {
-               debug_error ("[Client] Foreach callback is [%p], cbdata = %p => exit",
-                               msg->sound_msg.callback, msg->sound_msg.cbdata);
-               return MM_ERROR_SOUND_INTERNAL;
-       }
-
-       for (route_index = 0; route_index < MM_SOUND_ROUTE_NUM; route_index++) {
-               route = msg->sound_msg.route_list[route_index];
-               if (route == 0) {
-                       break;
-               }
-               debug_msg("[Client] available route : %d\n", route);
-               if (((mm_sound_available_route_cb)msg->sound_msg.callback)(route, msg->sound_msg.cbdata) == false) {
-                       debug_msg ("[Client] user doesn't want anymore. quit loop!!\n");
-                       break;
-               }
-       }
-
-       debug_fleave();
-
-       return MM_ERROR_NONE;
-}
-
-int _mm_sound_client_msgq_foreach_available_route_cb(mm_sound_available_route_cb available_route_cb, void *user_data)
-{
-       mm_ipc_msg_t msgrcv = {0,};
-       mm_ipc_msg_t msgsnd = {0,};
-       int ret = MM_ERROR_NONE;
-       int instance;
-
-       debug_fenter();
-
-       ret = __mm_sound_client_get_msg_queue();
-       if (ret  != MM_ERROR_NONE) {
-               return ret;
-       }
-
-       pthread_mutex_lock(&g_thread_mutex);
-
-       instance = getpid();
-       /* Send REQ_FOREACH_AVAILABLE_ROUTE_CB */
-       msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_FOREACH_AVAILABLE_ROUTE_CB;
-       msgsnd.sound_msg.msgid = instance;
-       msgsnd.sound_msg.callback = (void *)available_route_cb;
-       msgsnd.sound_msg.cbdata = (void *)user_data;
-
-       if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-
-       /* Recieve */
-       if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-
-       switch (msgrcv.sound_msg.msgtype)
-       {
-       case MM_SOUND_MSG_RES_FOREACH_AVAILABLE_ROUTE_CB:
-               debug_msg("[Client] Success to set foreach available route callback\n");
-               msgrcv.sound_msg.callback = (void *)available_route_cb;
-               msgrcv.sound_msg.cbdata = (void *)user_data;
-               ret = _handle_foreach_callback (&msgrcv);
-               break;
-       case MM_SOUND_MSG_RES_ERROR:
-               debug_error("[Client] Error occurred \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       default:
-               debug_critical("[Client] Unexpected state with communication \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       }
-
-cleanup:
-       pthread_mutex_unlock(&g_thread_mutex);
-
-       debug_fleave();
-       return ret;
-}
-
-int _mm_sound_client_msgq_set_active_route(mm_sound_route route, bool need_broadcast)
-{
-       mm_ipc_msg_t msgrcv = {0,};
-       mm_ipc_msg_t msgsnd = {0,};
-       int ret = MM_ERROR_NONE;
-       int instance;
-
-       debug_fenter();
-
-       ret = __mm_sound_client_get_msg_queue();
-       if (ret  != MM_ERROR_NONE) {
-               return ret;
-       }
-
-       pthread_mutex_lock(&g_thread_mutex);
-
-       instance = getpid();
-       /* Send REQ_SET_ACTIVE_ROUTE */
-       msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_SET_ACTIVE_ROUTE;
-       msgsnd.sound_msg.msgid = instance;
-       msgsnd.sound_msg.route = route;
-       msgsnd.sound_msg.need_broadcast = need_broadcast;
-
-       if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE)
-               goto cleanup;
-
-       /* Recieve */
-       if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-
-       switch (msgrcv.sound_msg.msgtype)
-       {
-       case MM_SOUND_MSG_RES_SET_ACTIVE_ROUTE:
-               debug_msg("[Client] Success to add active device callback\n");
-               break;
-       case MM_SOUND_MSG_RES_ERROR:
-               debug_error("[Client] Error occurred \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       default:
-               debug_critical("[Client] Unexpected state with communication \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       }
-
-cleanup:
-       pthread_mutex_unlock(&g_thread_mutex);
-
-       debug_fleave();
-       return ret;
-}
-
-int _mm_sound_client_msgq_set_active_route_auto(void)
-{
-       mm_ipc_msg_t msgrcv = {0,};
-       mm_ipc_msg_t msgsnd = {0,};
-       int ret = MM_ERROR_NONE;
-       int instance;
-
-       debug_fenter();
-
-       ret = __mm_sound_client_get_msg_queue();
-       if (ret  != MM_ERROR_NONE) {
-               return ret;
-       }
-
-       pthread_mutex_lock(&g_thread_mutex);
-
-       instance = getpid();
-       /* Send REQ_SET_ACTIVE_ROUTE */
-       msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_SET_ACTIVE_ROUTE_AUTO;
-       msgsnd.sound_msg.msgid = instance;
-
-       if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-
-       /* Recieve */
-       if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-
-       switch (msgrcv.sound_msg.msgtype)
-       {
-       case MM_SOUND_MSG_RES_SET_ACTIVE_ROUTE_AUTO:
-               debug_msg("[Client] Success to set active device auto\n");
-               break;
-       case MM_SOUND_MSG_RES_ERROR:
-               debug_error("[Client] Error occurred \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       default:
-               debug_critical("[Client] Unexpected state with communication \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       }
-
-cleanup:
-       pthread_mutex_unlock(&g_thread_mutex);
-
-       debug_fleave();
-       return ret;
-}
-
-int _mm_sound_client_msgq_get_active_device(mm_sound_device_in *device_in, mm_sound_device_out *device_out)
-{
-       mm_ipc_msg_t msgrcv = {0,};
-       mm_ipc_msg_t msgsnd = {0,};
-       int ret = MM_ERROR_NONE;
-       int instance;
-
-       debug_fenter();
-
-       ret = __mm_sound_client_get_msg_queue();
-       if (ret  != MM_ERROR_NONE) {
-               return ret;
-       }
-
-       pthread_mutex_lock(&g_thread_mutex);
-
-       instance = getpid();
-       /* Send REQ_GET_ACTIVE_DEVICE */
-       msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_GET_ACTIVE_DEVICE;
-       msgsnd.sound_msg.msgid = instance;
-
-       if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-
-       /* Recieve */
-       if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-
-       switch (msgrcv.sound_msg.msgtype)
-       {
-       case MM_SOUND_MSG_RES_GET_ACTIVE_DEVICE:
-               *device_in = msgrcv.sound_msg.device_in;
-               *device_out = msgrcv.sound_msg.device_out;
-               debug_log("[Client] Success to get active device in=[%x], out=[%x]\n", *device_in, *device_out);
-               break;
-       case MM_SOUND_MSG_RES_ERROR:
-               debug_error("[Client] Error occurred \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       default:
-               debug_critical("[Client] Unexpected state with communication \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       }
-
-cleanup:
-       pthread_mutex_unlock(&g_thread_mutex);
-
-       debug_fleave();
-       return ret;
-}
-
-int _mm_sound_client_msgq_get_audio_path(mm_sound_device_in *device_in, mm_sound_device_out *device_out)
-{
-       mm_ipc_msg_t msgrcv = {0,};
-       mm_ipc_msg_t msgsnd = {0,};
-       int ret = MM_ERROR_NONE;
-       int instance;
-
-       debug_fenter();
-
-       ret = __mm_sound_client_get_msg_queue();
-       if (ret  != MM_ERROR_NONE) {
-               return ret;
-       }
-
-       pthread_mutex_lock(&g_thread_mutex);
-
-       instance = getpid();
-       /* Send REQ_GET_AUDIO_PATH */
-       msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_GET_AUDIO_PATH;
-       msgsnd.sound_msg.msgid = instance;
-
-       if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-
-       /* Recieve */
-       if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-
-       switch (msgrcv.sound_msg.msgtype)
-       {
-       case MM_SOUND_MSG_RES_GET_AUDIO_PATH:
-               *device_in = msgrcv.sound_msg.device_in;
-               *device_out = msgrcv.sound_msg.device_out;
-               debug_log("[Client] Success to get active device in=[%x], out=[%x]\n", *device_in, *device_out);
-               break;
-       case MM_SOUND_MSG_RES_ERROR:
-               debug_error("[Client] Error occurred \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       default:
-               debug_critical("[Client] Unexpected state with communication \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       }
-
-cleanup:
-       pthread_mutex_unlock(&g_thread_mutex);
-
-       debug_fleave();
-       return ret;
-}
-
-int _mm_sound_client_msgq_add_active_device_changed_callback(const char *name, mm_sound_active_device_changed_cb func, void* user_data)
-{
-       mm_ipc_msg_t msgrcv = {0,};
-       mm_ipc_msg_t msgsnd = {0,};
-       int ret = MM_ERROR_NONE;
-       int instance;
-
-       debug_fenter();
-
-       ret = __mm_sound_client_get_msg_queue();
-       if (ret  != MM_ERROR_NONE) {
-               return ret;
-       }
-
-       pthread_mutex_lock(&g_thread_mutex);
-
-       instance = getpid();
-       /* Send REQ_ADD_ACTIVE_DEVICE_CB */
-       msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_ADD_ACTIVE_DEVICE_CB;
-       msgsnd.sound_msg.msgid = instance;
-       msgsnd.sound_msg.callback = func;
-       msgsnd.sound_msg.cbdata = user_data;
-       MMSOUND_STRNCPY(msgsnd.sound_msg.name, name, MM_SOUND_NAME_NUM);
-
-       if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-
-       /* Recieve */
-       if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-
-       switch (msgrcv.sound_msg.msgtype)
-       {
-       case MM_SOUND_MSG_RES_ADD_ACTIVE_DEVICE_CB:
-               debug_msg("[Client] Success to add active device callback\n");
-               if (g_thread_id == -1)
-               {
-                       g_thread_id = pthread_create(&g_thread, NULL, callbackfunc, NULL);
-                       if (g_thread_id == -1)
-                       {
-                               debug_critical("[Client] Fail to create thread %s\n", strerror(errno));
-                               ret = MM_ERROR_SOUND_INTERNAL;
-                               goto cleanup;
-                       }
-               }
-               break;
-       case MM_SOUND_MSG_RES_ERROR:
-               debug_error("[Client] Error occurred \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       default:
-               debug_critical("[Client] Unexpected state with communication \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       }
-
-cleanup:
-       pthread_mutex_unlock(&g_thread_mutex);
-
-       debug_fleave();
-       return ret;
-}
-
-int _mm_sound_client_msgq_remove_active_device_changed_callback(const char *name)
-{
-       mm_ipc_msg_t msgrcv = {0,};
-       mm_ipc_msg_t msgsnd = {0,};
-       int ret = MM_ERROR_NONE;
-       int instance;
-
-       debug_fenter();
-
-       ret = __mm_sound_client_get_msg_queue();
-       if (ret  != MM_ERROR_NONE) {
-               return ret;
-       }
-
-       pthread_mutex_lock(&g_thread_mutex);
-
-       instance = getpid();
-       /* Send REQ_REMOVE_ACTIVE_DEVICE_CB */
-       msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_REMOVE_ACTIVE_DEVICE_CB;
-       msgsnd.sound_msg.msgid = instance;
-       MMSOUND_STRNCPY(msgsnd.sound_msg.name, name, MM_SOUND_NAME_NUM);
-
-       if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-
-       /* Recieve */
-       if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-
-       switch (msgrcv.sound_msg.msgtype)
-       {
-       case MM_SOUND_MSG_RES_REMOVE_ACTIVE_DEVICE_CB:
-               debug_msg("[Client] Success to remove active device callback\n");
-               break;
-       case MM_SOUND_MSG_RES_ERROR:
-               debug_error("[Client] Error occurred \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       default:
-               debug_critical("[Client] Unexpected state with communication \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       }
-
-cleanup:
-       pthread_mutex_unlock(&g_thread_mutex);
-
-       debug_fleave();
-       return ret;
-}
-
-int _mm_sound_client_msgq_add_volume_changed_callback(mm_sound_volume_changed_cb func, void* user_data)
-{
-       mm_ipc_msg_t msgrcv = {0,};
-       mm_ipc_msg_t msgsnd = {0,};
-       int ret = MM_ERROR_NONE;
-       int instance;
-
-       debug_fenter();
-
-       ret = __mm_sound_client_get_msg_queue();
-       if (ret  != MM_ERROR_NONE) {
-               return ret;
-       }
-
-       pthread_mutex_lock(&g_thread_mutex);
-
-       instance = getpid();
-       /* Send REQ_ADD_VOLUME_CB */
-       msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_ADD_VOLUME_CB;
-       msgsnd.sound_msg.msgid = instance;
-       msgsnd.sound_msg.callback = func;
-       msgsnd.sound_msg.cbdata = user_data;
-
-       if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-
-       /* Recieve */
-       if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-
-       switch (msgrcv.sound_msg.msgtype)
-       {
-       case MM_SOUND_MSG_RES_ADD_VOLUME_CB:
-               debug_msg("[Client] Success to add volume callback\n");
-               if (g_thread_id == -1)
-               {
-                       g_thread_id = pthread_create(&g_thread, NULL, callbackfunc, NULL);
-                       if (g_thread_id == -1)
-                       {
-                               debug_critical("[Client] Fail to create thread %s\n", strerror(errno));
-                               ret = MM_ERROR_SOUND_INTERNAL;
-                               goto cleanup;
-                       }
-               }
-               break;
-       case MM_SOUND_MSG_RES_ERROR:
-               debug_error("[Client] Error occurred \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       default:
-               debug_critical("[Client] Unexpected state with communication \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       }
-
-cleanup:
-       pthread_mutex_unlock(&g_thread_mutex);
-
-       debug_fleave();
-       return ret;
-}
-
-int _mm_sound_client_msgq_remove_volume_changed_callback(void)
-{
-       mm_ipc_msg_t msgrcv = {0,};
-       mm_ipc_msg_t msgsnd = {0,};
-       int ret = MM_ERROR_NONE;
-       int instance;
-
-       debug_fenter();
-
-       ret = __mm_sound_client_get_msg_queue();
-       if (ret  != MM_ERROR_NONE) {
-               return ret;
-       }
-
-       pthread_mutex_lock(&g_thread_mutex);
-
-       instance = getpid();
-       /* Send REQ_REMOVE_VOLUME_CB */
-       msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_REMOVE_VOLUME_CB;
-       msgsnd.sound_msg.msgid = instance;
-
-       if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-
-       /* Recieve */
-       if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-
-       switch (msgrcv.sound_msg.msgtype)
-       {
-       case MM_SOUND_MSG_RES_REMOVE_VOLUME_CB:
-               debug_msg("[Client] Success to remove volume callback\n");
-               break;
-       case MM_SOUND_MSG_RES_ERROR:
-               debug_error("[Client] Error occurred \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       default:
-               debug_critical("[Client] Unexpected state with communication \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       }
-
-cleanup:
-       pthread_mutex_unlock(&g_thread_mutex);
-
-       debug_fleave();
-       return ret;
-}
-
-int _mm_sound_client_msgq_add_available_route_changed_callback(mm_sound_available_route_changed_cb func, void* user_data)
-{
-       mm_ipc_msg_t msgrcv = {0,};
-       mm_ipc_msg_t msgsnd = {0,};
-       int ret = MM_ERROR_NONE;
-       int instance;
-
-       debug_fenter();
-
-       ret = __mm_sound_client_get_msg_queue();
-       if (ret  != MM_ERROR_NONE) {
-               return ret;
-       }
-
-       pthread_mutex_lock(&g_thread_mutex);
-
-       instance = getpid();
-       /* Send REQ_ADD_AVAILABLE_ROUTE_CB */
-       msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_ADD_AVAILABLE_ROUTE_CB;
-       msgsnd.sound_msg.msgid = instance;
-       msgsnd.sound_msg.callback = func;
-       msgsnd.sound_msg.cbdata = user_data;
-
-       if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-
-       /* Recieve */
-       if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-
-       switch (msgrcv.sound_msg.msgtype)
-       {
-       case MM_SOUND_MSG_RES_ADD_AVAILABLE_ROUTE_CB:
-               debug_msg("[Client] Success to add available route callback\n");
-               if (g_thread_id == -1)
-               {
-                       g_thread_id = pthread_create(&g_thread, NULL, callbackfunc, NULL);
-                       if (g_thread_id == -1)
-                       {
-                               debug_critical("[Client] Fail to create thread %s\n", strerror(errno));
-                               ret = MM_ERROR_SOUND_INTERNAL;
-                               goto cleanup;
-                       }
-               }
-               break;
-       case MM_SOUND_MSG_RES_ERROR:
-               debug_error("[Client] Error occurred \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       default:
-               debug_critical("[Client] Unexpected state with communication \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       }
-
-cleanup:
-       pthread_mutex_unlock(&g_thread_mutex);
-
-       debug_fleave();
-       return ret;
-}
-
-int _mm_sound_client_msgq_remove_available_route_changed_callback(void)
-{
-       mm_ipc_msg_t msgrcv = {0,};
-       mm_ipc_msg_t msgsnd = {0,};
-       int ret = MM_ERROR_NONE;
-       int instance;
-
-       debug_fenter();
-
-       ret = __mm_sound_client_get_msg_queue();
-       if (ret  != MM_ERROR_NONE) {
-               return ret;
-       }
-
-       pthread_mutex_lock(&g_thread_mutex);
-
-       instance = getpid();
-       /* Send REQ_REMOVE_AVAILABLE_ROUTE_CB */
-       msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_REMOVE_AVAILABLE_ROUTE_CB;
-       msgsnd.sound_msg.msgid = instance;
-
-       if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-
-       /* Recieve */
-       if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE) {
-               goto cleanup;
-       }
-
-       switch (msgrcv.sound_msg.msgtype)
-       {
-       case MM_SOUND_MSG_RES_REMOVE_AVAILABLE_ROUTE_CB:
-               debug_msg("[Client] Success to remove available route callback\n");
-               break;
-       case MM_SOUND_MSG_RES_ERROR:
-               debug_error("[Client] Error occurred \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       default:
-               debug_critical("[Client] Unexpected state with communication \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       }
-
-cleanup:
-       pthread_mutex_unlock(&g_thread_mutex);
-
-       debug_fleave();
-       return ret;
-}
-
-static int __MMIpcCBSndMsg(mm_ipc_msg_t *msg)
-{
-       /* rcv message */
-       msg->msg_type = msg->sound_msg.msgid;
-       if (msgsnd(g_msg_sccb, msg,DSIZE, 0)== -1)
-       {
-               debug_error("[Client] Fail to callback send message msgid : [%d], [%d][%s]", g_msg_sccb, errno, strerror(errno));
-               return MM_ERROR_COMMON_UNKNOWN;
-       }
-       return MM_ERROR_NONE;
-}
-
-static int __MMIpcCBRecvMsg(int msgtype, mm_ipc_msg_t *msg)
-{
-       /* rcv message */
-       if(msgrcv(g_msg_sccb, msg, DSIZE, msgtype, 0) == -1)
-       {
-               debug_error("[Client] Fail to callback receive message msgid : [%d], [%d][%s]", g_msg_sccb, errno, strerror(errno));
-               return MM_ERROR_COMMON_UNKNOWN;
-       }
-       return MM_ERROR_NONE;
-}
-
-static int __MMIpcCBSndMsgReply(mm_ipc_msg_t *msg)
-{
-       /* rcv message */
-       msg->msg_type = msg->sound_msg.msgid;
-       if (msgsnd(g_msg_scsndcb, msg, DSIZE, 0)== -1) {
-               debug_error("[Client] Fail to callback send message msgid : [%d], [%d][%s]", g_msg_scsndcb, errno, strerror(errno));
-               return MM_ERROR_COMMON_UNKNOWN;
-       }
-       return MM_ERROR_NONE;
-}
-
-static int __MMIpcCBRecvMsgForReply(int msgtype, mm_ipc_msg_t *msg)
-{
-       /* rcv message */
-       if(msgrcv(g_msg_scrcvcb, msg, DSIZE, msgtype, 0) == -1) {
-               debug_error("[Client] Fail to callback receive message msgid : [%d], [%d][%s]", g_msg_scrcvcb, errno, strerror(errno));
-               return MM_ERROR_COMMON_UNKNOWN;
-       }
-       return MM_ERROR_NONE;
-}
-
-#define MAX_RCV_RETRY 20000
-
-static int __MMIpcRecvMsg(int msgtype, mm_ipc_msg_t *msg)
-{
-       int retry_count = 0;
-
-       /* rcv message */
-       while (msgrcv(g_msg_scrcv, msg, DSIZE, msgtype, IPC_NOWAIT) == -1) {
-               if (errno == ENOMSG) {
-                       if (retry_count < MAX_RCV_RETRY) { /* usec is 10^-6 sec so, 5ms * 20000 = 10sec. */
-                               usleep(5000);
-                               retry_count++;
-                               continue;
-                       } else {
-                               debug_error("[Client] retry(%d) is over : [%d] \n", MAX_RCV_RETRY, g_msg_scrcv);
-                               return MM_ERROR_SOUND_INTERNAL;
-                       }
-               } else if (errno == EINTR) {
-                       debug_warning("[Client] Interrupted by signal, continue loop");
-                       continue;
-               }
-
-               debug_error("[Client] Fail to receive msgid : [%d], [%d][%s]", g_msg_scrcv, errno, strerror(errno));
-
-               return MM_ERROR_COMMON_UNKNOWN;
-       }
-       debug_log("[Client] Retry %d times when receive msg\n", retry_count);
-       return MM_ERROR_NONE;
-}
-
-static int __MMIpcSndMsg(mm_ipc_msg_t *msg)
-{
-       /* rcv message */
-       int try_again = 0;
-
-       msg->msg_type = msg->sound_msg.msgid;
-       while (msgsnd(g_msg_scsnd, msg,DSIZE, IPC_NOWAIT) == -1)
-       {
-               if(errno == EACCES) {
-                       debug_warning("Not acces.\n");
-               } else if(errno == EAGAIN || errno == ENOMEM) {
-                       mm_ipc_msg_t msgdata = {0,};
-                       debug_warning("Blocked process [msgflag & IPC_NOWAIT != 0]\n");
-                       debug_warning("The system does not have enough memory to make a copy of the message pointed to by msgp\n");
-                       /* wait 10 msec ,then it will try again */
-                       usleep(10000);
-                       /*  it will try 5 times, after 5 times ,if it still fail ,then it will clear the message queue */
-                       if (try_again <= 5) {
-                               try_again ++;
-                               continue;
-                       }
-                       /* message queue is full ,it need to clear the queue */
-                       while( msgrcv(g_msg_scsnd, &msgdata, DSIZE, 0, IPC_NOWAIT) != -1 ) {
-                               debug_warning("msg queue is full ,remove msgtype:[%d] from the queue",msgdata.sound_msg.msgtype);
-                       }
-                       try_again++;
-                       continue;
-               } else if(errno == EIDRM) {
-                       debug_warning("Removed msgid from system\n");
-               } else if(errno == EINTR) {
-                       debug_warning("Iterrrupted by singnal\n");
-               } else if(errno == EINVAL) {
-                       debug_warning("Invalid msgid or msgtype < 1 or out of data size \n");
-               } else if(errno == EFAULT) {
-                       debug_warning("The address pointed to by msgp isn't accessible \n");
-               }
-               debug_error("[Client] Fail to send message msgid : [%d], [%d][%s]", g_msg_scsnd, errno, strerror(errno));
-               return MM_ERROR_SOUND_INTERNAL;
-       }
-       return MM_ERROR_NONE;
-}
-
-static int __MMSoundGetMsg(void)
-{
-       /* Init message queue, generate msgid for communication to server */
-       /* The key value to get msgid is defined "mm_sound_msg.h". Shared with server */
-       int i = 0;
-
-       debug_fenter();
-
-       /* get msg queue rcv, snd, cb */
-       g_msg_scsnd = msgget(ftok(KEY_BASE_PATH, RCV_MSG), 0666);
-       g_msg_scrcv = msgget(ftok(KEY_BASE_PATH, SND_MSG), 0666);
-       g_msg_sccb = msgget(ftok(KEY_BASE_PATH, CB_MSG), 0666);
-       g_msg_scsndcb = msgget(ftok(KEY_BASE_PATH, RCV_CB_MSG), 0666);
-       g_msg_scrcvcb = msgget(ftok(KEY_BASE_PATH, SND_CB_MSG), 0666);
-
-       if ((g_msg_scsnd == -1 || g_msg_scrcv == -1 || g_msg_sccb == -1 || g_msg_scsndcb == -1 || g_msg_scrcvcb == -1) != MM_ERROR_NONE) {
-               if (errno == EACCES) {
-                       debug_warning("Require ROOT permission.\n");
-               } else if (errno == ENOMEM) {
-                       debug_warning("System memory is empty.\n");
-               } else if(errno == ENOSPC) {
-                       debug_warning("Resource is empty.\n");
-               }
-               /* Some app would start before Sound Server IPC ready. */
-               /* Let's try it again in 50ms later by 10 times */
-               for (i=0;i<10;i++) {
-                       usleep(50000);
-                       g_msg_scsnd = msgget(ftok(KEY_BASE_PATH, RCV_MSG), 0666);
-                       g_msg_scrcv = msgget(ftok(KEY_BASE_PATH, SND_MSG), 0666);
-                       g_msg_sccb = msgget(ftok(KEY_BASE_PATH, CB_MSG), 0666);
-                       g_msg_scsndcb = msgget(ftok(KEY_BASE_PATH, RCV_CB_MSG), 0666);
-                       g_msg_scrcvcb = msgget(ftok(KEY_BASE_PATH, SND_CB_MSG), 0666);
-                       if ((g_msg_scsnd == -1 || g_msg_scrcv == -1 || g_msg_sccb == -1 || g_msg_scsndcb == -1 || g_msg_scrcvcb == -1) != MM_ERROR_NONE) {
-                               debug_error("Fail to GET msgid by retrying %d times\n", i+1);
-                       } else
-                               break;
-               }
-               if ((g_msg_scsnd == -1 || g_msg_scrcv == -1 || g_msg_sccb == -1 || g_msg_scsndcb == -1 || g_msg_scrcvcb == -1) != MM_ERROR_NONE) {
-                       debug_error("Fail to GET msgid finally, just return internal error.\n");
-                       return MM_ERROR_SOUND_INTERNAL;
-               }
-       }
-
-       debug_log("Get msg queue id from server : snd[%d], rcv[%d], cb[%d], snd_cb[%d], rcv_cb[%d]\n",
-                       g_msg_scsnd, g_msg_scrcv, g_msg_sccb, g_msg_scsndcb, g_msg_scrcvcb);
-
-       debug_fleave();
-       return MM_ERROR_NONE;
-}
-
-#ifdef PULSE_CLIENT
-
-int MMSoundClientMsgqIsBtA2dpOn (bool *connected, char** bt_name)
-{
-       mm_ipc_msg_t msgrcv = {0,};
-       mm_ipc_msg_t msgsnd = {0,};
-       int ret = MM_ERROR_NONE;
-       int instance;
-
-       debug_fenter();
-
-       instance = getpid();
-
-       ret = __mm_sound_client_get_msg_queue();
-       if (ret  != MM_ERROR_NONE)
-               return ret;
-
-       pthread_mutex_lock(&g_thread_mutex);
-
-       /* Send req  */
-       msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_IS_BT_A2DP_ON;
-       msgsnd.sound_msg.msgid = instance;
-
-       ret = __MMIpcSndMsg(&msgsnd);
-       if (ret != MM_ERROR_NONE)
-       {
-               debug_error("Fail to send msg\n");
-               goto cleanup;
-       }
-
-       /* Receive */
-       ret = __MMIpcRecvMsg(instance, &msgrcv);
-       if (ret != MM_ERROR_NONE)
-       {
-               debug_error("Fail to recieve msg\n");
-               goto cleanup;
-       }
-       switch (msgrcv.sound_msg.msgtype)
-       {
-               case MM_SOUND_MSG_RES_IS_BT_A2DP_ON:
-                       debug_msg("Success to get IS_BT_A2DP_ON [%d][%s]\n", msgrcv.sound_msg.code, msgrcv.sound_msg.filename);
-                       *connected  = (bool)msgrcv.sound_msg.code;
-                       if (*connected)
-                               *bt_name = strdup (msgrcv.sound_msg.filename);
-                       else
-                               *bt_name = NULL;
-                       break;
-               case MM_SOUND_MSG_RES_ERROR:
-                       debug_error("Error occurred \n");
-                       ret = msgrcv.sound_msg.code;
-                       goto cleanup;
-                       break;
-               default:
-                       debug_critical("Unexpected state with communication \n");
-                       ret = msgrcv.sound_msg.code;
-                       goto cleanup;
-                       break;
-       }
-
-cleanup:
-               pthread_mutex_unlock(&g_thread_mutex);
-
-       debug_fleave();
-       return ret;
-}
-
-int _mm_sound_client_msgq_set_sound_path_for_active_device(mm_sound_device_out device_out, mm_sound_device_in device_in)
-{
-       mm_ipc_msg_t msgrcv = {0,};
-       mm_ipc_msg_t msgsnd = {0,};
-       int ret = MM_ERROR_NONE;
-       int instance;
-
-       debug_fenter();
-
-       ret = __mm_sound_client_get_msg_queue();
-       if (ret  != MM_ERROR_NONE)
-               return ret;
-
-       pthread_mutex_lock(&g_thread_mutex);
-
-       instance = getpid();
-       /* Send MM_SOUND_MSG_REQ_SET_PATH_FOR_ACTIVE_DEVICE */
-       msgsnd.sound_msg.msgtype = MM_SOUND_MSG_REQ_SET_PATH_FOR_ACTIVE_DEVICE;
-       msgsnd.sound_msg.msgid = instance;
-       msgsnd.sound_msg.device_in =  device_in;
-       msgsnd.sound_msg.device_out = device_out;
-
-       if (__MMIpcSndMsg(&msgsnd) != MM_ERROR_NONE)
-               goto cleanup;
-
-       /* Recieve */
-       if (__MMIpcRecvMsg(instance, &msgrcv) != MM_ERROR_NONE)
-               goto cleanup;
-
-       switch (msgrcv.sound_msg.msgtype)
-       {
-       case MM_SOUND_MSG_RES_SET_PATH_FOR_ACTIVE_DEVICE:
-               debug_msg("[Client] Success to setsound path for active device\n");
-               break;
-       case MM_SOUND_MSG_RES_ERROR:
-               debug_error("[Client] Error occurred \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       default:
-               debug_critical("[Client] Unexpected state with communication \n");
-               ret = msgrcv.sound_msg.code;
-               goto cleanup;
-               break;
-       }
-
-cleanup:
-       pthread_mutex_unlock(&g_thread_mutex);
-
-       debug_fleave();
-       return ret;
-}
-
-
-#endif // PULSE_CLIENT
index becd843..15ee574 100644 (file)
@@ -117,7 +117,7 @@ int mm_sound_play_keysound(const char *filename, int volume_config)
        ipc_t data = {{0,},{0,},{0,}};
        int capture_status = 0;
        char *role = NULL;
-       char *vol_gain_type = NULL;
+       const char *vol_gain_type = NULL;
 
        if (!filename)
                return MM_ERROR_SOUND_INVALID_FILE;
index c907ef3..011d273 100644 (file)
@@ -1150,7 +1150,6 @@ int mm_sound_pcm_play_write(MMSoundPcmHandle_t handle, void* ptr, unsigned int l
        int ret = 0;
        static int written_byte = 0;
        mm_sound_pcm_t *pcmHandle = (mm_sound_pcm_t*)handle;
-       int vr_state = 0;
 
        /* Check input param */
        if(pcmHandle == NULL) {
index 35914e3..6998c3c 100644 (file)
@@ -4,14 +4,7 @@ bin_PROGRAMS = sound_server
 sound_server_SOURCES = mm_sound_mgr_codec.c \
                                                mm_sound_mgr_ipc.c \
                                                mm_sound_mgr_ipc_dbus.c \
-                                               mm_sound_mgr_pulse.c \
                                                mm_sound_mgr_asm.c \
-                                               mm_sound_mgr_device.c \
-                                               mm_sound_mgr_device_headset.c \
-                                               mm_sound_mgr_device_dock.c \
-                                               mm_sound_mgr_device_hdmi.c \
-                                               mm_sound_mgr_device_wfd.c \
-                                               mm_sound_mgr_session.c \
                                                mm_sound_mgr_run.c \
                                                mm_sound_plugin.c \
                                                mm_sound_server.c \
@@ -28,8 +21,7 @@ sound_server_CFLAGS = -I$(srcdir)/../include \
                                          $(AUDIOSESSIONMGR_CFLAGS) \
                                          $(VCONF_CFLAGS) \
                                          $(GLIB2_CFLAGS) \
-                                         $(GIO_CFLAGS) \
-                                         $(HEYNOTI_CFLAGS)
+                                         $(GIO_CFLAGS)
 
 sound_server_LDADD = $(MMLOGSVR_LIBS) \
                     -ldl -lrt \
@@ -39,7 +31,6 @@ sound_server_LDADD = $(MMLOGSVR_LIBS) \
                     $(GLIB2_LIBS) \
                     $(GIO_LIBS) \
                     $(VCONF_LIBS) \
-                    $(HEYNOTI_LIBS) \
                     $(srcdir)/../libmmfsound.la \
                     $(srcdir)/../common/libmmfsoundcommon.la
 
diff --git a/server/include/mm_sound_mgr_device.h b/server/include/mm_sound_mgr_device.h
deleted file mode 100644 (file)
index 5daf64d..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * libmm-sound
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Seungbae Shin <seungbae.shin@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-#ifndef __MM_SOUND_MGR_DEVICE_H__
-#define __MM_SOUND_MGR_DEVICE_H__
-
-#if 0
-#include "../include/mm_sound.h"
-#include "../include/mm_sound_device.h"
-#include "../include/mm_ipc.h"
-
-typedef struct {
-       int pid;
-       mm_sound_route route;
-       void *callback;
-       void *cbdata;
-       int device_flags;
-       bool need_broadcast;
-       char name[MM_SOUND_NAME_NUM];
-} _mm_sound_mgr_device_param_t;
-
-typedef enum
-{
-       DEVICE_EARJACK_TYPE_SPK_WITH_MIC = 3,
-} device_earjack_type_e;
-
-#define DEVICE_ID_AUTO      -1
-
-#define DEVICE_NAME_BUILTIN_SPK       "built-in speaker"
-#define DEVICE_NAME_BUILTIN_RCV       "built-in receiver"
-#define DEVICE_NAME_BUILTIN_MIC       "built-in mic"
-#define DEVICE_NAME_AUDIOJACK_3P      "headphone"
-#define DEVICE_NAME_AUDIOJACK_4P      "headset"
-#define DEVICE_NAME_HDMI              "hdmi"
-#define DEVICE_NAME_MIRRORING         "mirroring"
-
-int _mm_sound_mgr_device_init(void);
-int _mm_sound_mgr_device_fini(void);
-int _mm_sound_mgr_device_is_route_available(const _mm_sound_mgr_device_param_t *param, bool *is_available);
-int _mm_sound_mgr_device_foreach_available_route_cb(mm_ipc_msg_t *msg);
-int _mm_sound_mgr_device_active_device_callback(mm_sound_device_in device_in, mm_sound_device_out device_out);
-int _mm_sound_mgr_device_available_device_callback(mm_sound_device_in device_in, mm_sound_device_out device_out, bool available);
-int _mm_sound_mgr_device_get_volume_value_by_active_device(char *buf, mm_sound_device_out device_out, unsigned int *value);
-int _mm_sound_mgr_device_set_volume_value_by_active_device(char *buf, mm_sound_device_out device_out, int value);
-int _mm_sound_mgr_device_set_sound_path_for_active_device(mm_sound_device_out playback, mm_sound_device_in capture);
-int _mm_sound_mgr_device_add_volume_callback(const _mm_sound_mgr_device_param_t *param);
-int _mm_sound_mgr_device_remove_volume_callback(const _mm_sound_mgr_device_param_t *param);
-int _mm_sound_mgr_device_get_audio_path(mm_sound_device_in *device_in, mm_sound_device_out *device_out);
-int _mm_sound_mgr_device_get_current_connected_dev_list(int device_flags, mm_sound_device_t **device_list, int *dev_num);
-int _mm_sound_mgr_device_add_connected_callback(const _mm_sound_mgr_device_param_t *param);
-int _mm_sound_mgr_device_remove_connected_callback(const _mm_sound_mgr_device_param_t *param);
-int _mm_sound_mgr_device_add_info_changed_callback(const _mm_sound_mgr_device_param_t *param);
-int _mm_sound_mgr_device_remove_info_changed_callback(const _mm_sound_mgr_device_param_t *param);
-int MMSoundMgrDeviceGetIoDirectionById (int id, device_io_direction_e *io_direction);
-int MMSoundMgrDeviceUpdateStatus (device_update_status_e update_status, device_type_e device_type, device_io_direction_e io_direction, int id, const char* name, device_state_e state, int *alloc_id);
-int MMSoundMgrDeviceUpdateStatusWithoutNotification (device_update_status_e update_status, device_type_e device_type, device_io_direction_e io_direction, int id, const char* name, device_state_e state, int *alloc_id);
-
-#endif
-#endif /* __MM_SOUND_MGR_DEVICE_H__ */
-
diff --git a/server/include/mm_sound_mgr_device_dock.h b/server/include/mm_sound_mgr_device_dock.h
deleted file mode 100644 (file)
index c7f9a13..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * libmm-sound
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Seungbae Shin <seungbae.shin@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef __MM_SOUND_MGR_DOCK_H__
-#define __MM_SOUND_MGR_DOCK_H__
-
-#include "../../include/mm_ipc.h"
-
-#if 0
-typedef enum
-{
-       DOCK_NONE      = 0,
-       DOCK_DESKDOCK  = 1,
-       DOCK_CARDOCK   = 2,
-       DOCK_AUDIODOCK = 7,
-       DOCK_SMARTDOCK = 8
-} DOCK_STATUS;
-
-int MMSoundMgrDockInit(void);
-int MMSoundMgrDockFini(void);
-#endif
-
-
-#endif /* __MM_SOUND_MGR_DOCK_H__ */
-
diff --git a/server/include/mm_sound_mgr_device_hdmi.h b/server/include/mm_sound_mgr_device_hdmi.h
deleted file mode 100644 (file)
index 73403cc..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * libmm-sound
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Seungbae Shin <seungbae.shin@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef __MM_SOUND_MGR_HDMI_H__
-#define __MM_SOUND_MGR_HDMI_H__
-
-#if 0
-int MMSoundMgrHdmiInit(void);
-int MMSoundMgrHdmiFini(void);
-#endif
-
-
-#endif /* __MM_SOUND_MGR_HDMI_H__ */
-
diff --git a/server/include/mm_sound_mgr_device_headset.h b/server/include/mm_sound_mgr_device_headset.h
deleted file mode 100644 (file)
index c20f694..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * libmm-sound
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Seungbae Shin <seungbae.shin@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef __MM_SOUND_MGR_HEADSET_H__
-#define __MM_SOUND_MGR_HEADSET_H__
-
-#include "../../include/mm_ipc.h"
-
-#if 0
-int MMSoundMgrHeadsetInit(void);
-int MMSoundMgrHeadsetFini(void);
-#endif
-
-#endif /* __MM_SOUND_MGR_HEADSET_H__ */
-
diff --git a/server/include/mm_sound_mgr_device_wfd.h b/server/include/mm_sound_mgr_device_wfd.h
deleted file mode 100644 (file)
index 14f30ed..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * libmm-sound
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Seungbae Shin <seungbae.shin@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef __MM_SOUND_MGR_WFD_H__
-#define __MM_SOUND_MGR_WFD_H__
-
-#if 0
-int MMSoundMgrWfdInit(void);
-int MMSoundMgrWfdFini(void);
-#endif
-
-
-#endif /* __MM_SOUND_MGR_WFD_H__ */
-
diff --git a/server/include/mm_sound_mgr_ipc_msgq.h b/server/include/mm_sound_mgr_ipc_msgq.h
deleted file mode 100644 (file)
index 1d6fa76..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * libmm-sound
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Seungbae Shin <seungbae.shin@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef __MM_SOUND_MGR_IPC_MSGQ_H__
-#define __MM_SOUND_MGR_IPC_MSGQ_H__
-
-#include "../../include/mm_sound_msg.h"
-
-#define SOUND_MSG_SET(sound_msg, x_msgtype, x_handle, x_code, x_msgid) \
-do { \
-       sound_msg.msgtype = x_msgtype; \
-       sound_msg.handle = x_handle; \
-       sound_msg.code = x_code; \
-       sound_msg.msgid = x_msgid; \
-} while(0)
-
-
-int MMSoundMgrIpcMsgqInit(void);
-int MMSoundMgrIpcMsgqFini(void);
-int MMSoundMgrIpcMsgqReady(void);
-
-int _MMIpcMsgqCBSndMsg(mm_ipc_msg_t *msg);
-int _MMIpcMsgqCBRecvMsg(mm_ipc_msg_t *msg);
-int _MMIpcMsgqCBMsgEnQueueAgain(mm_ipc_msg_t *msg);
-
-#endif /* __MM_SOUND_MGR_H__ */
-
diff --git a/server/include/mm_sound_mgr_pulse.h b/server/include/mm_sound_mgr_pulse.h
deleted file mode 100644 (file)
index be4fdad..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * libmm-sound
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Seungbae Shin <seungbae.shin@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef __MM_SOUND_MGR_PULSE_H__
-#define __MM_SOUND_MGR_PULSE_H__
-
-#if 0
-
-#include "../../include/mm_ipc.h"
-#include "mm_sound_mgr_session.h"
-
-typedef void (*pa_disconnect_cb)(void* user_data);
-
-
-void MMSoundMgrPulseSetUSBDefaultSink (int usb_device);
-void MMSoundMgrPulseSetDefaultSink (char* device_api_name, char* device_bus_name);
-void MMSoundMgrPulseSetDefaultSinkByName (char* name);
-void MMSoundMgrPulseSetSourcemutebyname (char* sourcename, int mute);
-
-int MMSoundMgrPulseHandleRegisterBluetoothStatus (void* pinfo);
-
-int MMSoundMgrPulseHandleIsBtA2DPOnReq (bool* is_bt_on, char** bt_name);
-void MMSoundMgrPulseGetInitialBTStatus (bool *a2dp, bool *sco);
-int MMSoundMgrPulseGetBluetoothInfo(bool* is_nrec, int* bandwidth);
-
-void MMSoundMgrPulseSetSession(session_t session, session_state_t state);
-void MMSoundMgrPulseSetSubsession(subsession_t subsession, int subsession_opt);
-void MMSoundMgrPulseSetActiveDevice(mm_sound_device_in device_in, mm_sound_device_out device_out);
-
-void MMSoundMgrPulseSetCorkAll (bool cork);
-void MMSoundMgrPulseUnLoadHDMI();
-void MMSoundMgrPulseGetPathInfo(mm_sound_device_out *device_out, mm_sound_device_in *device_in);
-#ifdef TIZEN_MICRO
-void MMSoundMgrPulseSetVolumeLevel(volume_type_t volume_type, unsigned int volume_level);
-#endif
-void MMSoundMgrPulseSetVoicecontrolState (bool state);
-
-void* MMSoundMgrPulseInit(pa_disconnect_cb cb, void* user_data);
-int MMSoundMgrPulseFini(void* handle);
-#endif
-
-#endif /* __MM_SOUND_MGR_PULSE_H__ */
-
diff --git a/server/include/mm_sound_mgr_session.h b/server/include/mm_sound_mgr_session.h
deleted file mode 100644 (file)
index 3527a34..0000000
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * libmm-sound
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Seungbae Shin <seungbae.shin@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef __MM_SOUND_MGR_SESSION_H__
-#define __MM_SOUND_MGR_SESSION_H__
-
-typedef enum
-{
-       SESSION_END = 0,
-       SESSION_START,
-} session_state_t;
-
-/* MMSoundMgrPulseSetSession & pa_tizen_session_t should be updated for PA */
-typedef enum
-{
-       SESSION_MEDIA = 0,
-       SESSION_VOICECALL,
-       SESSION_VIDEOCALL,
-       SESSION_VOIP,
-       SESSION_FMRADIO,
-       SESSION_NOTIFICATION,
-       SESSION_ALARM,
-       SESSION_EMERGENCY,
-       SESSION_VOICE_RECOGNITION,
-       SESSION_NUM
-} session_t;
-
-/* MMSoundMgrPulseSetSubsession & pa_tizen_subsession_t should be updated for PA */
-typedef enum
-{
-       SUBSESSION_VOICE = 0,
-       SUBSESSION_RINGTONE,
-       SUBSESSION_MEDIA,
-       SUBSESSION_INIT,
-       SUBSESSION_VR_NORMAL,
-       SUBSESSION_VR_DRIVE,
-       SUBSESSION_RECORD_STEREO,
-       SUBSESSION_RECORD_MONO,
-       SUBSESSION_NUM
-} subsession_t;
-
-#if 0
-//#include <pulse/pulseaudio.h>
-#include "../../include/mm_ipc.h"
-#include "include/mm_sound.h"
-//#include <vconf.h>
-
-typedef enum
-{
-       NOT_AVAILABLE = 0,
-       AVAILABLE,
-} device_status_t;
-
-
-typedef enum
-{
-       DEVICE_BUILTIN = 0,
-       DEVICE_WIRED,
-       DEVICE_BT_A2DP,
-       DEVICE_BT_SCO,
-       DEVICE_DOCK,
-       DEVICE_HDMI,
-       DEVICE_MIRRORING,
-       DEVICE_USB_AUDIO,
-       DEVICE_MULTIMEDIA_DOCK,
-} device_type_t;
-
-enum mm_sound_audio_mute_t {
-       MM_SOUND_AUDIO_UNMUTE = 0,                              /**< Unmute state */
-       MM_SOUND_AUDIO_MUTE,                                    /**< Mute state */
-};
-
-#ifdef TIZEN_MICRO
-enum mm_sound_bandwidth {
-       MM_SOUND_BANDWIDTH_UNKNOWN = 0,
-       MM_SOUND_BANDWIDTH_NB = 1,
-       MM_SOUND_BANDWIDTH_WB = 2,
-};
-
-enum mm_sound_hfp_connection_state {
-       MM_SOUND_HFP_STATUS_UNKNOWN = 0,
-       MM_SOUND_HFP_STATUS_INCOMMING_CALL = 1, /* ringtone */
-};
-#endif
-
-int MMSoundMgrSessionInit(void);
-int MMSoundMgrSessionFini(void);
-
-/* called by mgr headset, pulse */
-int MMSoundMgrSessionSetDeviceAvailable (device_type_t device, int available, int type, const char* name);
-
-
-int MMSoundMgrSessionIsDeviceAvailable (mm_sound_device_out playback, mm_sound_device_in capture, bool *available);
-int MMSoundMgrSessionIsDeviceAvailableNoLock (mm_sound_device_out playback, mm_sound_device_in capture, bool *available);
-
-int MMSoundMgrSessionGetAvailableDevices (int *playback, int *capture);
-
-int MMSoundMgrSessionSetDeviceActive (mm_sound_device_out playback, mm_sound_device_in capture, bool need_broadcast);
-int MMSoundMgrSessionGetDeviceActive (mm_sound_device_out *playback, mm_sound_device_in *capture);
-
-int MMSoundMgrSessionSetSession(session_t session, session_state_t state);     /* called by mgr_asm */
-int MMSoundMgrSessionGetSession(session_t *session);
-
-int MMSoundMgrSessionSetSubSession(subsession_t subsession, int subsession_opt); /* called by mgr_asm */
-int MMSoundMgrSessionGetSubSession(subsession_t *subsession);
-
-char* MMSoundMgrSessionGetBtA2DPName ();
-
-int MMSoundMgrSessionSetDefaultSink (const char * const default_sink_name);
-
-int MMSoundMgrSessionSCOChanged (bool connected);
-
-void MMSoundMgrSessionSetVoiceControlState (bool enable);
-bool MMSoundMgrSessionGetVoiceControlState ();
-int MMSoundMgrSessionSetSCO (bool is_sco_on, bool is_bt_nrec, bool is_bt_wb);
-int MMSoundMgrSessionSetDeviceActiveAuto (void);
-int  MMSoundMgrSessionSetSoundPathForActiveDevice (mm_sound_device_out playback, mm_sound_device_in capture);
-
-#ifdef TIZEN_MICRO
-int MMSoundMgrSessionEnableAgSCO (bool enable);
-int MMSoundMgrSessionSetHFBandwidth (int bandwidth);
-int MMSoundMgrSessionSetHFState (int stat);
-int MMSoundMgrSessionMediaPause();
-int MMSoundMgrSessionSetDuplicateSubSession(void);
-const char* MMSoundMgrSessionGetSessionString(session_t session);
-#endif
-#endif
-#endif /* __MM_SOUND_MGR_SESSION_H__ */
-
index 6f2f30c..ccb7d62 100644 (file)
@@ -40,7 +40,6 @@
 #include <mm_debug.h>
 
 #include "include/mm_sound_mgr_asm.h"
-#include "include/mm_sound_mgr_session.h"
 #include "include/mm_sound_mgr_ipc.h"
 #include "../include/mm_sound_utils.h"
 
@@ -69,6 +68,41 @@ pthread_mutex_t g_mutex_asm = PTHREAD_MUTEX_INITIALIZER;
 #include <string.h>
 #include <errno.h>
 
+/* for temporal : copied from mgr_session.c */
+typedef enum
+{
+       SESSION_END = 0,
+       SESSION_START,
+} session_state_t;
+
+typedef enum
+{
+       SESSION_MEDIA = 0,
+       SESSION_VOICECALL,
+       SESSION_VIDEOCALL,
+       SESSION_VOIP,
+       SESSION_FMRADIO,
+       SESSION_NOTIFICATION,
+       SESSION_ALARM,
+       SESSION_EMERGENCY,
+       SESSION_VOICE_RECOGNITION,
+       SESSION_NUM
+} session_t;
+
+typedef enum
+{
+       SUBSESSION_VOICE = 0,
+       SUBSESSION_RINGTONE,
+       SUBSESSION_MEDIA,
+       SUBSESSION_INIT,
+       SUBSESSION_VR_NORMAL,
+       SUBSESSION_VR_DRIVE,
+       SUBSESSION_RECORD_STEREO,
+       SUBSESSION_RECORD_MONO,
+       SUBSESSION_NUM
+} subsession_t;
+/* -------------- */
+
 #define USE_SYSTEM_SERVER_PROCESS_MONITORING
 
 #define ROW_NUM_OF_SUB_EVENT           12 /* it should be exactly same with number of ASM_CASE_SUB_EVENT in ASM_sound_case table */
diff --git a/server/mm_sound_mgr_device.c b/server/mm_sound_mgr_device.c
deleted file mode 100644 (file)
index 287af97..0000000
+++ /dev/null
@@ -1,1339 +0,0 @@
-/*
- * libmm-sound
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Seungbae Shin <seungbae.shin@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#if 0
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <pthread.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <dirent.h>
-
-#include <glib.h>
-#include <errno.h>
-
-#include <mm_error.h>
-#include <mm_types.h>
-#include <mm_debug.h>
-#include <mm_ipc.h>
-#include <pulse/ext-echo-cancel.h>
-#include "include/mm_sound_mgr_common.h"
-#include "include/mm_sound_mgr_ipc.h"
-#include "include/mm_sound_mgr_device.h"
-#include "include/mm_sound_mgr_device_headset.h"
-
-#include "include/mm_sound_thread_pool.h"
-#include "../include/mm_sound_msg.h"
-#include "../include/mm_sound_common.h"
-#include "../include/mm_sound_device.h"
-#include "../include/mm_sound_utils.h"
-
-#include <vconf.h>
-#include <vconf-keys.h>
-
-#include "include/mm_sound_mgr_session.h"
-#include "include/mm_sound_mgr_pulse.h"
-
-#define MAX_SUPPORT_DEVICE_NUM    256
-static char g_device_id_array[MAX_SUPPORT_DEVICE_NUM];
-
-void mm_sound_util_get_devices_from_route(mm_sound_route route, mm_sound_device_in *device_in, mm_sound_device_out *device_out);
-
-static GList *g_active_device_cb_list = NULL;
-static pthread_mutex_t g_active_device_cb_mutex = PTHREAD_MUTEX_INITIALIZER;
-static GList *g_available_route_cb_list = NULL;
-static pthread_mutex_t g_available_route_cb_mutex = PTHREAD_MUTEX_INITIALIZER;
-static GList *g_volume_cb_list = NULL;
-static pthread_mutex_t g_volume_cb_mutex = PTHREAD_MUTEX_INITIALIZER;
-
-static GList *g_device_connected_cb_list = NULL;
-static pthread_mutex_t g_device_connected_cb_mutex = PTHREAD_MUTEX_INITIALIZER;
-static GList *g_device_info_changed_cb_list = NULL;
-static pthread_mutex_t g_device_info_changed_cb_mutex = PTHREAD_MUTEX_INITIALIZER;
-static GList *g_connected_device_list = NULL;
-static pthread_mutex_t g_connected_device_list_mutex = PTHREAD_MUTEX_INITIALIZER;
-typedef struct {
-       GList *list;
-}connected_device_list_s;
-connected_device_list_s g_connected_device_list_s;
-
-static int _mm_sound_mgr_device_volume_callback(keynode_t* node, void* data);
-
-static char *g_volume_vconf[VOLUME_TYPE_MAX] = {
-       VCONF_KEY_VOLUME_TYPE_SYSTEM,       /* VOLUME_TYPE_SYSTEM */
-       VCONF_KEY_VOLUME_TYPE_NOTIFICATION, /* VOLUME_TYPE_NOTIFICATION */
-       VCONF_KEY_VOLUME_TYPE_ALARM,        /* VOLUME_TYPE_ALARM */
-       VCONF_KEY_VOLUME_TYPE_RINGTONE,     /* VOLUME_TYPE_RINGTONE */
-       VCONF_KEY_VOLUME_TYPE_MEDIA,        /* VOLUME_TYPE_MEDIA */
-       VCONF_KEY_VOLUME_TYPE_CALL,         /* VOLUME_TYPE_CALL */
-       VCONF_KEY_VOLUME_TYPE_VOIP,         /* VOLUME_TYPE_VOIP */
-       VCONF_KEY_VOLUME_TYPE_VOICE,            /* VOLUME_TYPE_VOICE */
-       VCONF_KEY_VOLUME_TYPE_ANDROID           /* VOLUME_TYPE_FIXED */
-};
-
-int _mm_sound_mgr_device_init(void)
-{
-       int i = 0;
-       int ret = MM_ERROR_NONE;
-       debug_fenter();
-
-       for(i = 0 ; i < VOLUME_TYPE_MAX; i++) {
-               vconf_notify_key_changed(g_volume_vconf[i], (void (*) (keynode_t *, void *))_mm_sound_mgr_device_volume_callback, (void *)i);
-       }
-       g_connected_device_list_s.list = g_connected_device_list;
-       memset(g_device_id_array, 0, MAX_SUPPORT_DEVICE_NUM);
-
-       /* forcedly, add internal sound device info. */
-       ret = MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CONNECTED, DEVICE_TYPE_BUILTIN_SPEAKER, DEVICE_IO_DIRECTION_OUT, DEVICE_ID_AUTO, DEVICE_NAME_BUILTIN_SPK, DEVICE_STATE_DEACTIVATED, NULL);
-       if (ret) {
-               debug_error("failed to MMSoundMgrDeviceUpdateStatus() failed (%d)\n", ret);
-       }
-       ret = MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CONNECTED, DEVICE_TYPE_BUILTIN_RECEIVER, DEVICE_IO_DIRECTION_OUT, DEVICE_ID_AUTO, DEVICE_NAME_BUILTIN_RCV, DEVICE_STATE_DEACTIVATED, NULL);
-       if (ret) {
-               debug_error("failed to MMSoundMgrDeviceUpdateStatus() failed (%d)\n", ret);
-       }
-       ret = MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CONNECTED, DEVICE_TYPE_BUILTIN_MIC, DEVICE_IO_DIRECTION_IN, DEVICE_ID_AUTO, DEVICE_NAME_BUILTIN_MIC, DEVICE_STATE_DEACTIVATED, NULL);
-       if (ret) {
-               debug_error("failed to MMSoundMgrDeviceUpdateStatus() failed (%d)\n", ret);
-       }
-
-       debug_fleave();
-       return MM_ERROR_NONE;
-}
-
-int _mm_sound_mgr_device_fini(void)
-{
-       debug_fenter();
-
-       debug_fleave();
-       return MM_ERROR_NONE;
-}
-
-int _mm_sound_mgr_device_is_route_available(const _mm_sound_mgr_device_param_t *param, bool *is_available)
-{
-       mm_sound_route route = param->route;
-       mm_sound_device_in device_in = MM_SOUND_DEVICE_IN_NONE;
-       mm_sound_device_out device_out = MM_SOUND_DEVICE_OUT_NONE;
-       int ret = MM_ERROR_NONE;
-
-       debug_fenter();
-
-       mm_sound_util_get_devices_from_route(route, &device_in, &device_out);
-
-       /* check given input & output device is available */
-       ret = MMSoundMgrSessionIsDeviceAvailable(device_out, device_in, is_available);
-
-       debug_fleave();
-       return ret;
-}
-
-int _mm_sound_mgr_device_foreach_available_route_cb(mm_ipc_msg_t *msg)
-{
-       mm_sound_route *route_list = NULL;
-       int route_list_count = 0;
-       int route_index = 0;
-       int available_count = 0;
-       bool is_available = 0;
-       int ret = MM_ERROR_NONE;
-
-       debug_fenter();
-
-       route_list_count = mm_sound_util_get_valid_route_list(&route_list);
-       for (route_index = 0; route_index < route_list_count; route_index++) {
-               mm_sound_device_in device_in = MM_SOUND_DEVICE_IN_NONE;
-               mm_sound_device_out device_out = MM_SOUND_DEVICE_OUT_NONE;
-
-               mm_sound_util_get_devices_from_route(route_list[route_index], &device_in, &device_out);
-               /* check input & output device of given route is available */
-               ret = MMSoundMgrSessionIsDeviceAvailable(device_out, device_in, &is_available);
-               if (ret != MM_ERROR_NONE) {
-                       debug_error("MMSoundMgrSessionIsDeviceAvailable() failed (%d)\n", ret);
-                       goto FINISH;
-               }
-
-               /* add route to avaiable route list */
-               if (is_available) {
-                       if (available_count >= (sizeof(msg->sound_msg.route_list) / sizeof(int))) {
-                               debug_error("Cannot add available route, list is full\n");
-                               ret = MM_ERROR_SOUND_INTERNAL;
-                               goto FINISH;
-                       }
-                       msg->sound_msg.route_list[available_count++] = route_list[route_index];
-               }
-       }
-FINISH:
-       debug_fleave();
-       return ret;
-}
-
-int _mm_sound_mgr_device_get_audio_path(mm_sound_device_in *device_in, mm_sound_device_out *device_out)
-{
-       int ret = MM_ERROR_NONE;
-
-#ifdef DEBUG_DETAIL
-       debug_fenter();
-#endif
-
-       ret = MMSoundMgrSessionGetAudioPath(device_out, device_in);
-
-#ifdef DEBUG_DETAIL
-       debug_fleave();
-#endif
-       return ret;
-}
-
-int _mm_sound_mgr_device_add_volume_callback(const _mm_sound_mgr_device_param_t *param)
-{
-       int ret = MM_ERROR_NONE;
-       GList *list = NULL;
-       _mm_sound_mgr_device_param_t *cb_param = NULL;
-       bool is_already_set = FALSE;
-
-#ifdef DEBUG_DETAIL
-       debug_fenter();
-#endif
-
-       MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_volume_cb_mutex, MM_ERROR_SOUND_INTERNAL);
-
-       for (list = g_volume_cb_list; list != NULL; list = list->next) {
-               cb_param = (_mm_sound_mgr_device_param_t *)list->data;
-               if ((cb_param) && (cb_param->pid == param->pid) && (!strcmp(cb_param->name, param->name))) {
-                       cb_param->callback = param->callback;
-                       cb_param->cbdata = param->cbdata;
-                       is_already_set = TRUE;
-                       break;
-               }
-       }
-       if (!is_already_set) {
-               cb_param = g_malloc(sizeof(_mm_sound_mgr_device_param_t));
-               memcpy(cb_param, param, sizeof(_mm_sound_mgr_device_param_t));
-               g_volume_cb_list = g_list_append(g_volume_cb_list, cb_param);
-               if (g_volume_cb_list) {
-                       debug_log("volume cb registered for pid [%d]", cb_param->pid);
-               } else {
-                       debug_error("g_list_append failed\n");
-                       ret = MM_ERROR_SOUND_INTERNAL;
-                       goto FINISH;
-               }
-
-               __mm_sound_mgr_ipc_freeze_send (FREEZE_COMMAND_EXCLUDE, param->pid);
-       }
-
-FINISH:
-       MMSOUND_LEAVE_CRITICAL_SECTION(&g_volume_cb_mutex);
-#ifdef DEBUG_DETAIL
-       debug_fleave();
-#endif
-       return ret;
-}
-
-int _mm_sound_mgr_device_remove_volume_callback(const _mm_sound_mgr_device_param_t *param)
-{
-       int ret = MM_ERROR_SOUND_INTERNAL;
-       GList *list = NULL;
-       _mm_sound_mgr_device_param_t *cb_param = NULL;
-
-       debug_fenter();
-
-       MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_volume_cb_mutex, MM_ERROR_SOUND_INTERNAL);
-
-       for (list = g_volume_cb_list; list != NULL; list = list->next) {
-               cb_param = (_mm_sound_mgr_device_param_t *)list->data;
-               if ((cb_param) && (cb_param->pid == param->pid) && (!strcmp(cb_param->name, param->name))) {
-                       g_volume_cb_list = g_list_remove(g_volume_cb_list, cb_param);
-                       __mm_sound_mgr_ipc_freeze_send (FREEZE_COMMAND_INCLUDE, param->pid);
-                       g_free(cb_param);
-                       ret = MM_ERROR_NONE;
-                       break;
-               }
-       }
-
-       MMSOUND_LEAVE_CRITICAL_SECTION(&g_volume_cb_mutex);
-
-       debug_fleave();
-       return ret;
-}
-
-int __mm_sound_mgr_device_check_process(int pid)
-{
-       DIR *dir = NULL;
-       char check_path[128] = "";
-       int exist = MM_ERROR_NONE;
-
-       memset(check_path, '\0', sizeof(check_path));
-       snprintf(check_path, sizeof(check_path) - 1, "/proc/%d", pid);
-
-       dir = opendir(check_path);
-       if (dir == NULL) {
-               switch (errno) {
-                       case ENOENT:
-                               debug_error("pid %d does not exist anymore\n", pid);
-                               exist = MM_ERROR_SOUND_INTERNAL;
-                               break;
-                       case EACCES:
-                               debug_error("Permission denied\n");
-                               break;
-                       case EMFILE:
-                               debug_error("Too many file descriptors in use by process\n");
-                               break;
-                       case ENFILE:
-                               debug_error("Too many files are currently open in the system\n");
-                               break;
-                       default:
-                               debug_error("Other error : %d\n", errno);
-                               break;
-               }
-       } else {
-               debug_warning("pid : %d still alive\n", pid);
-               if (-1 == closedir(dir)) {
-                       debug_error("closedir failed with errno : %d\n", errno);
-               }
-       }
-       return exist;
-}
-
-
-static int __mm_sound_mgr_device_check_flags_to_append (int device_flags, mm_sound_device_t *device_h, bool *is_good_to_append)
-{
-       bool need_to_append = false;
-       int need_to_check_for_io_direction = device_flags & DEVICE_IO_DIRECTION_FLAGS;
-       int need_to_check_for_state = device_flags & DEVICE_STATE_FLAGS;
-       int need_to_check_for_type = device_flags & DEVICE_TYPE_FLAGS;
-
-       debug_warning("device_h[0x%x], device_flags[0x%x], need_to_check(io_direction[0x%x],state[0x%x],type[0x%x])\n",
-                       device_h, device_flags, need_to_check_for_io_direction, need_to_check_for_state, need_to_check_for_type);
-
-       if(!device_h) {
-               return MM_ERROR_INVALID_ARGUMENT;
-       }
-       if (device_flags == DEVICE_ALL_FLAG) {
-               *is_good_to_append = true;
-               return MM_ERROR_NONE;
-       }
-
-       if (need_to_check_for_io_direction) {
-               if ((device_h->io_direction == DEVICE_IO_DIRECTION_IN) && (device_flags & DEVICE_IO_DIRECTION_IN_FLAG)) {
-                       need_to_append = true;
-               } else if ((device_h->io_direction == DEVICE_IO_DIRECTION_OUT) && (device_flags & DEVICE_IO_DIRECTION_OUT_FLAG)) {
-                       need_to_append = true;
-               } else if ((device_h->io_direction == DEVICE_IO_DIRECTION_BOTH) && (device_flags & DEVICE_IO_DIRECTION_BOTH_FLAG)) {
-                       need_to_append = true;
-               }
-               if (need_to_append) {
-                       if (!need_to_check_for_state && !need_to_check_for_type) {
-                               *is_good_to_append = true;
-                               return MM_ERROR_NONE;
-                       }
-               } else {
-                       *is_good_to_append = false;
-                       return MM_ERROR_NONE;
-               }
-       }
-       if (need_to_check_for_state) {
-               need_to_append = false;
-               if ((device_h->state == DEVICE_STATE_DEACTIVATED) && (device_flags & DEVICE_STATE_DEACTIVATED_FLAG)) {
-                       need_to_append = true;
-               } else if ((device_h->state == DEVICE_STATE_ACTIVATED) && (device_flags & DEVICE_STATE_ACTIVATED_FLAG)) {
-                       need_to_append = true;
-               }
-               if (need_to_append) {
-                       if (!need_to_check_for_type) {
-                               *is_good_to_append = true;
-                               return MM_ERROR_NONE;
-                       }
-               } else {
-                       *is_good_to_append = false;
-                       return MM_ERROR_NONE;
-               }
-       }
-       if (need_to_check_for_type) {
-               need_to_append = false;
-               bool is_internal_device = IS_INTERNAL_DEVICE(device_h->type);
-               if (is_internal_device && (device_flags & DEVICE_TYPE_INTERNAL_FLAG)) {
-                       need_to_append = true;
-               } else if (!is_internal_device && (device_flags & DEVICE_TYPE_EXTERNAL_FLAG)) {
-                       need_to_append = true;
-               }
-               if (need_to_append) {
-                       *is_good_to_append = true;
-                       return MM_ERROR_NONE;
-               } else {
-                       *is_good_to_append = false;
-                       return MM_ERROR_NONE;
-               }
-       }
-       return MM_ERROR_NONE;
-}
-
-//int _mm_sound_mgr_device_get_current_connected_dev_list(const _mm_sound_mgr_device_param_t *param, GList **device_list)
-int _mm_sound_mgr_device_get_current_connected_dev_list(int device_flags, mm_sound_device_t **device_list, int *dev_num)
-{
-       int ret = MM_ERROR_NONE;
-       int _dev_num = 0, dev_idx = 0;
-       int dev_list_match_quary[MAX_SUPPORT_DEVICE_NUM] = {-1,};
-       mm_sound_device_t *device_node = NULL, *_device_node = NULL;
-       GList *list = NULL;
-       bool is_good_to_append = FALSE;
-
-
-#ifdef DEBUG_DETAIL
-       debug_fenter();
-#endif
-       _mm_sound_mgr_device_connected_dev_list_dump();
-
-       if (!device_list || !dev_num) {
-               debug_error("Parameter Null");
-               return MM_ERROR_INVALID_ARGUMENT;
-       }
-       MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_connected_device_list_mutex, MM_ERROR_SOUND_INTERNAL);
-
-       debug_msg("address of g_connected_device_list[0x%x]", g_connected_device_list);
-
-       for (_dev_num = 0, list = g_connected_device_list; list != NULL; _dev_num++, list = list->next) {
-               _device_node = (mm_sound_device_t *)list->data;
-               if (_device_node) {
-                       __mm_sound_mgr_device_check_flags_to_append(device_flags, _device_node, &is_good_to_append);
-                       if (is_good_to_append) {
-                               debug_warning("[DEBUG] is_good_to_append true : %d", dev_idx);
-                               dev_list_match_quary[dev_idx++] = _dev_num;
-                       }
-               }
-       }
-
-       *device_list = g_malloc(sizeof(mm_sound_device_t)*dev_idx);
-       *dev_num = dev_idx;
-       dev_idx = 0;
-
-       for (_dev_num =0, list = g_connected_device_list; list != NULL; _dev_num++, list = list->next) {
-               _device_node = (mm_sound_device_t *)list->data;
-               if (_device_node && dev_list_match_quary[dev_idx] == _dev_num) {
-                       memcpy(*device_list + dev_idx, _device_node, sizeof(mm_sound_device_t));
-                       dev_idx++;
-               }
-       }
-
-FINISH:
-       MMSOUND_LEAVE_CRITICAL_SECTION(&g_connected_device_list_mutex);
-#ifdef DEBUG_DETAIL
-       debug_fleave();
-#endif
-       return ret;
-}
-
-int _mm_sound_mgr_device_add_connected_callback(const _mm_sound_mgr_device_param_t *param)
-{
-       int ret = MM_ERROR_NONE;
-       GList *list = NULL;
-       _mm_sound_mgr_device_param_t *cb_param = NULL;
-       bool is_already_set = FALSE;
-
-#ifdef DEBUG_DETAIL
-       debug_fenter();
-#endif
-
-       MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_device_connected_cb_mutex, MM_ERROR_SOUND_INTERNAL);
-
-       for (list = g_device_connected_cb_list; list != NULL; list = list->next) {
-               cb_param = (_mm_sound_mgr_device_param_t *)list->data;
-               if (cb_param && (cb_param->pid == param->pid)) {
-                       cb_param->callback = param->callback;
-                       cb_param->cbdata = param->cbdata;
-                       is_already_set = TRUE;
-                       break;
-               }
-       }
-
-       if (!is_already_set) {
-               cb_param = g_malloc(sizeof(_mm_sound_mgr_device_param_t));
-               memcpy(cb_param, param, sizeof(_mm_sound_mgr_device_param_t));
-               g_device_connected_cb_list = g_list_append(g_device_connected_cb_list, cb_param);
-               if (g_device_connected_cb_list) {
-                       debug_log("device connected cb registered for pid [%d]", cb_param->pid);
-               } else {
-                       debug_error("g_list_append failed\n");
-                       ret = MM_ERROR_SOUND_INTERNAL;
-                       goto FINISH;
-               }
-
-               __mm_sound_mgr_ipc_freeze_send (FREEZE_COMMAND_EXCLUDE, param->pid);
-       }
-
-FINISH:
-       MMSOUND_LEAVE_CRITICAL_SECTION(&g_device_connected_cb_mutex);
-#ifdef DEBUG_DETAIL
-       debug_fleave();
-#endif
-       return ret;
-}
-
-int _mm_sound_mgr_device_remove_connected_callback(const _mm_sound_mgr_device_param_t *param)
-{
-       int ret = MM_ERROR_SOUND_INTERNAL;
-       GList *list = NULL;
-       bool is_same_pid_exists = false;
-       _mm_sound_mgr_device_param_t *cb_param = NULL;
-
-       debug_fenter();
-
-       MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_device_connected_cb_mutex, MM_ERROR_SOUND_INTERNAL);
-
-       for (list = g_device_connected_cb_list; list != NULL; list = list->next) {
-               cb_param = (_mm_sound_mgr_device_param_t *)list->data;
-               if (cb_param && (cb_param->pid == param->pid)) {
-                       g_device_connected_cb_list = g_list_remove(g_device_connected_cb_list, cb_param);
-                       g_free(cb_param);
-                       ret = MM_ERROR_NONE;
-                       break;
-               }
-       }
-
-       /* Check for PID still exists in the list, if not include freeze */
-       for (list = g_device_connected_cb_list; list != NULL; list = list->next) {
-               cb_param = (_mm_sound_mgr_device_param_t *)list->data;
-               if ((cb_param) && (cb_param->pid == param->pid)) {
-                       is_same_pid_exists = true;
-                       break;
-               }
-       }
-       if (!is_same_pid_exists) {
-               __mm_sound_mgr_ipc_freeze_send (FREEZE_COMMAND_INCLUDE, param->pid);
-       }
-       MMSOUND_LEAVE_CRITICAL_SECTION(&g_device_connected_cb_mutex);
-
-       debug_fleave();
-       return ret;
-}
-
-int _mm_sound_mgr_device_add_info_changed_callback(const _mm_sound_mgr_device_param_t *param)
-{
-       int ret = MM_ERROR_NONE;
-       GList *list = NULL;
-       _mm_sound_mgr_device_param_t *cb_param = NULL;
-       bool is_already_set = FALSE;
-
-#ifdef DEBUG_DETAIL
-       debug_fenter();
-#endif
-
-       MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_device_info_changed_cb_mutex, MM_ERROR_SOUND_INTERNAL);
-
-       for (list = g_device_info_changed_cb_list; list != NULL; list = list->next) {
-               cb_param = (_mm_sound_mgr_device_param_t *)list->data;
-               if (cb_param && (cb_param->pid == param->pid)) {
-                       cb_param->callback = param->callback;
-                       cb_param->cbdata = param->cbdata;
-                       is_already_set = TRUE;
-                       break;
-               }
-       }
-
-       if (!is_already_set) {
-               cb_param = g_malloc(sizeof(_mm_sound_mgr_device_param_t));
-               memcpy(cb_param, param, sizeof(_mm_sound_mgr_device_param_t));
-               g_device_info_changed_cb_list = g_list_append(g_device_info_changed_cb_list, cb_param);
-               if (g_device_info_changed_cb_list) {
-                       debug_log("device information changed cb registered for pid [%d]", cb_param->pid);
-               } else {
-                       debug_error("g_list_append failed\n");
-                       ret = MM_ERROR_SOUND_INTERNAL;
-                       goto FINISH;
-               }
-
-               __mm_sound_mgr_ipc_freeze_send (FREEZE_COMMAND_EXCLUDE, param->pid);
-       }
-
-FINISH:
-       MMSOUND_LEAVE_CRITICAL_SECTION(&g_device_info_changed_cb_mutex);
-#ifdef DEBUG_DETAIL
-       debug_fleave();
-#endif
-       return ret;
-}
-
-int _mm_sound_mgr_device_remove_info_changed_callback(const _mm_sound_mgr_device_param_t *param)
-{
-       int ret = MM_ERROR_SOUND_INTERNAL;
-       GList *list = NULL;
-       bool is_same_pid_exists = false;
-       _mm_sound_mgr_device_param_t *cb_param = NULL;
-
-       debug_fenter();
-
-       MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_device_info_changed_cb_mutex, MM_ERROR_SOUND_INTERNAL);
-
-       for (list = g_device_info_changed_cb_list; list != NULL; list = list->next) {
-               cb_param = (_mm_sound_mgr_device_param_t *)list->data;
-               if (cb_param && (cb_param->pid == param->pid)) {
-                       g_device_info_changed_cb_list = g_list_remove(g_device_info_changed_cb_list, cb_param);
-                       g_free(cb_param);
-                       ret = MM_ERROR_NONE;
-                       break;
-               }
-       }
-
-       /* Check for PID still exists in the list, if not include freeze */
-       for (list = g_device_info_changed_cb_list; list != NULL; list = list->next) {
-               cb_param = (_mm_sound_mgr_device_param_t *)list->data;
-               if ((cb_param) && (cb_param->pid == param->pid)) {
-                       is_same_pid_exists = true;
-                       break;
-               }
-       }
-       if (!is_same_pid_exists) {
-               __mm_sound_mgr_ipc_freeze_send (FREEZE_COMMAND_INCLUDE, param->pid);
-       }
-       MMSOUND_LEAVE_CRITICAL_SECTION(&g_device_info_changed_cb_mutex);
-
-       debug_fleave();
-       return ret;
-}
-
-#define CLEAR_DEAD_CB_LIST(x)  do { \
-       if (x && cb_param) { \
-               bool is_exist = mm_sound_util_is_process_alive(cb_param->pid); \
-               debug_msg ("cb_list = %p, cb_param = %p, pid=[%d] : exist[%d]", x, cb_param, cb_param->pid, is_exist); \
-               if (!is_exist) { \
-                       debug_warning("PID:%d does not exist now! remove from device cb list\n", cb_param->pid); \
-                       g_free (cb_param); \
-                       x = g_list_remove (x, cb_param); \
-               } \
-       } else { \
-               debug_error ("Invalid list or param"); \
-       } \
-}while(0)
-
-static void _clear_volume_cb_list_func (_mm_sound_mgr_device_param_t * cb_param, gpointer user_data)
-{
-       CLEAR_DEAD_CB_LIST(g_volume_cb_list);
-}
-
-static void _clear_device_connected_cb_list_func (_mm_sound_mgr_device_param_t * cb_param, gpointer user_data)
-{
-       CLEAR_DEAD_CB_LIST(g_device_connected_cb_list);
-}
-
-static void _clear_device_info_changed_cb_list_func (_mm_sound_mgr_device_param_t * cb_param, gpointer user_data)
-{
-       CLEAR_DEAD_CB_LIST(g_device_info_changed_cb_list);
-}
-
-static int _mm_sound_mgr_device_volume_callback(keynode_t* node, void* data)
-{
-       int ret = MM_ERROR_NONE;
-       GList *list = NULL;
-       _mm_sound_mgr_device_param_t *cb_param = NULL;
-       mm_ipc_msg_t msg;
-       volume_type_t type = (volume_type_t)data;
-       mm_sound_device_in device_in;
-       mm_sound_device_out device_out;
-       char *str = NULL;
-       unsigned int value;
-
-       debug_enter("[%s] changed callback called", vconf_keynode_get_name(node));
-
-       MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_volume_cb_mutex, MM_ERROR_SOUND_INTERNAL);
-
-       MMSoundMgrSessionGetDeviceActive(&device_out, &device_in);
-       /* Get volume value from VCONF */
-       if (vconf_get_int(g_volume_vconf[type], &value)) {
-               debug_error ("vconf_get_int(%s) failed..\n", g_volume_vconf[type]);
-               ret = MM_ERROR_SOUND_INTERNAL;
-               goto FINISH;
-       }
-
-       /* Update list for dead process */
-       __mm_sound_mgr_ipc_notify_volume_changed(type, value);
-
-FINISH:
-       MMSOUND_LEAVE_CRITICAL_SECTION(&g_volume_cb_mutex);
-
-       debug_leave();
-       return ret;
-}
-
-int _mm_sound_mgr_device_active_device_callback(mm_sound_device_in device_in, mm_sound_device_out device_out)
-{
-       int ret = MM_ERROR_NONE;
-       return ret;
-}
-
-int _mm_sound_mgr_device_set_sound_path_for_active_device(mm_sound_device_out playback, mm_sound_device_in capture)
-{
-       int ret = MM_ERROR_NONE;
-
-       debug_fenter();
-       ret = MMSoundMgrSessionSetSoundPathForActiveDevice(playback, capture);
-
-       debug_fleave();
-       return ret;
-}
-
-int _mm_sound_mgr_device_available_device_callback(mm_sound_device_in device_in, mm_sound_device_out device_out, bool available)
-{
-       int ret = MM_ERROR_NONE;
-       return ret;
-}
-
-#define RELEASE_DEVICE_INFO_ID(x_id) \
-do { \
-       if (g_device_id_array[x_id-1] == 1) { \
-               g_device_id_array[x_id-1] = 0; \
-       } else { \
-               debug_error("could not release the id[%d]\n", x_id); \
-       } \
-} while(0)
-
-#define SET_DEVICE_INFO_ID_AUTO(x_device_h) \
-do { \
-       int device_id = 0; \
-       int cnt = 1; \
-       if (!x_device_h) { \
-               debug_error("device_h is null, could not set device id"); \
-               break; \
-       } \
-       for (cnt = 1; cnt < MAX_SUPPORT_DEVICE_NUM+1; cnt++) { \
-               if (g_device_id_array[cnt-1] == 0) { \
-                       break; \
-               } \
-       } \
-       if (cnt == MAX_SUPPORT_DEVICE_NUM+1) { \
-               debug_error("could not get a new id, device array is full\n"); \
-               device_id = -1; \
-       } else { \
-               device_id = cnt; \
-               g_device_id_array[cnt-1] = 1; \
-       } \
-       x_device_h->id = device_id; \
-} while(0)
-
-#define GET_DEVICE_INFO_ID(x_device_h, x_id) \
-do { \
-       if (!x_device_h) { \
-               debug_error("device_h is null, could not get device id"); \
-               break; \
-       } \
-       if (x_id) \
-               *x_id = x_device_h->id; \
-} while(0)
-
-#define SET_DEVICE_INFO_TYPE(x_device_h, x_type) \
-do { \
-       if (!x_device_h) { \
-               debug_error("device_h is null, could not set device type"); \
-               break; \
-       } \
-       x_device_h->type = x_type; \
-} while(0)
-
-#define SET_DEVICE_INFO_IO_DIRECTION(x_device_h, x_io_direction) \
-do { \
-       if (!x_device_h) { \
-               debug_error("device_h is null, could not set device io direction"); \
-               break; \
-       } \
-       x_device_h->io_direction = x_io_direction; \
-} while(0)
-
-#define GET_DEVICE_INFO_IO_DIRECTION(x_device_h, x_io_direction) \
-do { \
-       if (!x_device_h) { \
-               debug_error("device_h is null, could not get device io direction"); \
-               break; \
-       } \
-       x_io_direction = x_device_h->io_direction; \
-} while(0)
-
-#define SET_DEVICE_INFO_NAME(x_device_h, x_name) \
-do { \
-       if (!x_device_h) { \
-               debug_error("device_h is null, could not set device name"); \
-               break; \
-       } \
-       if(x_name) { \
-               int size = strlen(x_name); \
-               memcpy (x_device_h->name, x_name, (MAX_DEVICE_NAME_NUM > size)? size : MAX_DEVICE_NAME_NUM-1); \
-       } \
-} while(0)
-
-#define SET_DEVICE_INFO_STATE(x_device_h, x_state) \
-do { \
-       if (!x_device_h) { \
-               debug_error("device_h is null, could not set device state"); \
-               break; \
-       } \
-       x_device_h->state = x_state; \
-} while(0)
-
-#define GET_DEVICE_INFO_STATE(x_device_h, x_state) \
-do { \
-       if (!x_device_h) { \
-               debug_error("device_h is null, could not get device state"); \
-               break; \
-       } \
-       x_state = x_device_h->state; \
-} while(0)
-
-static const char* device_update_str[] =
-{
-       "DISCONNECTED",
-       "CONNECTED",
-       "STATE",
-       "IO-DIRECTION",
-};
-
-static const char* device_type_str[] =
-{
-       "BUILTIN_SPK",
-       "BUILTIN_RCV",
-       "BUILTIN_MIC",
-       "AUDIOJACK",
-       "BLUETOOTH",
-       "HDMI",
-       "MIRRORING",
-       "USB_AUDIO",
-};
-
-static const char* device_state_str[] =
-{
-       "DEACTIVATED",
-       "ACTIVATED",
-};
-
-static const char* device_io_direction_str[] =
-{
-       "IN",
-       "OUT",
-       "BOTH",
-};
-
-static int __mm_sound_mgr_device_check_flags_to_trigger (int device_flags, mm_sound_device_t *device_h, bool *is_good_to_go)
-{
-       bool need_to_go = false;
-       int need_to_check_for_io_direction = device_flags & DEVICE_IO_DIRECTION_FLAGS;
-       int need_to_check_for_state = device_flags & DEVICE_STATE_FLAGS;
-       int need_to_check_for_type = device_flags & DEVICE_TYPE_FLAGS;
-
-       debug_warning("device_h[0x%x], device_flags[0x%x], need_to_check(io_direction[0x%x],state[0x%x],type[0x%x])\n",
-                       device_h, device_flags, need_to_check_for_io_direction, need_to_check_for_state, need_to_check_for_type);
-
-       if(!device_h) {
-               return MM_ERROR_INVALID_ARGUMENT;
-       }
-       if (device_flags == DEVICE_ALL_FLAG) {
-               *is_good_to_go = true;
-               return MM_ERROR_NONE;
-       }
-
-       if (need_to_check_for_io_direction) {
-               if ((device_h->io_direction == DEVICE_IO_DIRECTION_IN) && (device_flags & DEVICE_IO_DIRECTION_IN_FLAG)) {
-                       need_to_go = true;
-               } else if ((device_h->io_direction == DEVICE_IO_DIRECTION_OUT) && (device_flags & DEVICE_IO_DIRECTION_OUT_FLAG)) {
-                       need_to_go = true;
-               } else if ((device_h->io_direction == DEVICE_IO_DIRECTION_BOTH) && (device_flags & DEVICE_IO_DIRECTION_BOTH_FLAG)) {
-                       need_to_go = true;
-               }
-               if (need_to_go) {
-                       if (!need_to_check_for_state && !need_to_check_for_type) {
-                               *is_good_to_go = true;
-                               return MM_ERROR_NONE;
-                       }
-               } else {
-                       *is_good_to_go = false;
-                       return MM_ERROR_NONE;
-               }
-       }
-       if (need_to_check_for_state) {
-               need_to_go = false;
-               if ((device_h->state == DEVICE_STATE_DEACTIVATED) && (device_flags & DEVICE_STATE_DEACTIVATED_FLAG)) {
-                       need_to_go = true;
-               } else if ((device_h->state == DEVICE_STATE_ACTIVATED) && (device_flags & DEVICE_STATE_ACTIVATED_FLAG)) {
-                       need_to_go = true;
-               }
-               if (need_to_go) {
-                       if (!need_to_check_for_type) {
-                               *is_good_to_go = true;
-                               return MM_ERROR_NONE;
-                       }
-               } else {
-                       *is_good_to_go = false;
-                       return MM_ERROR_NONE;
-               }
-       }
-       if (need_to_check_for_type) {
-               need_to_go = false;
-               bool is_internal_device = IS_INTERNAL_DEVICE(device_h->type);
-               if (is_internal_device && (device_flags & DEVICE_TYPE_INTERNAL_FLAG)) {
-                       need_to_go = true;
-               } else if (!is_internal_device && (device_flags & DEVICE_TYPE_EXTERNAL_FLAG)) {
-                       need_to_go = true;
-               }
-               if (need_to_go) {
-                       *is_good_to_go = true;
-                       return MM_ERROR_NONE;
-               } else {
-                       *is_good_to_go = false;
-                       return MM_ERROR_NONE;
-               }
-       }
-       return MM_ERROR_NONE;
-}
-
-int _mm_sound_mgr_device_connected_callback(mm_sound_device_t *device_h, bool is_connected)
-{
-       int ret = MM_ERROR_NONE;
-       GList *list = NULL;
-       _mm_sound_mgr_device_param_t *cb_param = NULL;
-       mm_ipc_msg_t msg;
-       bool is_good_to_go = true;
-
-       debug_fenter();
-       // need to check this in client
-//     ret = __mm_sound_mgr_device_check_flags_to_trigger (cb_param->device_flags, device_h, &is_good_to_go);
-
-       __mm_sound_mgr_ipc_notify_device_connected (device_h, is_connected);
-
-       debug_fleave();
-       return ret;
-}
-
-int _mm_sound_mgr_device_info_changed_callback(mm_sound_device_t *device_h, int changed_info_type)
-{
-       int ret = MM_ERROR_NONE;
-       GList *list = NULL;
-       _mm_sound_mgr_device_param_t *cb_param = NULL;
-       mm_ipc_msg_t msg;
-       bool is_good_to_go = true;
-
-       debug_fenter();
-
-       // need to check this in client
-       // ret = __mm_sound_mgr_device_check_flags_to_trigger (cb_param->device_flags, device_h, &is_good_to_go);
-       __mm_sound_mgr_ipc_notify_device_info_changed (device_h, changed_info_type);
-
-       debug_fleave();
-       return ret;
-}
-
-int _mm_sound_mgr_device_connected_dev_list_find_item (mm_sound_device_t **device_h, device_type_e device_type, int id)
-{
-       int ret = MM_ERROR_NONE;
-
-       MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_connected_device_list_mutex, MM_ERROR_SOUND_INTERNAL);
-
-       GList *list = NULL;
-       mm_sound_device_t *device_node = NULL;
-       for (list = g_connected_device_list; list != NULL; list = list->next) {
-               device_node = (mm_sound_device_t *)list->data;
-               if (((device_node) && (device_node->type == device_type) && (id == DEVICE_ID_AUTO)) || ((device_node) && (device_node->id == id))) {
-                       debug_log("found the suitable item, device_type[%d], id[%d]\n", device_node->type, device_node->id);
-                       break;
-               }
-       }
-       if (list != NULL) {
-               *device_h = device_node;
-       } else {
-               debug_error("no suitable item for device_type[%d], id[%d]\n", device_type, id);
-               ret = MM_ERROR_SOUND_NO_DATA;
-       }
-
-       MMSOUND_LEAVE_CRITICAL_SECTION(&g_connected_device_list_mutex);
-
-       return ret;
-}
-
-int _mm_sound_mgr_device_connected_dev_list_add_item (mm_sound_device_t **device_h)
-{
-       int ret = MM_ERROR_NONE;
-       mm_sound_device_t *device_node = g_malloc0(sizeof(mm_sound_device_t));
-       debug_log("new device_node[0x%x]\n", device_node);
-
-       MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_connected_device_list_mutex, MM_ERROR_SOUND_INTERNAL);
-
-       g_connected_device_list = g_list_append(g_connected_device_list, device_node);
-
-       MMSOUND_LEAVE_CRITICAL_SECTION(&g_connected_device_list_mutex);
-
-       *device_h = device_node;
-
-       return ret;
-}
-
-int _mm_sound_mgr_device_connected_dev_list_remove_item (mm_sound_device_t *device_h)
-{
-       int ret = MM_ERROR_NONE;
-       GList *list = NULL;
-       mm_sound_device_t *device_node = NULL;
-       if (!device_h) {
-               debug_error("device_h is null\n");
-               ret = MM_ERROR_INVALID_ARGUMENT;
-       } else {
-               MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_connected_device_list_mutex, MM_ERROR_SOUND_INTERNAL);
-               for (list = g_connected_device_list; list != NULL; list = list->next) {
-                       device_node = (mm_sound_device_t *)list->data;
-                       if ((device_node) && (device_node->type == device_h->type)) {
-                               RELEASE_DEVICE_INFO_ID(device_node->id);
-                               g_connected_device_list = g_list_remove(g_connected_device_list, device_node);
-                               g_free(device_node);
-                               break;
-                       }
-               }
-               MMSOUND_LEAVE_CRITICAL_SECTION(&g_connected_device_list_mutex);
-       }
-
-       debug_log("=============== Remain devices =========================================================\n");
-       _mm_sound_mgr_device_connected_dev_list_dump();
-
-       return ret;
-}
-
-int _mm_sound_mgr_device_connected_dev_list_dump ()
-{
-       int ret = MM_ERROR_NONE;
-       GList *list = NULL;
-       mm_sound_device_t *device_node = NULL;
-       int count = 0;
-
-       debug_log("================================== device list : start =====================================\n");
-       MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_connected_device_list_mutex, MM_ERROR_SOUND_INTERNAL);
-       for (list = g_connected_device_list; list != NULL; list = list->next) {
-               device_node = (mm_sound_device_t *)list->data;
-               if (device_node) {
-                       debug_log(" idx[%d] >>>  type[%12s], id[%2d], io_direction[%4s], state[%12s], name[%s]\n",
-                               count++, device_type_str[device_node->type], device_node->id, device_io_direction_str[device_node->io_direction], device_state_str[device_node->state], device_node->name);
-               }
-       }
-       MMSOUND_LEAVE_CRITICAL_SECTION(&g_connected_device_list_mutex);
-       debug_log("================================== device list : end =======================================\n");
-
-       return ret;
-}
-
-int MMSoundMgrDeviceGetIoDirectionById (int id, device_io_direction_e *io_direction)
-{
-       int ret = MM_ERROR_NONE;
-       /* find the device handle by device_type and(or) id */
-       mm_sound_device_t *device_h = NULL;
-       ret = _mm_sound_mgr_device_connected_dev_list_find_item (&device_h, 0, id);
-       if(!ret && device_h) {
-               debug_log("found device_h[0x%x] for id[%d], io_direction[%d]\n", device_h, id, device_h->io_direction);
-               *io_direction = device_h->io_direction;
-       } else {
-               debug_error("failed to _mm_sound_mgr_device_connected_dev_list_find_item() for id[%d], ret[0x%x]\n", id, ret);
-               ret = MM_ERROR_SOUND_NO_DATA;
-       }
-       return ret;
-}
-
-/* if DEVICE is connected => add new entry (alloc id) => update status => call callback func */
-/* if DEVICE is disconnected => update status(deactivated) => call changed info callback => copy disconnected entry */
-/*                            => remove the entry (dealloc id) => call disconnected callback with copied entry */
-/* if DEVICE's info. is changed => get device_h (by type and(or) id) => update status => call callback func */
-int MMSoundMgrDeviceUpdateStatus (device_update_status_e update_status, device_type_e device_type, device_io_direction_e io_direction, int id, const char* name, device_state_e state, int *alloc_id)
-{
-       debug_warning ("[UpdateDeviceStatus] update_for[%12s], type[%11s], direction[%4s], id[%d], name[%s], state[%11s], alloc_id[0x%x]\n",
-                       device_update_str[update_status], device_type_str[device_type], device_io_direction_str[io_direction], id, name, device_state_str[state], alloc_id);
-       switch (update_status) {
-       case DEVICE_UPDATE_STATUS_CONNECTED:
-       {
-               int ret = MM_ERROR_NONE;
-               /* find the device handle by device_type and(or) id */
-               mm_sound_device_t *device_h = NULL;
-               ret = _mm_sound_mgr_device_connected_dev_list_find_item (&device_h, device_type, id);
-               if(ret == MM_ERROR_SOUND_NO_DATA && !device_h) {
-                       /* add new entry for the type */
-                       ret = _mm_sound_mgr_device_connected_dev_list_add_item (&device_h);
-                       if (ret || !device_h) {
-                               debug_error("could not add a new item for this type[%d], device_h[0x%x], ret[0x%x]\n", device_type, device_h, ret);
-                       } else {
-                               debug_error("update info for this device_h[0x%x]\n", device_h);
-                               /* update device information */
-                               /* 1. type */
-                               SET_DEVICE_INFO_TYPE(device_h, device_type);
-                               /* 2. io direction */
-                               SET_DEVICE_INFO_IO_DIRECTION(device_h, io_direction);
-                               /* 3. name */
-                               SET_DEVICE_INFO_NAME(device_h, name);
-                               /* 4. state */
-                               SET_DEVICE_INFO_STATE(device_h, DEVICE_STATE_DEACTIVATED);
-                               /* 4. id */
-                               SET_DEVICE_INFO_ID_AUTO(device_h);
-                               GET_DEVICE_INFO_ID(device_h, alloc_id);
-
-                               _mm_sound_mgr_device_connected_dev_list_dump();
-
-                               /* trigger callback functions */
-                               ret = _mm_sound_mgr_device_connected_callback(device_h, true);
-                               if (ret) {
-                                       debug_error("failed to _mm_sound_mgr_device_connected_callback() for this type[%d], device_h[0x%x], ret[0x%x]\n", device_type, device_h, ret);
-                               }
-                               /******************************************************/
-                               /* ACTIVATE this device for routing if needed */
-                               /* do here */
-                               /******************************************************/
-
-                       }
-               } else {
-                       debug_error("failed to _mm_sound_mgr_device_connected_dev_list_find_item() for this type[%d], device_h[0x%x], ret[0x%x]\n", device_type, device_h, ret);
-               }
-       }
-               break;
-
-       case DEVICE_UPDATE_STATUS_DISCONNECTED:
-       {
-               int ret = MM_ERROR_NONE;
-               /* find the device handle by device_type and(or) id */
-               mm_sound_device_t *device_h = NULL;
-               _mm_sound_mgr_device_connected_dev_list_dump();
-               ret = _mm_sound_mgr_device_connected_dev_list_find_item (&device_h, device_type, id);
-               if(!ret && device_h) {
-                       debug_log("found device_h[0x%x] for this type[%d]/id[%d]\n", device_h, device_type, id);
-
-                       /********************************************************/
-                       /* DEACTIVATE this device for routing if needed */
-                       /* do here */
-                       /********************************************************/
-
-                       /* update device information */
-                       /* 1. state */
-                       device_state_e prev_state = DEVICE_STATE_DEACTIVATED;
-                       GET_DEVICE_INFO_STATE(device_h, prev_state);
-                       SET_DEVICE_INFO_STATE(device_h, DEVICE_STATE_DEACTIVATED);
-
-                       /* trigger callback functions */
-                       if (prev_state == DEVICE_STATE_ACTIVATED) {
-                               ret = _mm_sound_mgr_device_info_changed_callback(device_h, DEVICE_CHANGED_INFO_STATE);
-                               if (ret) {
-                                       debug_error("failed to _mm_sound_mgr_device_info_changed_callback(DEVICE_CHANGED_INFO_STATE), device_h[0x%x], ret[0x%x]\n", device_h, ret);
-                               }
-                       }
-                       /* copy this device structure */
-                       mm_sound_device_t copied_device_h;
-                       memcpy ((void*)&copied_device_h, (void*)device_h, sizeof(mm_sound_device_t));
-
-                       /* remove this device from the list */
-                       ret = _mm_sound_mgr_device_connected_dev_list_remove_item (device_h);
-                       if (ret) {
-                               debug_error("failed to _mm_sound_mgr_device_connected_dev_list_remove_item(), device_h[0x%x], ret[0x%x]\n", device_h, ret);
-                       }
-
-                       ret = _mm_sound_mgr_device_connected_callback(&copied_device_h, false);
-                       if (ret) {
-                               debug_error("failed to _mm_sound_mgr_device_connected_callback() for this type[%d], device_h[0x%x], ret[0x%x]\n", device_type, copied_device_h, ret);
-                       }
-
-               } else {
-                       debug_error("failed to _mm_sound_mgr_device_connected_dev_list_find_item() for this type[%d], device_h[0x%x], ret[0x%x]\n", device_type, device_h, ret);
-               }
-       }
-               break;
-
-       case DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE:
-       {
-               int ret = MM_ERROR_NONE;
-               /* find the device handle by device_type and(or) id */
-               mm_sound_device_t *device_h = NULL;
-               ret = _mm_sound_mgr_device_connected_dev_list_find_item (&device_h, device_type, id);
-               if(!ret && device_h) {
-                       debug_log("we are going to change STATE[to %d] of this item[0x%x]\n", state, device_h);
-
-                       device_state_e prev_state = DEVICE_STATE_DEACTIVATED;
-                       GET_DEVICE_INFO_STATE(device_h, prev_state);
-                       if (prev_state == state) {
-                               debug_log("previous state is same as new one, no need to set\n");
-                       } else {
-                               SET_DEVICE_INFO_STATE(device_h, state);
-                               _mm_sound_mgr_device_connected_dev_list_dump();
-                               ret = _mm_sound_mgr_device_info_changed_callback(device_h, DEVICE_CHANGED_INFO_STATE);
-                               if (ret) {
-                                       debug_error("failed to _mm_sound_mgr_device_info_changed_callback(DEVICE_CHANGED_INFO_STATE), device_h[0x%x], ret[0x%x]\n", device_h, ret);
-                               }
-                       }
-
-               } else {
-                       debug_error("failed to _mm_sound_mgr_device_connected_dev_list_find_item() for this type[%d], device_h[0x%x], ret[0x%x]\n", device_type, device_h, ret);
-               }
-       }
-               break;
-
-       case DEVICE_UPDATE_STATUS_CHANGED_INFO_IO_DIRECTION:
-       {
-               int ret = MM_ERROR_NONE;
-               /* find the device handle by device_type and(or) id */
-               mm_sound_device_t *device_h = NULL;
-               ret = _mm_sound_mgr_device_connected_dev_list_find_item (&device_h, device_type, id);
-               if(!ret && device_h) {
-                       debug_log("we are going to change IO DIRECTION[to %d] of this item[0x%x]\n", io_direction, device_h);
-
-                       device_io_direction_e prev_io_direction = DEVICE_IO_DIRECTION_IN;
-                       GET_DEVICE_INFO_IO_DIRECTION(device_h, prev_io_direction);
-                       if (prev_io_direction == io_direction) {
-                               debug_log("previous io_direction is same as new one, no need to set\n");
-                       } else {
-                               SET_DEVICE_INFO_IO_DIRECTION(device_h, io_direction);
-                               _mm_sound_mgr_device_connected_dev_list_dump();
-                               ret = _mm_sound_mgr_device_info_changed_callback(device_h, DEVICE_CHANGED_INFO_IO_DIRECTION);
-                               if (ret) {
-                                       debug_error("failed to _mm_sound_mgr_device_info_changed_callback(DEVICE_CHANGED_INFO_DIRECTION), device_h[0x%x], ret[0x%x]\n", device_h, ret);
-                               }
-                       }
-
-               } else {
-                       debug_error("failed to _mm_sound_mgr_device_connected_dev_list_find_item() for this type[%d], device_h[0x%x], ret[0x%x]\n", device_type, device_h, ret);
-               }
-       }
-               break;
-       }
-
-       return MM_ERROR_NONE;
-}
-
-int MMSoundMgrDeviceUpdateStatusWithoutNotification (device_update_status_e update_status, device_type_e device_type, device_io_direction_e io_direction, int id, const char* name, device_state_e state, int *alloc_id)
-{
-       debug_warning ("[Update Device Status] update_status[%d], device type[%11s], io_direction[%4s], id[%d], name[%s], state[%11s], alloc_id[0x%x]\n",
-                                               update_status, device_type_str[device_type], device_io_direction_str[io_direction], id, name, device_state_str[state], alloc_id);
-       switch (update_status) {
-       case DEVICE_UPDATE_STATUS_CONNECTED:
-       {
-               int ret = MM_ERROR_NONE;
-               /* find the device handle by device_type and(or) id */
-               mm_sound_device_t *device_h = NULL;
-               ret = _mm_sound_mgr_device_connected_dev_list_find_item (&device_h, device_type, id);
-               if(ret == MM_ERROR_SOUND_NO_DATA && !device_h) {
-                       debug_log("we are going to add new item for this type[%d]/id[%d]\n", device_type, id);
-                       /* add new entry for the type */
-                       ret = _mm_sound_mgr_device_connected_dev_list_add_item (&device_h);
-                       if (ret || !device_h) {
-                               debug_error("could not add a new item for this type[%d], device_h[0x%x], ret[0x%x]\n", device_type, device_h, ret);
-                       } else {
-                               debug_error("update info for this device_h[0x%x]\n", device_h);
-                               /* update device information */
-                               /* 1. type */
-                               SET_DEVICE_INFO_TYPE(device_h, device_type);
-                               /* 2. io direction */
-                               SET_DEVICE_INFO_IO_DIRECTION(device_h, io_direction);
-                               /* 3. name */
-                               SET_DEVICE_INFO_NAME(device_h, name);
-                               /* 4. state */
-                               SET_DEVICE_INFO_STATE(device_h, DEVICE_STATE_DEACTIVATED);
-                               /* 4. id */
-                               SET_DEVICE_INFO_ID_AUTO(device_h);
-                               GET_DEVICE_INFO_ID(device_h, alloc_id);
-
-                               _mm_sound_mgr_device_connected_dev_list_dump();
-
-                               /******************************************************/
-                               /* ACTIVATE this device for routing if needed */
-                               /* do here */
-                               /******************************************************/
-
-                       }
-               } else {
-                       debug_error("failed to _mm_sound_mgr_device_connected_dev_list_find_item() for this type[%d], device_h[0x%x], ret[0x%x]\n", device_type, device_h, ret);
-               }
-       }
-               break;
-
-       case DEVICE_UPDATE_STATUS_DISCONNECTED:
-       {
-               int ret = MM_ERROR_NONE;
-               /* find the device handle by device_type and(or) id */
-               mm_sound_device_t *device_h = NULL;
-               _mm_sound_mgr_device_connected_dev_list_dump();
-               ret = _mm_sound_mgr_device_connected_dev_list_find_item (&device_h, device_type, id);
-               if(!ret && device_h) {
-                       debug_log("found device_h[0x%x] for this type[%d]/id[%d]\n", device_h, device_type, id);
-
-                       /********************************************************/
-                       /* DEACTIVATE this device for routing if needed */
-                       /* do here */
-                       /********************************************************/
-
-                       /* update device information */
-                       /* 1. state */
-                       device_state_e prev_state = DEVICE_STATE_DEACTIVATED;
-                       GET_DEVICE_INFO_STATE(device_h, prev_state);
-                       SET_DEVICE_INFO_STATE(device_h, DEVICE_STATE_DEACTIVATED);
-
-                       /* remove this device from the list */
-                       ret = _mm_sound_mgr_device_connected_dev_list_remove_item (device_h);
-                       if (ret) {
-                               debug_error("failed to _mm_sound_mgr_device_connected_dev_list_remove_item(), device_h[0x%x], ret[0x%x]\n", device_h, ret);
-                       }
-
-               } else {
-                       debug_error("failed to _mm_sound_mgr_device_connected_dev_list_find_item() for this type[%d], device_h[0x%x], ret[0x%x]\n", device_type, device_h, ret);
-               }
-       }
-               break;
-
-       case DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE:
-       {
-               int ret = MM_ERROR_NONE;
-               /* find the device handle by device_type and(or) id */
-               mm_sound_device_t *device_h = NULL;
-               ret = _mm_sound_mgr_device_connected_dev_list_find_item (&device_h, device_type, id);
-               if(!ret && device_h) {
-                       debug_log("we are going to change STATE[to %d] of this item[0x%x]\n", state, device_h);
-
-                       device_state_e prev_state = DEVICE_STATE_DEACTIVATED;
-                       GET_DEVICE_INFO_STATE(device_h, prev_state);
-                       if (prev_state == state) {
-                               debug_warning("previous state is same as new one, no need to set\n");
-                       } else {
-                               SET_DEVICE_INFO_STATE(device_h, state);
-                               _mm_sound_mgr_device_connected_dev_list_dump();
-                       }
-
-               } else {
-                       debug_error("failed to _mm_sound_mgr_device_connected_dev_list_find_item() for this type[%d], device_h[0x%x], ret[0x%x]\n", device_type, device_h, ret);
-               }
-       }
-               break;
-
-       case DEVICE_UPDATE_STATUS_CHANGED_INFO_IO_DIRECTION:
-       {
-               int ret = MM_ERROR_NONE;
-               /* find the device handle by device_type and(or) id */
-               mm_sound_device_t *device_h = NULL;
-               ret = _mm_sound_mgr_device_connected_dev_list_find_item (&device_h, device_type, id);
-               if(!ret && device_h) {
-                       debug_log("we are going to change IO DIRECTION[to %d] of this item[0x%x]\n", io_direction, device_h);
-
-                       device_io_direction_e prev_io_direction = DEVICE_IO_DIRECTION_IN;
-                       GET_DEVICE_INFO_IO_DIRECTION(device_h, prev_io_direction);
-                       if (prev_io_direction == io_direction) {
-                               debug_warning("previous io_direction is same as new one, no need to set\n");
-                       } else {
-                               SET_DEVICE_INFO_IO_DIRECTION(device_h, io_direction);
-                               _mm_sound_mgr_device_connected_dev_list_dump();
-                       }
-
-               } else {
-                       debug_error("failed to _mm_sound_mgr_device_connected_dev_list_find_item() for this type[%d], device_h[0x%x], ret[0x%x]\n", device_type, device_h, ret);
-               }
-       }
-               break;
-       }
-
-       return MM_ERROR_NONE;
-}
-#endif
diff --git a/server/mm_sound_mgr_device_dock.c b/server/mm_sound_mgr_device_dock.c
deleted file mode 100644 (file)
index 727d2a8..0000000
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * libmm-sound
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Seungbae Shin <seungbae.shin@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <stdlib.h>
-#include <string.h>
-
-#include <pthread.h>
-#include <sys/shm.h>
-#include <sys/msg.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdbool.h>
-
-#include <errno.h>
-
-#include "include/mm_sound_mgr_common.h"
-#include "../include/mm_sound_common.h"
-
-#include <mm_error.h>
-#include <mm_debug.h>
-
-#include "include/mm_sound_mgr_device.h"
-#include "include/mm_sound_mgr_device_dock.h"
-#include "include/mm_sound_mgr_session.h"
-
-/******************************* Dock Code **********************************/
-
-#include <sys/types.h>
-#include <stdbool.h>
-#include <errno.h>
-#include <assert.h>
-
-#include "mm_ipc.h"
-#include "mm_sound_common.h"
-#include "mm_sound.h"
-
-#include <vconf.h>
-#include <vconf-keys.h>
-
-#define SOUND_DOCK_ON  "/usr/share/sounds/sound-server/dock.ogg"
-#define SOUND_DOCK_OFF "/usr/share/sounds/sound-server/undock.ogg"
-#define SOUND_DOCK_ON_DELAY 1000000
-#define SOUND_DOCK_OFF_DELAY 10000
-
-#define DOCK_OFF false
-#define DOCK_ON true
-
-#define DOCK_NO_RESTORE false
-#define DOCK_RESTORE true
-
-int g_saved_dock_status;
-
-#if 0
-
-static void __dock_sound_finished_cb(void *data , int id)
-{
-       bool* is_finish = (bool*)data;
-       debug_log ("dock sound play finished!!!\n");
-
-       if (is_finish) {
-               *is_finish = true;
-       }
-}
-
-static void __play_dock_sound_sync(bool is_on, bool need_restore)
-{
-       int handle;
-       bool is_play_finished = false;
-       bool dock_sound = false;
-
-       if (g_saved_dock_status == -1) {
-               debug_log ("skip dock sound because status is not valid [%d]\n", g_saved_dock_status);
-               return;
-       }
-
-       /* check dock sound */
-#if 0
-       vconf_get_bool(VCONFKEY_SETAPPL_ACCESSORY_DOCK_SOUND, &dock_sound);
-       if (dock_sound == false) {
-               debug_log ("dock sound is disabled in setting app");
-               return;
-       }
-#endif
-
-       debug_log ("start to play dock sound : is_on=[%d], need_restore=[%d]\n", is_on, need_restore);
-
-       if (need_restore) {
-               mm_sound_play_loud_solo_sound((is_on? SOUND_DOCK_ON:SOUND_DOCK_OFF), VOLUME_TYPE_FIXED, __dock_sound_finished_cb, &is_play_finished, &handle);
-               debug_log ("waiting for dock sound finish\n");
-               while (!is_play_finished) {
-                       usleep (SOUND_DOCK_OFF_DELAY);
-               }
-       } else {
-               mm_sound_play_loud_solo_sound_no_restore((is_on? SOUND_DOCK_ON:SOUND_DOCK_OFF), VOLUME_TYPE_FIXED, __dock_sound_finished_cb, &is_play_finished, &handle);
-               debug_log ("waiting for dock sound finish\n");
-               usleep (SOUND_DOCK_ON_DELAY);
-       }
-
-       debug_log ("dock sound finished!!!\n");
-}
-
-/* DOCK status value from system server */
-static void _dock_status_changed_cb(keynode_t* node, void* data)
-{
-       int ret = 0;
-       int dock_status = 0;
-
-       if (node == NULL) {
-               debug_error ("node is null...\n");
-               return;
-       }
-
-       debug_msg ("Handling [%s] Starts\n", vconf_keynode_get_name(node));
-
-       /* Get actual vconf value */
-       vconf_get_int(VCONFKEY_SYSMAN_CRADLE_STATUS, &dock_status);
-       debug_msg ("DOCK : [%s]=[%d]\n", VCONFKEY_SYSMAN_CRADLE_STATUS, dock_status);
-
-       if (g_saved_dock_status == dock_status) {
-               debug_warning ("No changes in DOCK STATUS, do nothing....\n");
-               return;
-       }
-
-       /* Set available/non-available based on current dock status value */
-       switch (dock_status)
-       {
-       case DOCK_DESKDOCK:
-       case DOCK_CARDOCK:
-               /* Play ON sound, no path restore due to dock routing  */
-               __play_dock_sound_sync (DOCK_ON, DOCK_NO_RESTORE);
-
-               /* Update device available status (available) */
-               ret = MMSoundMgrSessionSetDeviceAvailable (DEVICE_DOCK, DOCK_ON, 0, NULL);
-               if (ret != MM_ERROR_NONE) {
-                       debug_error ("MMSoundMgrSessionSetDeviceAvailable() failed...ret=%x\n", ret);
-               }
-               break;
-
-       case DOCK_AUDIODOCK:
-       case DOCK_SMARTDOCK:
-               /* Play ON sound, no path restore due to USB Audio routing */
-               __play_dock_sound_sync (DOCK_ON, DOCK_NO_RESTORE);
-               break;
-
-       case DOCK_NONE:
-               /* Update device available status (non-available) */
-               ret = MMSoundMgrSessionSetDeviceAvailable (DEVICE_DOCK, DOCK_OFF, 0, NULL);
-               if (ret != MM_ERROR_NONE) {
-                       debug_error ("MMSoundMgrSessionSetDeviceAvailable() failed...ret=%x\n", ret);
-               }
-
-               /* Play OFF sound  */
-               __play_dock_sound_sync (DOCK_OFF, DOCK_RESTORE);
-
-               break;
-
-       default:
-               debug_warning ("Unexpected Dock Status = [%d]\n", dock_status);
-               break;
-       }
-
-       g_saved_dock_status = dock_status;
-       debug_msg ("Handling [%s] Ends normally\n", vconf_keynode_get_name(node));
-}
-
-static int _register_dock_status ()
-{
-       /* set callback for vconf key change */
-       int ret = vconf_notify_key_changed(VCONFKEY_SYSMAN_CRADLE_STATUS, _dock_status_changed_cb, NULL);
-       debug_msg ("vconf [%s] set ret = [%d]\n", VCONFKEY_SYSMAN_CRADLE_STATUS, ret);
-       return ret;
-}
-
-int MMSoundMgrDockInit(void)
-{
-       int ret = 0;
-       debug_enter("\n");
-
-       g_saved_dock_status = -1;
-
-       ret = vconf_get_int(VCONFKEY_SYSMAN_CRADLE_STATUS, &g_saved_dock_status);
-       debug_warning ("Initial status is [%d], ret=[%d]\n", g_saved_dock_status, ret);
-
-       if (_register_dock_status () != 0) {
-               debug_error ("Registering dock status failed\n");
-               return MM_ERROR_SOUND_INTERNAL;
-       }
-
-       debug_leave("\n");
-       return MM_ERROR_NONE;
-}
-
-int MMSoundMgrDockFini(void)
-{
-       debug_enter("\n");
-
-       debug_leave("\n");
-       return MM_ERROR_NONE;
-}
-
-#endif
diff --git a/server/mm_sound_mgr_device_hdmi.c b/server/mm_sound_mgr_device_hdmi.c
deleted file mode 100644 (file)
index af325c8..0000000
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * libmm-sound
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Seungbae Shin <seungbae.shin@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <stdlib.h>
-#include <string.h>
-
-#include <pthread.h>
-#include <sys/shm.h>
-#include <sys/msg.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdbool.h>
-#include <vconf.h>
-#include <vconf-keys.h>
-
-#include <errno.h>
-
-#include "include/mm_sound_mgr_common.h"
-#include "../include/mm_sound_common.h"
-
-#include <mm_error.h>
-#include <mm_debug.h>
-
-#include "include/mm_sound_mgr_device.h"
-#include "include/mm_sound_mgr_device_hdmi.h"
-#include "include/mm_sound_mgr_session.h"
-
-/******************************* HDMI Code **********************************/
-
-#include "mm_sound.h"
-
-#if 0
-#define SUPPORT_DBUS_HDMI_AUDIO
-#ifdef SUPPORT_DBUS_HDMI_AUDIO
-
-#include <gio/gio.h>
-#define DEVICED_SYSNOTI_PATH           "/Org/Tizen/System/DeviceD/SysNoti"
-#define DEVICED_SYSNOTI_INTERFACE   "org.tizen.system.deviced.SysNoti"
-#define HDMI_AUDIO_CHANGED_SIGNAL      "ChangedHDMIAudio"
-
-#define VCONFKEY_SOUND_HDMI_SUPPORT "memory/private/sound/hdmisupport"
-enum {
-       MM_SOUND_HDMI_AUDIO_UNPLUGGED = -1,
-       MM_SOUND_HDMI_AUDIO_NOT_AVAILABLE = 0,
-       MM_SOUND_HDMI_AUDIO_AVAILABLE = 1
-};
-
-typedef enum {
-       MM_SOUND_HDMI_SUPPORT_NOTHING = -1,
-       MM_SOUND_HDMI_SUPPORT_ONLY_STEREO = 0,
-       MM_SOUND_HDMI_SUPPORT_ONLY_SURROUND = 1,
-       MM_SOUND_HDMI_SUPPORT_STEREO_AND_SURROUND =2,
-} hdmi_support_type_t;
-
-GDBusConnection *conn_hdmiaudio, *conn_popup;
-guint sig_id_hdmiaudio, sig_id_popup;
-int hdmi_available = false;
-
-int _parse_hdmi_support_info(int hdmi_support, hdmi_support_type_t* support){
-       int channels = 0;
-       bool support_stereo = false, support_surround = false;
-
-       channels = hdmi_support & 0x000000FF;
-
-       if(channels == 0xFF){
-               channels = 0;
-               return 0;
-       }
-
-       if ((channels & 0x20) > 0)
-           support_surround = true;
-       if ((channels & 0x02) > 0)
-           support_stereo = true;
-
-       if (support_stereo && support_surround)
-           *support = MM_SOUND_HDMI_SUPPORT_STEREO_AND_SURROUND;
-       else if (!support_stereo && support_surround)
-           *support = MM_SOUND_HDMI_SUPPORT_ONLY_SURROUND;
-       else if (support_stereo && !support_surround)
-           *support = MM_SOUND_HDMI_SUPPORT_ONLY_STEREO;
-       else
-           *support = MM_SOUND_HDMI_SUPPORT_NOTHING;
-
-       return 1;
-}
-
-
-static void hdmi_audio_changed(GDBusConnection *conn,
-                                                          const gchar *sender_name,
-                                                          const gchar *object_path,
-                                                          const gchar *interface_name,
-                                                          const gchar *signal_name,
-                                                          GVariant *parameters,
-                                                          gpointer user_data)
-{
-       int value=0;
-       hdmi_support_type_t hdmi_support_type = MM_SOUND_HDMI_SUPPORT_NOTHING;
-       const GVariantType* value_type;
-
-       debug_msg ("sender : %s, object : %s, interface : %s, signal : %s",
-                       sender_name, object_path, interface_name, signal_name);
-       if(g_variant_is_of_type(parameters, G_VARIANT_TYPE("(i)")))
-       {
-               g_variant_get(parameters, "(i)",&value);
-               debug_msg("singal[%s] = %X\n", HDMI_AUDIO_CHANGED_SIGNAL, value);
-               vconf_set_int(VCONFKEY_SOUND_HDMI_SUPPORT, value);
-
-               if(value >= MM_SOUND_HDMI_AUDIO_AVAILABLE) {
-                       hdmi_available = true;
-                       _parse_hdmi_support_info(value, &hdmi_support_type);
-                       debug_msg("HDMI support type : %d\n", hdmi_support_type);
-                       MMSoundMgrSessionSetDeviceAvailable (DEVICE_HDMI, hdmi_available, 0, NULL);
-                       MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CONNECTED, DEVICE_TYPE_HDMI, DEVICE_IO_DIRECTION_OUT, DEVICE_ID_AUTO, NULL, 0, NULL);
-               }
-
-               if(value == MM_SOUND_HDMI_AUDIO_NOT_AVAILABLE || value == MM_SOUND_HDMI_AUDIO_UNPLUGGED){
-                       hdmi_available = false;
-                       MMSoundMgrSessionSetDeviceAvailable (DEVICE_HDMI, hdmi_available, 0, NULL);
-                       MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_DISCONNECTED, DEVICE_TYPE_HDMI, DEVICE_IO_DIRECTION_OUT, DEVICE_ID_AUTO, NULL, 0, NULL);
-               }
-       }
-       else
-       {
-               value_type = g_variant_get_type(parameters);
-               debug_warning("signal type is %s", value_type);
-       }
-
-}
-
-void _deinit_hdmi_audio_dbus(void)
-{
-       debug_fenter ();
-       g_dbus_connection_signal_unsubscribe(conn_hdmiaudio, sig_id_hdmiaudio);
-       g_object_unref(conn_hdmiaudio);
-       debug_fleave ();
-}
-
-int _init_hdmi_audio_dbus(void)
-{
-       GError *err = NULL;
-       debug_fenter ();
-
-       g_type_init();
-
-       conn_hdmiaudio = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
-       if (!conn_hdmiaudio && err) {
-               debug_error ("g_bus_get_sync() error (%s) ", err->message);
-               g_error_free (err);
-               goto error;
-       }
-
-       sig_id_hdmiaudio = g_dbus_connection_signal_subscribe(conn_hdmiaudio,
-                       NULL, DEVICED_SYSNOTI_INTERFACE, HDMI_AUDIO_CHANGED_SIGNAL, DEVICED_SYSNOTI_PATH, NULL, 0,
-                       hdmi_audio_changed, NULL, NULL);
-       if (sig_id_hdmiaudio == 0) {
-               debug_error ("g_dbus_connection_signal_subscribe() error (%d)", sig_id_hdmiaudio);
-               goto sig_error;
-       }
-
-       debug_fleave ();
-       return 0;
-
-sig_error:
-       g_dbus_connection_signal_unsubscribe(conn_hdmiaudio, sig_id_hdmiaudio);
-       g_object_unref(conn_hdmiaudio);
-
-error:
-       return -1;
-
-}
-#endif
-
-int MMSoundMgrHdmiInit(void)
-{
-       debug_enter("\n");
-#ifdef SUPPORT_DBUS_HDMI_AUDIO
-       if (_init_hdmi_audio_dbus() != 0) {
-               debug_error ("Registering hdmi audio signal handler failed\n");
-               return MM_ERROR_SOUND_INTERNAL;
-       }
-#endif
-       debug_leave("\n");
-       return MM_ERROR_NONE;
-}
-
-int MMSoundMgrHdmiFini(void)
-{
-       debug_enter("\n");
-#ifdef SUPPORT_DBUS_HDMI_AUDIO
-       _deinit_hdmi_audio_dbus();
-#endif
-       debug_leave("\n");
-       return MM_ERROR_NONE;
-}
-
-#endif
diff --git a/server/mm_sound_mgr_device_headset.c b/server/mm_sound_mgr_device_headset.c
deleted file mode 100644 (file)
index af4b1b9..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * libmm-sound
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Seungbae Shin <seungbae.shin@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <stdlib.h>
-#include <string.h>
-
-#include <pthread.h>
-#include <sys/shm.h>
-#include <sys/msg.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdbool.h>
-
-#include <errno.h>
-
-#include "include/mm_sound_mgr_common.h"
-#include "include/mm_sound_thread_pool.h"
-#include "../include/mm_sound_common.h"
-
-#include <mm_error.h>
-#include <mm_debug.h>
-
-#include "include/mm_sound_mgr_device.h"
-#include "include/mm_sound_mgr_device_headset.h"
-#include "include/mm_sound_mgr_session.h"
-
-/******************************* Headset Code **********************************/
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <assert.h>
-#include <string.h>
-#include <pthread.h>
-
-#include "mm_ipc.h"
-#include "mm_sound_common.h"
-#include "mm_sound.h"
-
-#include <vconf.h>
-#include <vconf-keys.h>
-
-#if 0
-/* earjack status value */
-static void _earjack_status_changed_cb(keynode_t* node, void* data)
-{
-       int earjack_status = 0;
-       device_io_direction_e io_direction = DEVICE_IO_DIRECTION_OUT;
-       char *name = NULL;
-
-       /* Get actual vconf value */
-       vconf_get_int(VCONFKEY_SYSMAN_EARJACK, &earjack_status);
-       debug_msg ("[%s] changed callback called, status=[%d]\n", vconf_keynode_get_name(node), earjack_status);
-
-       if (earjack_status == DEVICE_EARJACK_TYPE_SPK_WITH_MIC) {
-               io_direction = DEVICE_IO_DIRECTION_BOTH;
-               name = DEVICE_NAME_AUDIOJACK_4P;
-       } else {
-               io_direction = DEVICE_IO_DIRECTION_OUT;
-               name = DEVICE_NAME_AUDIOJACK_3P;
-       }
-       MMSoundMgrDeviceUpdateStatus (earjack_status ? DEVICE_UPDATE_STATUS_CONNECTED : DEVICE_UPDATE_STATUS_DISCONNECTED, DEVICE_TYPE_AUDIOJACK, io_direction, DEVICE_ID_AUTO, name, 0, NULL);
-       MMSoundMgrSessionSetDeviceAvailable (DEVICE_WIRED, earjack_status, earjack_status, NULL);
-}
-
-static int _register_earjack_status(void)
-{
-       /* set callback for vconf key change */
-       int ret = vconf_notify_key_changed(VCONFKEY_SYSMAN_EARJACK, _earjack_status_changed_cb, NULL);
-       debug_msg ("vconf [%s] set ret = [%d]\n", VCONFKEY_SYSMAN_EARJACK, ret);
-       return ret;
-}
-
-int MMSoundMgrHeadsetInit(void)
-{
-       debug_enter("\n");
-       _register_earjack_status();
-       debug_leave("\n");
-
-       return MM_ERROR_NONE;
-}
-
-int MMSoundMgrHeadsetFini(void)
-{
-       debug_enter("\n");
-       debug_leave("\n");
-
-       return MM_ERROR_NONE;
-}
-
-#endif
diff --git a/server/mm_sound_mgr_device_wfd.c b/server/mm_sound_mgr_device_wfd.c
deleted file mode 100644 (file)
index 300d186..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * libmm-sound
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Seungbae Shin <seungbae.shin@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <stdlib.h>
-#include <string.h>
-
-#include <pthread.h>
-#include <sys/shm.h>
-#include <sys/msg.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdbool.h>
-
-#include <errno.h>
-
-#include "include/mm_sound_mgr_common.h"
-#include "../include/mm_sound_common.h"
-
-#include <mm_error.h>
-#include <mm_debug.h>
-
-#include "include/mm_sound_mgr_device.h"
-#include "include/mm_sound_mgr_device_wfd.h"
-#include "include/mm_sound_mgr_session.h"
-
-/******************************* WFD Code **********************************/
-
-#include "mm_sound.h"
-
-#include <vconf.h>
-#include <vconf-keys.h>
-
-#if 0
-
-/* WFD status value */
-static void _miracast_wfd_status_changed_cb(keynode_t* node, void* data)
-{
-       int miracast_wfd_status = 0;
-
-       /* Get actual vconf value */
-       vconf_get_bool(VCONFKEY_MIRACAST_WFD_SOURCE_STATUS, &miracast_wfd_status);
-       debug_msg ("[%s] changed callback called, status=[%d]\n", vconf_keynode_get_name(node), miracast_wfd_status);
-
-       MMSoundMgrSessionSetDeviceAvailable (DEVICE_MIRRORING, miracast_wfd_status, 0, NULL);
-       MMSoundMgrDeviceUpdateStatus (miracast_wfd_status ? DEVICE_UPDATE_STATUS_CONNECTED : DEVICE_UPDATE_STATUS_DISCONNECTED, DEVICE_TYPE_MIRRORING, DEVICE_IO_DIRECTION_OUT, DEVICE_ID_AUTO, NULL, 0, NULL);
-}
-
-static int _register_wfd_status(void)
-{
-       /* set callback for vconf key change */
-       int ret = vconf_notify_key_changed(VCONFKEY_MIRACAST_WFD_SOURCE_STATUS, _miracast_wfd_status_changed_cb, NULL);
-       debug_msg ("vconf [%s] set ret = [%d]\n", VCONFKEY_MIRACAST_WFD_SOURCE_STATUS, ret);
-       return ret;
-}
-
-int MMSoundMgrWfdInit(void)
-{
-       debug_enter("\n");
-
-       if (_register_wfd_status() != 0) {
-               debug_error ("Registering WFD status failed\n");
-               return MM_ERROR_SOUND_INTERNAL;
-       }
-
-       debug_leave("\n");
-       return MM_ERROR_NONE;
-}
-
-int MMSoundMgrWfdFini(void)
-{
-       debug_enter("\n");
-
-       debug_leave("\n");
-       return MM_ERROR_NONE;
-}
-#endif
-
index c888dbf..1cd75bf 100644 (file)
@@ -39,7 +39,6 @@
 #include "../include/mm_sound_msg.h"
 //#include "include/mm_sound_thread_pool.h"
 #include "include/mm_sound_mgr_codec.h"
-#include "include/mm_sound_mgr_device.h"
 #include "include/mm_sound_mgr_asm.h"
 #include <mm_error.h>
 #include <mm_debug.h>
 
 #define SHM_OPEN
 
-#ifdef PULSE_CLIENT
-#include "include/mm_sound_mgr_pulse.h"
-#endif
-
 /* workaround for AF volume gain tuning */
 #define MM_SOUND_AF_FILE_PREFIX "/opt/ug/res/sounds/ug-camera-efl/sounds/af_"
 
diff --git a/server/mm_sound_mgr_pulse.c b/server/mm_sound_mgr_pulse.c
deleted file mode 100644 (file)
index 6a2136c..0000000
+++ /dev/null
@@ -1,2238 +0,0 @@
-/*
- * libmm-sound
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Seungbae Shin <seungbae.shin@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#if 0
-#include <stdlib.h>
-#include <string.h>
-
-#include <pthread.h>
-#include <sys/shm.h>
-#include <sys/msg.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdbool.h>
-
-#include <errno.h>
-
-#include "include/mm_sound_mgr_common.h"
-#include "include/mm_sound_mgr_device_dock.h"
-#include "../include/mm_sound_common.h"
-#include "../include/mm_sound.h"
-
-#include <mm_error.h>
-#include <mm_debug.h>
-#include <glib.h>
-#include <time.h>
-#include <sys/time.h>
-
-#include <pulse/pulseaudio.h>
-#include <pulse/ext-policy.h>
-#include <pulse/ext-echo-cancel.h>
-
-#ifdef SUPPORT_BT_SCO
-#define SUPPORT_BT_SCO_DETECT
-#endif
-
-#include "include/mm_sound_mgr_pulse.h"
-#include "include/mm_sound_mgr_session.h"
-#include "include/mm_sound_mgr_device.h"
-
-#include "include/mm_sound_msg.h"
-#include "include/mm_sound_mgr_ipc.h"
-
-#include <vconf.h>
-#include <vconf-keys.h>
-
-#ifdef SUPPORT_BT_SCO_DETECT
-#include "bluetooth.h"
-#ifdef TIZEN_MICRO
-#include "bluetooth-api.h"
-#include "bluetooth-audio-api.h"
-#endif
-#include "../include/mm_sound_utils.h"
-#endif
-
-#define VCONF_BT_STATUS "db/bluetooth/status"
-
-#define MAX_STRING     32
-enum{
-       DEVICE_NONE,
-       DEVICE_IN_MIC_OUT_SPEAKER,
-       DEVICE_IN_MIC_OUT_RECEIVER,
-       DEVICE_IN_MIC_OUT_WIRED,
-       DEVICE_IN_WIRED_OUT_WIRED,
-       DEVICE_IN_BT_SCO_OUT_BT_SCO,
-};
-
-typedef struct _path_info
-{
-       int device_in;
-       int device_out;
-} path_info_t;
-
-typedef struct _pulse_info
-{
-       pa_threaded_mainloop *m;
-       pa_threaded_mainloop *m_operation;
-
-       pa_context *context;
-
-       char device_api_name[MAX_STRING];
-       char device_bus_name[MAX_STRING];
-       char *usb_sink_name;
-       char *dock_sink_name;
-       bool init_bt_status;
-
-       bool is_sco_init;
-//#ifdef TIZEN_MICRO
-       bool ag_init;
-       bool hf_init;
-//#endif
-       int bt_idx;
-       int usb_idx;
-       int dock_idx;
-       int device_in_out;
-       int aec_module_idx;
-       int card_idx;
-       int sink_idx;
-       int device_type;
-#ifdef TIZEN_MICRO
-       int need_update_vol;
-#endif
-       pthread_t thread;
-       GAsyncQueue *queue;
-
-       pa_disconnect_cb disconnect_cb;
-       void* user_data;
-}pulse_info_t;
-
-typedef enum {
-       PA_CLIENT_NOT_USED,
-       PA_CLIENT_GET_CARD_INFO_BY_INDEX,
-       PA_CLIENT_GET_SERVER_INFO,
-       PA_CLIENT_SET_DEVICE_NOT_AVAILABLE,
-       PA_CLIENT_DESTROY,
-       PA_CLIENT_MAX
-}pa_client_command_t;
-
-static const char* command_str[] =
-{
-       "NotUsed",
-       "GetCardInfoByIndex",
-       //"GetSinkInfoByIndex",
-       "GetServerInfo",
-       "SetDeviceNotAvailable",
-       "Destroy",
-       "Max"
-};
-
-pthread_mutex_t g_mutex = PTHREAD_MUTEX_INITIALIZER;
-pthread_mutex_t g_bt_info_mutex = PTHREAD_MUTEX_INITIALIZER;
-int g_alloc_device_id = -1;
-
-path_info_t g_path_info;
-pulse_info_t* pulse_info = NULL;
-#ifdef TIZEN_MICRO
-static int g_bt_hf_volume_control = 0;
-static int g_bt_hf_sco_nb = 0;
-#define SPK_VOL_MAX 6
-#define CLIENT_VOLUME_MAX 16.0f
-#endif
-#define DEVICE_BUS_USB "usb"
-#define DEVICE_BUS_BUILTIN "builtin"
-#define IS_STREQ(str1, str2) (strcmp (str1, str2) == 0)
-#define IS_BUS_USB(bus) IS_STREQ(bus, DEVICE_BUS_USB)
-
-#define CHECK_CONTEXT_SUCCESS_GOTO(p, expression, label) \
-       do { \
-               if (!(expression)) { \
-                       goto label; \
-               } \
-       } while(0);
-
-#define CHECK_CONTEXT_DEAD_GOTO(c, label) \
-       do { \
-               if (!PA_CONTEXT_IS_GOOD(pa_context_get_state(c))) {\
-                       goto label; \
-               } \
-       } while(0);
-
-
-/* -------------------------------- PULSEAUDIO --------------------------------------------*/
-
-
-static void pa_context_subscribe_success_cb(pa_context *c, int success, void *userdata)
-{
-       pulse_info_t *pinfo = (pulse_info_t*)userdata;
-       debug_msg("\n");
-       pa_threaded_mainloop_signal(pinfo->m, 0);
-       return;
-}
-
-static void server_info_cb(pa_context *c, const pa_server_info *i, void *userdata)
-{
-       int ret = 0;
-       pulse_info_t *pinfo = (pulse_info_t*)userdata;
-
-       if (!i) {
-               debug_error("error in server info callback\n");
-
-    } else {
-               debug_msg ("We got default sink = [%s]\n", i->default_sink_name);
-
-               /* ToDo: Update server info */
-               ret = MMSoundMgrSessionSetDefaultSink (i->default_sink_name);
-               if (ret != MM_ERROR_NONE) {
-                       /* TODO : Error Handling */
-                       debug_error ("MMSoundMgrSessionSetDefaultSink failed....ret = [%x]\n", ret);
-               }
-    }
-
-       pa_threaded_mainloop_signal(pinfo->m, 0);
-       return;
-}
-
-static void init_card_info_cb (pa_context *c, const pa_card_info *i, int eol, void *userdata)
-{
-       pulse_info_t *pinfo = (pulse_info_t *)userdata;
-       if (pinfo == NULL) {
-               debug_error ("pinfo is null, return");
-               return;
-       }
-
-       debug_msg("\n");
-
-       if (eol || i == NULL) {
-               debug_msg ("signaling--------------\n");
-               pa_threaded_mainloop_signal (pinfo->m, 0);
-               return;
-       }
-
-       if (strstr (i->name, "bluez")) {
-               pinfo->init_bt_status = true;
-       }
-
-       return;
-}
-
-static void _store_usb_info (pulse_info_t *pinfo, bool is_usb_dock, int index, const char* name)
-{
-       if (is_usb_dock) {
-               if (pinfo->dock_sink_name) {
-                       free(pinfo->dock_sink_name);
-               }
-               pinfo->dock_sink_name = strdup(name);
-               pinfo->dock_idx = index;
-       } else {
-               if (pinfo->usb_sink_name) {
-                       free(pinfo->usb_sink_name);
-               }
-               pinfo->usb_sink_name = strdup(name);
-               pinfo->usb_idx = index;
-       }
-}
-
-static void new_card_info_cb (pa_context *c, const pa_card_info *i, int eol, void *userdata)
-{
-       int ret = 0;
-       const char* bus = NULL;
-
-       pulse_info_t *pinfo = (pulse_info_t *)userdata;
-       if (!userdata) {
-               debug_error ("NULL PARAM");
-               return;
-       }
-
-       if (eol || i == NULL) {
-               pa_threaded_mainloop_signal(pinfo->m, 0);
-               return;
-       }
-
-       bus = pa_proplist_gets(i->proplist, PA_PROP_DEVICE_BUS);
-       if (IS_BUS_USB(bus)) {
-               int dock_status = 0;
-               const char* serial = pa_proplist_gets(i->proplist, PA_PROP_DEVICE_SERIAL);
-               debug_msg ("name=[%s], bus=[%s], serial=[%s]\n", i->name, bus, serial);
-
-               vconf_get_int(VCONFKEY_SYSMAN_CRADLE_STATUS, &dock_status);
-               if ((pinfo->dock_idx == PA_INVALID_INDEX) &&
-                       ((dock_status == DOCK_AUDIODOCK) || (dock_status == DOCK_SMARTDOCK))) {
-                       _store_usb_info(pinfo, true, i->index, serial);
-                       ret = MMSoundMgrSessionSetDeviceAvailable (DEVICE_MULTIMEDIA_DOCK, AVAILABLE, 0, (serial)? serial : "NONAME");
-                       if (ret != MM_ERROR_NONE) {
-                               /* TODO : Error Handling */
-                               debug_error ("MMSoundMgrSessionSetDeviceAvailable failed....ret = [%x]", ret);
-                       }
-               } else {
-                       _store_usb_info(pinfo, false, i->index, serial);
-                       ret = MMSoundMgrSessionSetDeviceAvailable (DEVICE_USB_AUDIO, AVAILABLE, 0, (serial)? serial : "NONAME");
-                       if (ret != MM_ERROR_NONE) {
-                               /* TODO : Error Handling */
-                               debug_error ("MMSoundMgrSessionSetDeviceAvailable failed....ret = [%x]", ret);
-                       }
-                       device_io_direction_e io_direction = DEVICE_IO_DIRECTION_OUT;
-                       ret = MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CONNECTED, DEVICE_TYPE_USB_AUDIO, io_direction, DEVICE_ID_AUTO, (serial)? serial : "NONAME", 0, NULL);
-                       if (ret != MM_ERROR_NONE) {
-                               /* TODO : Error Handling */
-                               debug_error ("MMSoundMgrDeviceUpdateStatus failed....ret = [%x]", ret);
-                       }
-               }
-       } else { /* other than USB, we assume this is BT */
-               /* Get device name : eg. SBH-600 */
-               const char* desc = pa_proplist_gets(i->proplist, PA_PROP_DEVICE_DESCRIPTION);
-               debug_msg ("name=[%s], bus=[%s], desc=[%s]", i->name, bus, desc);
-
-               if (g_alloc_device_id == -1) {
-                       ret = MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CONNECTED, DEVICE_TYPE_BLUETOOTH, DEVICE_IO_DIRECTION_BOTH, DEVICE_ID_AUTO, (desc)? desc : "NONAME", 0, &g_alloc_device_id);
-                       if (ret != MM_ERROR_NONE) {
-                               /* TODO : Error Handling */
-                               debug_error ("MMSoundMgrDeviceUpdateStatus failed....ret = [%x]", ret);
-                       }
-
-               }
-               ret = MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_IO_DIRECTION, DEVICE_TYPE_BLUETOOTH, DEVICE_IO_DIRECTION_OUT, g_alloc_device_id, (desc)? desc : "NONAME", 0, NULL);
-               if (ret != MM_ERROR_NONE) {
-                       /* TODO : Error Handling */
-                       debug_error ("MMSoundMgrDeviceUpdateStatus failed....ret = [%x]", ret);
-               }
-
-               /* Store BT index for future removal */
-               pinfo->bt_idx = i->index;
-               ret = MMSoundMgrSessionSetDeviceAvailable (DEVICE_BT_A2DP, AVAILABLE, 0, (desc)? desc : "NONAME");
-               if (ret != MM_ERROR_NONE) {
-                       /* TODO : Error Handling */
-                       debug_error ("MMSoundMgrSessionSetDeviceAvailable failed....ret = [%x]", ret);
-               }
-
-       }
-       return;
-}
-
-static void context_subscribe_cb (pa_context * c, pa_subscription_event_type_t t, uint32_t idx, void *userdata)
-{
-       pulse_info_t *pinfo = (pulse_info_t *)userdata;
-
-       if (pinfo == NULL) {
-               debug_error ("pinfo is null, return");
-               return;
-       }
-
-       if ((t &  PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_CARD) {
-               debug_msg ("EVENT CARD : type=(0x%x) idx=(%u) pinfo=(%p)\n", t, idx, pinfo);
-               /* FIXME: We assumed that card is bt, card new/remove = bt new/remove */
-               if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) { /* BT/USB is removed */
-                       if (idx == pinfo->bt_idx) {
-                               pinfo->device_type = DEVICE_BT_A2DP;
-                               g_async_queue_push(pinfo->queue, (gpointer)PA_CLIENT_SET_DEVICE_NOT_AVAILABLE);
-                       } else if (idx == pinfo->usb_idx) {
-                               pinfo->device_type = DEVICE_USB_AUDIO;
-                               g_async_queue_push(pinfo->queue, (gpointer)PA_CLIENT_SET_DEVICE_NOT_AVAILABLE);
-                       } else if (idx == pinfo->dock_idx) {
-                               pinfo->device_type = DEVICE_MULTIMEDIA_DOCK;
-                               g_async_queue_push(pinfo->queue, (gpointer)PA_CLIENT_SET_DEVICE_NOT_AVAILABLE);
-                       } else {
-                               debug_warning ("Unexpected card index [%d] is removed. (Current bt index=[%d], usb index=[%d], dock index=[%d]", idx, pinfo->bt_idx, pinfo->usb_idx, pinfo->dock_idx);
-                       }
-               } else if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW) { /* BT/USB is loaded */
-                       /* Get more additional information for this card */
-                       pinfo->card_idx = idx;
-                       g_async_queue_push(pinfo->queue, (gpointer)PA_CLIENT_GET_CARD_INFO_BY_INDEX);
-               }
-       } else if ((t &  PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_SERVER) {
-               debug_msg ("EVENT SERVER : type=(0x%x) idx=(%u) pinfo=(%p)\n", t, idx, pinfo);
-#ifndef TIZEN_MICRO
-               /* FIXME : This cause crash on TIZEN_MICRO, to be removed completely */
-               g_async_queue_push(pinfo->queue, (gpointer)PA_CLIENT_GET_SERVER_INFO);
-#endif
-       } else {
-               debug_msg ("type=(0x%x) idx=(%u) is not card or server event, skip...\n", t, idx);
-               return;
-       }
-}
-
-#define PA_READY_CHECK_MAX_RETRY 20
-#define PA_READY_CHECK_INTERVAL_US 200000
-
-static void context_state_cb (pa_context *c, void *userdata)
-{
-       pulse_info_t *pinfo = (pulse_info_t *)userdata;
-       int left_retry = PA_READY_CHECK_MAX_RETRY;
-
-       if (pinfo == NULL) {
-               debug_error ("pinfo is null");
-               return;
-       }
-
-       switch (pa_context_get_state(c)) {
-               case PA_CONTEXT_UNCONNECTED:
-               case PA_CONTEXT_CONNECTING:
-               case PA_CONTEXT_AUTHORIZING:
-               case PA_CONTEXT_SETTING_NAME:
-                       break;
-               case PA_CONTEXT_FAILED:
-                       {
-                               // wait for pa_ready file creation.
-                               debug_error("pulseaudio disconnected!! wait for pa_ready file creation");
-
-                               do {
-                                       if (access(PA_READY, F_OK) == 0)
-                                               break;
-                                       usleep(PA_READY_CHECK_INTERVAL_US);
-                                       debug_error ("waiting....[%d]", left_retry);
-                               } while(left_retry--);
-
-                               debug_error("call disconnect handler [%p] to quit sound-server", pinfo->disconnect_cb);
-                               if (pinfo->disconnect_cb)
-                                       pinfo->disconnect_cb(pinfo->user_data);
-                       }
-                       break;
-               case PA_CONTEXT_TERMINATED:
-                       pa_threaded_mainloop_signal(pinfo->m, 0);
-                       break;
-
-               case PA_CONTEXT_READY:
-                       pa_threaded_mainloop_signal(pinfo->m, 0);
-                       break;
-       }
-}
-
-void *pulse_client_thread_run (void *args)
-{
-       pulse_info_t *pinfo = (pulse_info_t*)args;
-       pa_operation *o = NULL;
-       pa_client_command_t cmd = PA_CLIENT_NOT_USED;
-
-#if 0
-       while(1)
-       {
-               cmd = (pa_client_command_t)g_async_queue_pop(pinfo->queue);
-               debug_msg("pop cmd = [%d][%s]", cmd, command_str[cmd]);
-               if(cmd <= PA_CLIENT_NOT_USED || cmd >= PA_CLIENT_MAX) {
-                       continue;
-               }
-               if ((pa_client_command_t)cmd == PA_CLIENT_SET_DEVICE_NOT_AVAILABLE) {
-                       if (pinfo->device_type == DEVICE_BT_A2DP) {
-                               debug_msg("DEVICE_BT_A2DP");
-                               MMSoundMgrSessionSetDeviceAvailable (DEVICE_BT_A2DP, NOT_AVAILABLE, 0, NULL);
-                               if (g_alloc_device_id != -1) {
-                                       device_io_direction_e prev_io_direction;
-                                       MMSoundMgrDeviceGetIoDirectionById (g_alloc_device_id, &prev_io_direction);
-                                       if (prev_io_direction == MM_SOUND_DEVICE_IO_DIRECTION_OUT) {
-                                               MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_IO_DIRECTION, DEVICE_TYPE_BLUETOOTH, MM_SOUND_DEVICE_IO_DIRECTION_BOTH, g_alloc_device_id, NULL, 0, 0);
-                                       }
-                                       MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_DISCONNECTED, DEVICE_TYPE_BLUETOOTH, MM_SOUND_DEVICE_IO_DIRECTION_BOTH, g_alloc_device_id, NULL, 0, 0);
-                                       g_alloc_device_id = -1;
-                               }
-                               pinfo->bt_idx = PA_INVALID_INDEX;
-                               pinfo->device_type = PA_INVALID_INDEX;
-                       } else if(pinfo->device_type == DEVICE_USB_AUDIO) {
-                               debug_msg("DEVICE_USB_AUDIO");
-                               MMSoundMgrSessionSetDeviceAvailable (DEVICE_USB_AUDIO, NOT_AVAILABLE, 0, NULL);
-                               device_io_direction_e io_direction = DEVICE_IO_DIRECTION_OUT;
-                               MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_DISCONNECTED, DEVICE_TYPE_USB_AUDIO, io_direction, DEVICE_ID_AUTO, NULL, 0, NULL);
-                               pinfo->usb_idx = PA_INVALID_INDEX;
-                               pinfo->device_type = PA_INVALID_INDEX;
-                               if (pinfo->usb_sink_name) {
-                                       free(pinfo->usb_sink_name);
-                                       pinfo->usb_sink_name = NULL;
-                               }
-                       } else if(pinfo->device_type == DEVICE_MULTIMEDIA_DOCK) {
-                               debug_msg("DEVICE_MULTIMEDIA_DOCK");
-                               MMSoundMgrSessionSetDeviceAvailable (DEVICE_MULTIMEDIA_DOCK, NOT_AVAILABLE, 0, NULL);
-                               pinfo->dock_idx = PA_INVALID_INDEX;
-                               pinfo->device_type = PA_INVALID_INDEX;
-                               if (pinfo->dock_sink_name) {
-                                       free(pinfo->dock_sink_name);
-                                       pinfo->dock_sink_name = NULL;
-                               }
-                       }
-                       continue;
-               }
-               pa_threaded_mainloop_lock(pinfo->m);
-               CHECK_CONTEXT_DEAD_GOTO(pinfo->context, unlock_and_fail);
-
-               switch((pa_client_command_t)cmd)
-               {
-                       case PA_CLIENT_GET_CARD_INFO_BY_INDEX:
-                               debug_msg("new card(usb/a2dp) detected.");
-                               o = pa_context_get_card_info_by_index (pinfo->context, pinfo->card_idx, new_card_info_cb, pinfo);
-                               break;
-
-                       case PA_CLIENT_GET_SERVER_INFO:
-                               o = pa_context_get_server_info(pinfo->context, server_info_cb, pinfo);
-                               break;
-
-                       case PA_CLIENT_DESTROY:
-                               goto destroy;
-                               /* FALL THROUGH */
-                       default:
-                               debug_msg("unsupported command\n");
-                               goto unlock_and_fail;
-                               /* FALL THROUGH */
-               }
-
-               CHECK_CONTEXT_SUCCESS_GOTO(pinfo->context, o, unlock_and_fail);
-               while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) {
-                       pa_threaded_mainloop_wait(pinfo->m);
-                       CHECK_CONTEXT_DEAD_GOTO(pinfo->context, unlock_and_fail);
-               }
-               pa_operation_unref(o);
-               pa_threaded_mainloop_unlock(pinfo->m);
-
-               continue;
-
-unlock_and_fail:
-               if (o) {
-                       pa_operation_cancel(o);
-                       pa_operation_unref(o);
-               }
-               pa_threaded_mainloop_unlock(pinfo->m);
-       }
-
-       return 0;
-
-destroy:
-       pa_threaded_mainloop_unlock(pinfo->m);
-#endif
-
-       return 0;
-}
-
-static int pulse_client_thread_init(pulse_info_t *pinfo)
-{
-       debug_msg("\n");
-
-       pinfo->queue = g_async_queue_new();
-       if(!pinfo->queue) {
-               return -1;
-       }
-
-       if(pthread_create(&pinfo->thread, NULL, pulse_client_thread_run, pinfo) < 0) {
-               return -1;
-       }
-
-       return 0;
-}
-
-static int pulse_init (pulse_info_t * pinfo)
-{
-       int res;
-       pa_operation *o = NULL;
-
-       debug_msg (">>>>>>>>> \n");
-
-       if (pinfo == NULL) {
-               debug_error ("pinfo is null");
-               return -1;
-       }
-
-       /* Create new mainloop */
-       pinfo->m = pa_threaded_mainloop_new();
-       //g_assert(g_m);
-
-       res = pa_threaded_mainloop_start (pinfo->m);
-       //g_assert (res == 0);
-
-       /* LOCK thread */
-       pa_threaded_mainloop_lock (pinfo->m);
-
-       /* Get mainloop API */
-       pa_mainloop_api *api = pa_threaded_mainloop_get_api(pinfo->m);
-
-       /* Create new Context */
-       pinfo->context = pa_context_new(api, "SOUND_SERVER_ROUTE_MANAGER");
-
-       /* Set Callback */
-       pa_context_set_state_callback (pinfo->context, context_state_cb, pinfo);
-
-       /* Connect */
-       if (pa_context_connect (pinfo->context, NULL, PA_CONTEXT_NOAUTOSPAWN, NULL) < 0) {
-               debug_error ("connection error\n");
-       }
-
-       for (;;) {
-               pa_context_state_t state = pa_context_get_state (pinfo->context);
-               debug_msg ("context state is now %d\n", state);
-
-               if (!PA_CONTEXT_IS_GOOD (state)) {
-                       debug_error ("connection failed\n");
-                       break;
-               }
-
-               if (state == PA_CONTEXT_READY) {
-                       break;
-               }
-
-               /* Wait until the context is ready */
-               debug_msg ("waiting..................\n");
-               pa_threaded_mainloop_wait (pinfo->m);
-       }
-
-       pa_context_set_subscribe_callback(pinfo->context, context_subscribe_cb, pinfo);
-       o = pa_context_subscribe(pinfo->context,
-                       (pa_subscription_mask_t)PA_SUBSCRIPTION_MASK_CARD | PA_SUBSCRIPTION_MASK_SINK | PA_SUBSCRIPTION_MASK_SERVER,
-                       pa_context_subscribe_success_cb,pinfo);
-
-       CHECK_CONTEXT_SUCCESS_GOTO(pinfo->context, o, unlock_and_fail);
-       while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) {
-               pa_threaded_mainloop_wait(pinfo->m);
-               CHECK_CONTEXT_DEAD_GOTO(pinfo->context, unlock_and_fail);
-       }
-       pa_operation_unref(o);
-
-       /* Get initial card info */
-       o = pa_context_get_card_info_list (pinfo->context, init_card_info_cb, pinfo);
-
-       CHECK_CONTEXT_SUCCESS_GOTO(pinfo->context, o, unlock_and_fail);
-       while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) {
-               pa_threaded_mainloop_wait(pinfo->m);
-               CHECK_CONTEXT_DEAD_GOTO(pinfo->context, unlock_and_fail);
-       }
-       pa_operation_unref(o);
-
-       /* UNLOCK thread */
-       pa_threaded_mainloop_unlock (pinfo->m);
-
-       debug_msg ("<<<<<<<<<<\n");
-
-       return res;
-
-unlock_and_fail:
-       if (o) {
-               pa_operation_cancel(o);
-               pa_operation_unref(o);
-       }
-       pa_threaded_mainloop_unlock(pinfo->m);
-
-       debug_msg ("<<<<<<<<<<\n");
-
-       return res;
-}
-
-static int pulse_deinit (pulse_info_t * pinfo)
-{
-       if (pinfo == NULL) {
-               debug_error ("pinfo is null");
-               return -1;
-       }
-
-       pa_threaded_mainloop_lock (pinfo->m);
-       if (pinfo->context) {
-               pa_context_disconnect (pinfo->context);
-
-               /* Make sure we don't get any further callbacks */
-               pa_context_set_state_callback (pinfo->context, NULL, NULL);
-
-               pa_context_unref (pinfo->context);
-               pinfo->context = NULL;
-       }
-       pa_threaded_mainloop_unlock (pinfo->m);
-
-       pa_threaded_mainloop_stop (pinfo->m);
-       pa_threaded_mainloop_free (pinfo->m);
-
-       debug_msg ("<<<<<<<<<<\n");
-
-       return 0;
-
-}
-
-#ifdef _TIZEN_PUBLIC_
-#define AEC_ARGUMENT "aec_method=speex"
-#else
-#define AEC_ARGUMENT "aec_method=lvvefs sink_master=alsa_output.0.analog-stereo source_master=alsa_input.0.analog-stereo"
-#endif
-
-static void unload_hdmi_cb(pa_context *c, int success, void *userdata)
-{
-       pulse_info_t *pinfo = (pulse_info_t *)userdata;
-       if (pinfo == NULL) {
-               debug_error ("pinfo is null");
-               return;
-       }
-
-       if (success) {
-               debug_msg ("[PA_CB] m[%p] c[%p] HDMI unload success", pinfo->m, c);
-       } else {
-               debug_error("[PA_CB] m[%p] c[%p] HDMI unload fail:%s", pinfo->m, c, pa_strerror(pa_context_errno(c)));
-       }
-
-       pa_threaded_mainloop_signal(pinfo->m, 0);
-}
-
-/* -------------------------------- BT SCO --------------------------------------------*/
-#ifdef SUPPORT_BT_SCO_DETECT
-
-bool MMSoundMgrPulseBTSCOWBStatus()
-{
-       int ret = 0;
-       bool is_wb_enabled = 0;
-       bool sco_on = 1;
-
-       /* BT Api support thread safty */
-       debug_log ("Get WB status");
-#ifdef BT_THREAD_SAFTY_SUPPORT
-       ret = bt_ag_is_sco_opened(&sco_on);
-       if (ret != BT_ERROR_NONE) {
-               debug_error("SCO is not opened [%d]", sco_on);
-       }
-#endif
-
-       /* Check enabled if opened */
-       if (sco_on) {
-       /* FIXME : check with product api of bluetooth */
-       }
-       return is_wb_enabled;
-}
-
-bool MMSoundMgrPulseBTSCONRECStatus()
-{
-       int ret = 0;
-       bool is_nrec_enabled = 0;
-       bool sco_on = 1;
-
-       /* BT Api support thread safty */
-       debug_log ("Get NREC status");
-#ifdef BT_THREAD_SAFTY_SUPPORT
-       ret = bt_ag_is_sco_opened(&sco_on);
-       if (ret != BT_ERROR_NONE) {
-               debug_error("SCO is not opened [%d]", sco_on);
-       }
-#endif
-
-       /* Check enabled if opened */
-       if (sco_on) {
-               ret = bt_ag_is_nrec_enabled (&is_nrec_enabled);
-               if (ret != BT_ERROR_NONE) {
-                       debug_error ("Fail to get nrec status [%d]", ret);
-               }
-       }
-       return is_nrec_enabled;
-}
-
-void MMSoundMgrPulseUpdateBluetoothAGCodec(void)
-{
-       int ret = 0;
-       bool is_nrec_enabled = 0;
-       bool is_wb_enabled = 0;
-       bool sco_on = 1;
-
-       /* BT Api support thread safty */
-       debug_log ("Updating BT SCO info");
-#ifdef BT_THREAD_SAFTY_SUPPORT
-       ret = bt_ag_is_sco_opened(&sco_on);
-       if (ret != BT_ERROR_NONE) {
-               debug_error("SCO is not opened [%d]", sco_on);
-       }
-#endif
-
-       /* Check NREC enabled if opened */
-       if (sco_on) {
-               ret = bt_ag_is_nrec_enabled (&is_nrec_enabled);
-               if (ret != BT_ERROR_NONE) {
-                       debug_error ("Fail to get nrec status [%d]", ret);
-               }
-               /* FIXME : check with product api of bluetooth */
-       }
-
-       debug_warning("BT SCO info :: sco[%d], is_nrec_enabled[%d], is_wb_enabled[%d]", sco_on, is_nrec_enabled, is_wb_enabled);
-       MMSoundMgrSessionSetSCO (sco_on, is_nrec_enabled, is_wb_enabled);
-}
-
-static void __bt_audio_connection_state_changed_cb(int result,
-                                       bool connected, const char *remote_address,
-                                       bt_audio_profile_type_e type, void *user_data)
-{
-       /*      0 : BT_AUDIO_PROFILE_TYPE_ALL
-               1 : BT_AUDIO_PROFILE_TYPE_HSP_HFP
-               2 : BT_AUDIO_PROFILE_TYPE_A2DP
-               3 : BT_AUDIO_PROFILE_TYPE_AG    */
-
-#if 0
-       const static char * type_str[4] = { "ALL", "HSP/HFP", "A2DP", "AG" };
-       int length = sizeof(type_str) / sizeof(char*);
-       pulse_info_t* pinfo = (pulse_info_t*)user_data;
-
-       if(pinfo->ag_init == true) {
-               if (type > length) {
-                       debug_warning("Not supportted bt audio profile type. type(%d)\n", type);
-                       return;
-               }
-
-               debug_msg("connection state changed. connected(%s), type(%s), address(%s), result(%d)\n",
-                       connected == true ? "connected" : "disconnected",
-                       (type >= 0 && type < length) ? type_str[type] : "unknown type",
-                       remote_address != NULL ? remote_address : "NULL", result);
-
-               /* Set SCO Device available */
-               if (type == BT_AUDIO_PROFILE_TYPE_HSP_HFP) {
-                       device_io_direction_e io_direction = DEVICE_IO_DIRECTION_BOTH;
-                       if (connected && (g_alloc_device_id == -1) ) {
-                               MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CONNECTED, DEVICE_TYPE_BLUETOOTH, io_direction, DEVICE_ID_AUTO, NULL, 0, &g_alloc_device_id);
-                       }
-                       MMSoundMgrSessionSetDeviceAvailable (DEVICE_BT_SCO, connected, 0, NULL);
-
-                       if (!connected && (g_alloc_device_id != -1)) {
-                               int ret = MM_ERROR_NONE;
-                               device_io_direction_e prev_io_direction;
-                               ret = MMSoundMgrDeviceGetIoDirectionById (g_alloc_device_id, &prev_io_direction);
-                               if (prev_io_direction == MM_SOUND_DEVICE_IO_DIRECTION_OUT) {
-                                       MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_IO_DIRECTION, DEVICE_TYPE_BLUETOOTH, MM_SOUND_DEVICE_IO_DIRECTION_BOTH, g_alloc_device_id, NULL, 0, 0);
-                               }
-                               MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_DISCONNECTED, DEVICE_TYPE_BLUETOOTH, MM_SOUND_DEVICE_IO_DIRECTION_BOTH, g_alloc_device_id, NULL, 0, 0);
-                               g_alloc_device_id = -1;
-                       }
-               }
-               debug_msg("connection state changed end\n");
-       } else
-               debug_msg("bt ag-sco is not ready. ag_init(%d)\n", pinfo->ag_init);
-#endif
-
-}
-
-static void __bt_ag_sco_state_changed_cb(int result, bool opened, void *user_data)
-{
-       session_t session = 0;
-       pulse_info_t* pinfo = (pulse_info_t*)user_data;
-
-       debug_msg("bt ag-sco state changed. opend(%d), ag_init(%d)\n", opened, pinfo->ag_init);
-
-       if(pinfo->ag_init == true) {
-               if (opened) {
-                       MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_IO_DIRECTION, DEVICE_TYPE_BLUETOOTH, DEVICE_IO_DIRECTION_BOTH, DEVICE_ID_AUTO, NULL, DEVICE_STATE_DEACTIVATED, NULL);
-               } else {
-                       MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_IO_DIRECTION, DEVICE_TYPE_BLUETOOTH, DEVICE_IO_DIRECTION_OUT, DEVICE_ID_AUTO, NULL, DEVICE_STATE_DEACTIVATED, NULL);
-               }
-               MMSoundMgrSessionGetSession(&session);
-               if (session == SESSION_VOICECALL ||
-                       session == SESSION_VIDEOCALL ||
-                       session == SESSION_VOIP) {
-                       debug_warning("SESSION(%d), we don't handle sco stat in call session. sound-path should be routed in active device function by call app\n", session);
-                       return;
-               }
-
-               MMSoundMgrSessionEnableAgSCO (opened);
-       } else
-               debug_msg ("bt ag-sco is not ready. opened(%d), ag_init(%d)\n", pinfo->ag_init);
-
-}
-
-static int __bt_ag_initialize(pulse_info_t* pinfo)
-{
-       int ret = 0;
-
-       debug_msg("__bt_ag_initialize start");
-
-       ret = bt_audio_initialize();
-       if (ret != BT_ERROR_NONE) {
-               debug_error ("bt_audio_initialize error!!! [%d]", ret);
-               goto FAIL;
-       }
-
-       ret = bt_audio_set_connection_state_changed_cb(__bt_audio_connection_state_changed_cb, pinfo);
-       if (ret != BT_ERROR_NONE) {
-               debug_error ("bt_audio_set_connection_state_changed_cb error!!! [%d]", ret);
-               goto FAIL;
-       }
-
-       ret = bt_ag_set_sco_state_changed_cb(__bt_ag_sco_state_changed_cb, pinfo);
-       if (ret != BT_ERROR_NONE) {
-               debug_error ("bt_ag_set_sco_state_changed_cb error!!! [%d]", ret);
-               goto FAIL;
-       }
-
-       debug_msg("__bt_ag_initialize success");
-
-FAIL:
-       debug_error("__bt_ag_initialize failed(%d)", ret);
-       return ret;
-}
-
-static int __bt_ag_deinitialize(pulse_info_t* pinfo)
-{
-       int ret = 0;
-
-       debug_msg("__bt_ag_deinitialize start");
-
-       ret = bt_audio_unset_connection_state_changed_cb();
-       if (ret != BT_ERROR_NONE) {
-               debug_error ("bt_audio_unset_connection_state_changed_cb error!!! [%d]", ret);
-               goto FAIL;
-       }
-       ret = bt_ag_unset_sco_state_changed_cb();
-       if (ret != BT_ERROR_NONE) {
-               debug_error ("bt_ag_unset_sco_state_changed_cb error!!! [%d]", ret);
-               goto FAIL;
-       }
-       ret = bt_audio_deinitialize();
-       if (ret != BT_ERROR_NONE) {
-               debug_error ("bt_audio_deinitialize error!!! [%d]", ret);
-               goto FAIL;
-       }
-
-       debug_msg("__bt_ag_deinitialize success");
-
-FAIL:
-       debug_warning("__bt_ag_deinitialize failed. ret(%d)", ret);
-       return ret;
-}
-
-#ifdef TIZEN_MICRO
-void _speaker_volume_changed_cb()
-{
-       unsigned int vconf_value = 0;
-       int  ret = 0;
-       session_t cur_session = 0;
-       float ratio = 0.0f;
-       float client_vol_max = CLIENT_VOLUME_MAX;
-       int voltype = VOLUME_TYPE_CALL;
-       int max_vol = 0;
-       int native_vol = 0;
-       int client_vol = 0;
-
-       int mapping_table[2][9] = {
-               {0, 0, 3, 9, 11, 13, 15, 15, 15}, // call volume max : 6
-               {0, 0, 3, 6,  9,  8, 10, 13, 15}  // call volume max: 8
-       };
-
-       if(g_bt_hf_volume_control) {
-               g_bt_hf_volume_control = 0;
-               return;
-       }
-
-       /* In case of changing vconf key call/voip volume by pulse audio */
-       ret = MMSoundMgrSessionGetSession(&cur_session);
-       if(ret)
-               debug_warning("Fail to get current session");
-
-       if(cur_session == SESSION_VOICECALL) {
-               ret = _mm_sound_volume_get_value_by_type(VOLUME_TYPE_CALL, &vconf_value);
-               voltype = VOLUME_TYPE_CALL;
-       } else if(cur_session == SESSION_VOIP) {
-               ret = _mm_sound_volume_get_value_by_type(VOLUME_TYPE_VOIP, &vconf_value);
-               voltype = VOLUME_TYPE_VOIP;
-       } else {
-               debug_warning("Invalid volume control by [%d] session", cur_session);
-               return;
-       }
-
-       if(ret) {
-               debug_warning("Fail to get volume value %x", ret);
-               return;
-       }
-#if 0
-       /* TODO : need to clarify BT volume requirement */
-       /* mm_sound_volume_get_step is deprecated now.(rather use dbus interface in pulseaudio directly, see sound-manager) */
-       if(MM_ERROR_NONE != mm_sound_volume_get_step(voltype, &max_vol)) {
-               debug_warning("get volume max failed. voltype(%d)\n", voltype);
-               return;
-       }
-#endif
-       native_vol = vconf_value;
-
-       /* limitation : should be matched between client volume 9 to native volume and
-       native volume to client volume 9 for BLUETOOTH certification.*/
-       if(max_vol >= 9) {
-               client_vol = mapping_table[1][native_vol];
-       } else {
-               client_vol = mapping_table[0][native_vol];
-       }
-
-       /* Set in case of control by application */
-       ret = bluetooth_hf_set_speaker_gain(client_vol);
-       if(ret)
-               debug_warning("Set bt hf speaker gain failed %x", ret);
-
-       debug_msg("send paired device volume change msg by BT. voltype(%d), native_vol(%d), client_vol(%d), max_vol(%d)",
-               voltype, native_vol, client_vol, max_vol);
-}
-
-static int __bt_hf_enable_volume_changed_cb(int enable)
-{
-       if(enable) {
-               if(vconf_notify_key_changed(VCONF_KEY_VOLUME_TYPE_CALL, _speaker_volume_changed_cb, NULL)) {
-                       debug_error("vconf_notify_key_changed fail\n");
-               }
-               if(vconf_notify_key_changed(VCONF_KEY_VOLUME_TYPE_VOIP, _speaker_volume_changed_cb, NULL)) {
-                       debug_error("vconf_notify_key_changed fail\n");
-               }
-       } else {
-               if(vconf_ignore_key_changed(VCONF_KEY_VOLUME_TYPE_CALL, _speaker_volume_changed_cb)) {
-                       debug_error("vconf_ignore_key_changed fail\n");
-               }
-               if(vconf_ignore_key_changed(VCONF_KEY_VOLUME_TYPE_VOIP, _speaker_volume_changed_cb)) {
-                       debug_error("vconf_ignore_key_changed fail\n");
-               }
-       }
-       return 0;
-}
-
-static int _bt_hf_set_volume_by_client(const unsigned int vol)
-{
-       session_t session;
-       volume_type_t voltype = VOLUME_TYPE_CALL;
-       float ratio = 0;
-       int native_vol = 0;
-       int max_vol = 0;
-       int ret = MM_ERROR_NONE;
-
-       int mapping_table[2][16] = {
-               { 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6 }, // call volume max : 6
-               { 1, 1, 1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 8 } // call volume max: 8
-       };
-
-       ret = MMSoundMgrSessionGetSession(&session);
-       if(ret)
-               debug_warning("Fail to get session\ns");
-
-       if(session != SESSION_VOICECALL && session != SESSION_VOIP) {
-               debug_warning("session is not voice/voip. we handle only voice/voip volume. session(%s)\n",
-                       MMSoundMgrSessionGetSessionString(session));
-               return MM_ERROR_NONE;
-       } else {
-               if(session == SESSION_VOICECALL)
-                       voltype = VOLUME_TYPE_CALL;
-               else
-                       voltype = VOLUME_TYPE_VOIP;
-       }
-
-#if 0
-       /* TODO : need to clarify BT volume requirement */
-       /* mm_sound_volume_get_step is deprecated now.(rather use dbus interface in pulseaudio directly, see sound-manager) */
-       if(MM_ERROR_NONE != mm_sound_volume_get_step(voltype, &max_vol)) {
-               debug_warning("get volume max failed. voltype(%d)\n", voltype);
-               return;
-       }
-#endif
-
-       /* limitation : should be matched between client volume 9 to native volume 3 and
-       native volume 3 to client volume 9 for BLUETOOTH certification.*/
-       if(max_vol >= 9) {
-               native_vol = mapping_table[1][vol];
-       } else {
-               native_vol = mapping_table[0][vol];
-       }
-
-       /* we should check volume change callback for voice/voip.
-       because hf client device(me) send paired device volume changed message again. */
-       g_bt_hf_volume_control = 1;
-       _mm_sound_volume_set_value_by_type(voltype, native_vol);
-       MMSoundMgrPulseSetVolumeLevel(voltype, native_vol);
-
-       debug_msg("set volume by HF client. voltype(%d), client_vol(%d), native_vol(%d), max_vol(%d)\n",
-               voltype, vol, native_vol, max_vol);
-
-       return ret;
-}
-
-void _bt_hf_cb (int event, bt_hf_event_param_t *event_param, void * user_data)
-{
-       unsigned int vol_value = 0;
-       char str_message[256];
-       int ret = 0;
-       unsigned int codec_id;
-       subsession_t sub = 0;
-
-       if (event_param == NULL) {
-               debug_critical("Param data is NULL\n");
-               return;
-       }
-
-       sprintf (str_message, "HF event : [0x%04x], event_param : 0x%p, user_data : 0x%p", event, event_param, user_data);
-
-       switch (event) {
-       case BLUETOOTH_EVENT_HF_CONNECTED:
-               /* get WB capability here and set */
-               ret = bluetooth_hf_get_codec(&codec_id);
-               if (ret == BLUETOOTH_ERROR_NONE) {
-                       switch (codec_id) {
-                       case BLUETOOTH_CODEC_ID_CVSD: /* NB */
-                               g_bt_hf_sco_nb = 1;
-                               MMSoundMgrSessionSetHFBandwidth (MM_SOUND_BANDWIDTH_NB);
-                               break;
-                       case BLUETOOTH_CODEC_ID_MSBC: /* WB */
-                               g_bt_hf_sco_nb = 0;
-                               MMSoundMgrSessionSetHFBandwidth (MM_SOUND_BANDWIDTH_WB);
-                               break;
-                       default:
-                               break;
-                       }
-               }
-               MMSoundMgrSessionSetHFPConnectionState(MM_SOUND_HFP_STATUS_UNKNOWN);
-               debug_msg("%s >> %s", str_message, "BLUETOOTH_EVENT_HF_CONNECTED");
-               break;
-
-       case BLUETOOTH_EVENT_HF_DISCONNECTED:
-               MMSoundMgrSessionSetHFPConnectionState(MM_SOUND_HFP_STATUS_UNKNOWN);
-               debug_msg("%s >> %s", str_message, "BLUETOOTH_EVENT_HF_DISCONNECTED");
-               break;
-
-       case BLUETOOTH_EVENT_HF_CALL_STATUS:
-               {
-                       bt_hf_call_list_s * call_list = event_param->param_data;
-                       bt_hf_call_status_info_t **call_info;
-                       int i = 0;
-
-                       if (call_list == NULL) {
-                               debug_error("call_list is NULL");
-                               break;
-                       }
-
-                       debug_msg("%s >> %s : call_list_count = %d", str_message, "BLUETOOTH_EVENT_HF_CALL_STATUS",  call_list->count);
-
-                       if (call_list->count > 0) {
-                               call_info = g_malloc0(sizeof(bt_hf_call_status_info_t *) * call_list->count);
-                               if (call_info) {
-                                       if (bluetooth_hf_get_call_list(call_list->list, call_info) == BLUETOOTH_ERROR_NONE) {
-                                               /* o 1 = Held
-                                               o 2 = Dialing (outgoing calls only)
-                                               o 3 = Alerting (outgoing calls only)
-                                               o 4 = Incoming (incoming calls only)
-                                               o 5 = Waiting (incoming calls only)
-                                               o 6 = Call held by Response and Hold */
-                                               if (call_list->count >= 1) {
-                                                       for(i=0; i<call_list->count; i++) {
-                                                               debug_msg("Call status call_count(%d), call_status(%d)", i, call_info[i]->status);
-                                                               if(call_info[i]->status == 4)
-                                                                       MMSoundMgrSessionSetHFPConnectionState(MM_SOUND_HFP_STATUS_INCOMMING_CALL);
-                                                               else
-                                                                       MMSoundMgrSessionSetHFPConnectionState(MM_SOUND_HFP_STATUS_UNKNOWN);
-                                                       }
-                                               }
-                                       }
-
-                                       g_free(call_info);
-                                       call_info = NULL;
-                               } else {
-                                       debug_error("call_info is NULL");
-                               }
-                       }
-               }
-               break;
-
-       case BLUETOOTH_EVENT_HF_AUDIO_CONNECTED:
-               __bt_hf_enable_volume_changed_cb(TRUE);
-               ret = MMSoundMgrSessionGetSubSession(&sub);
-
-               /* get WB capability here and set */
-               ret = bluetooth_hf_get_codec(&codec_id);
-               if (ret == BLUETOOTH_ERROR_NONE) {
-                       switch (codec_id) {
-                       case BLUETOOTH_CODEC_ID_CVSD: /* NB */
-                               MMSoundMgrSessionSetHFBandwidth (MM_SOUND_BANDWIDTH_NB);
-                               debug_msg("Previous band NB %d",g_bt_hf_sco_nb);
-                               if(!g_bt_hf_sco_nb && sub == SUBSESSION_VOICE ) {
-                                       ret = MMSoundMgrSessionSetDuplicateSubSession();
-                                       if(!ret)
-                                               debug_warning("Fail to set duplicate sub session");
-                               }
-                               g_bt_hf_sco_nb = 1;
-                               break;
-                       case BLUETOOTH_CODEC_ID_MSBC: /* WB */
-                               MMSoundMgrSessionSetHFBandwidth (MM_SOUND_BANDWIDTH_WB);
-                               debug_msg("Previous band NB %d",g_bt_hf_sco_nb);
-                               if(g_bt_hf_sco_nb && sub == SUBSESSION_VOICE) {
-                                       ret = MMSoundMgrSessionSetDuplicateSubSession();
-                                       if(!ret)
-                                               debug_warning("Fail to set duplicate sub session");
-                               }
-                               g_bt_hf_sco_nb = 0;
-                               break;
-                       default:
-                               break;
-                       }
-               }
-               debug_msg("%s >> %s : codec_id=%d(NB:1, WB:2)", str_message, "BLUETOOTH_EVENT_HF_AUDIO_CONNECTED", codec_id);
-               break;
-
-       case BLUETOOTH_EVENT_HF_AUDIO_DISCONNECTED:
-               __bt_hf_enable_volume_changed_cb(FALSE);
-               MMSoundMgrSessionSetHFPConnectionState(MM_SOUND_HFP_STATUS_UNKNOWN);
-               debug_msg("%s >> %s", str_message, "BLUETOOTH_EVENT_HF_AUDIO_DISCONNECTED");
-               break;
-
-       case BLUETOOTH_EVENT_HF_RING_INDICATOR:
-               debug_msg("%s >> %s : %s", str_message, "BLUETOOTH_EVENT_HF_RING_INDICATOR",
-                               (event_param->param_data)? event_param->param_data : "NULL");
-               break;
-
-       case BLUETOOTH_EVENT_HF_CALL_TERMINATED:
-               MMSoundMgrSessionSetHFPConnectionState(MM_SOUND_HFP_STATUS_UNKNOWN);
-               debug_msg("%s >> %s", str_message, "BLUETOOTH_EVENT_HF_CALL_TERMINATED");
-               break;
-
-       case BLUETOOTH_EVENT_HF_CALL_STARTED:
-               debug_msg("%s >> %s", str_message, "BLUETOOTH_EVENT_HF_CALL_STARTED");
-               strcat (str_message, "");
-               break;
-
-       case BLUETOOTH_EVENT_HF_CALL_ENDED:
-               MMSoundMgrSessionSetHFPConnectionState(MM_SOUND_HFP_STATUS_UNKNOWN);
-               debug_msg("%s >> %s", str_message, "BLUETOOTH_EVENT_HF_CALL_ENDED");
-               break;
-
-       case BLUETOOTH_EVENT_HF_VOICE_RECOGNITION_ENABLED:
-               debug_msg("%s >> %s", str_message, "BLUETOOTH_EVENT_HF_VOICE_RECOGNITION_ENABLED");
-               /* BT connection signal before audio connected */
-               break;
-
-       case BLUETOOTH_EVENT_HF_VOICE_RECOGNITION_DISABLED:
-               debug_msg("%s >> %s", str_message, "BLUETOOTH_EVENT_HF_VOICE_RECOGNITION_DISABLED");
-               break;
-
-       case BLUETOOTH_EVENT_HF_VOLUME_SPEAKER:
-               vol_value = *(unsigned int *)(event_param->param_data);
-               debug_msg("%s >> %s : %d", str_message, "BLUETOOTH_EVENT_HF_VOLUME_SPEAKER", vol_value);
-               _bt_hf_set_volume_by_client(vol_value);
-               break;
-
-       default:
-               debug_log("%s >> %s", str_message, "Unhandled event...");
-               break;
-       }
-}
-
-static int __bt_hf_initialize(pulse_info_t* pinfo)
-{
-       int ret = 0;
-
-       debug_log ("__bt_hf_initialize start");
-       ret = bluetooth_hf_init(_bt_hf_cb, NULL);
-       if (ret != BLUETOOTH_ERROR_NONE) {
-               debug_error ("bluetooth_hf_init error!!! [%d]", ret);
-               goto FAIL;
-       }
-
-       MMSoundMgrSessionSetHFBandwidth(MM_SOUND_BANDWIDTH_UNKNOWN);
-
-       debug_msg ("__bt_hf_initialize success");
-       return ret;
-
-FAIL:
-       debug_error ("__bt_hf_initialize failed");
-       return ret;
-}
-
-static int __bt_hf_deinitialize(pulse_info_t* pinfo)
-{
-       int ret = 0;
-
-       debug_msg ("__bt_hf_deinitialize start");
-       ret = bluetooth_hf_deinit();
-       if (ret != BLUETOOTH_ERROR_NONE) {
-               debug_error ("bluetooth_hf_deinit error!!! [%d]", ret);
-               goto FAIL;
-       }
-
-       MMSoundMgrSessionSetHFBandwidth(MM_SOUND_BANDWIDTH_UNKNOWN);
-
-       debug_msg ("__bt_hf_deinitialize success");
-       return ret;
-FAIL:
-       debug_error ("__bt_hf_deinitialize failed");
-       return ret;
-}
-#endif /* TIZEN_MICRO */
-
-static void set_bt_status(pulse_info_t* pinfo, int bt_status)
-{
-       debug_warning ("BLUETOOTH state change detected(%s), hf_init(%d), ag_init(%d)\n",
-               bt_status > 0 ? "connected" : "disconnected",
-               pinfo->hf_init, pinfo->ag_init);
-
-       /* Init/Deinit BT AG */
-       if (bt_status) {
-#ifdef TIZEN_MICRO             
-               if (pinfo->hf_init == false) {
-                       if (!__bt_hf_initialize(pinfo)) {
-                               pinfo->hf_init = true;
-                       }
-               }
-#endif         
-               if (pinfo->ag_init == false) {
-                       if (!__bt_ag_initialize(pinfo)) {
-                               pinfo->ag_init = true;
-                       }
-               }
-       } else {
-#ifdef TIZEN_MICRO     
-               if (pinfo->hf_init == true) {
-                       if (!__bt_hf_deinitialize(pinfo)) {
-                               pinfo->hf_init = false;
-                       }
-               }
-#endif         
-               if (pinfo->ag_init == true) {
-                       if (!__bt_ag_deinitialize(pinfo)) {
-                               pinfo->ag_init = false;
-                       }
-               }
-       }
-#ifndef TIZEN_MICRO
-       pinfo->hf_init = false;
-#endif
-}
-
-static void bt_changed_cb(int result, bt_adapter_state_e bt_status, void *data)
-{
-       pulse_info_t* pinfo = (pulse_info_t*)data;
-
-       if (pinfo == NULL) {
-               debug_error ("pinfo is null");
-               return;
-       }
-
-       set_bt_status(pinfo, bt_status);
-}
-
-int MMSoundMgrPulseHandleRegisterBluetoothStatus (void* pinfo)
-{
-       int ret = 0;
-       bt_adapter_state_e bt_status = BT_ADAPTER_DISABLED;
-
-       if (pinfo == NULL) {
-               debug_error ("pinfo is null");
-               return MM_ERROR_INVALID_ARGUMENT;
-       }
-
-       ret = bt_initialize();
-       if (ret != BT_ERROR_NONE) {
-               debug_error("bt_initialize error [%d]", ret);
-       }
-
-       /* Get actual BT status */
-       ret = bt_adapter_get_state(&bt_status);
-       if (bt_status == BT_ADAPTER_ENABLED) {
-               set_bt_status((pulse_info_t*)pinfo, bt_status);
-               debug_msg ("Initial BT Status");
-       }
-
-       /* set callback for bt status change */
-       ret = bt_adapter_set_state_changed_cb(bt_changed_cb, pinfo);
-       debug_msg ("State set cb [%d]", ret);
-       return ret;
-}
-
-int MMSoundMgrPulseGetBluetoothInfo(bool* is_nrec, int* bandwidth)
-{
-       int ret = 0;
-       bool wb = 0;
-       bool nrec = false;
-
-       debug_msg ("Try to get AG SCO information.");
-
-       ret = bt_ag_is_nrec_enabled(&nrec);
-       if (ret != BT_ERROR_NONE) {
-               debug_error ("ERROR : bt_ag_is_nrec_enabled error!!! [%d]", ret);
-       }
-       /* FIXME : check with product api of bluetooth */
-       wb = 1;
-
-#ifdef TIZEN_MICRO
-       if(wb == 0) {
-               *bandwidth = MM_SOUND_BANDWIDTH_NB;
-       } else if(wb == 1) {
-               *bandwidth = MM_SOUND_BANDWIDTH_WB;
-       } else {
-               debug_error ("unknow band with. wb(%d), bt_bandwidth(%d)", wb, *bandwidth);
-       }
-#else
-       /* FIXME : Think over in case of not supportted hfp */
-       *bandwidth = 1;
-       *is_nrec = nrec;
-#endif /* TIZEN_MICRO */       
-
-       debug_msg ("Get AG SCO information. is_nrec=%d, bandwidth=%d", *is_nrec, *bandwidth);
-
-       return MM_ERROR_NONE;
-}
-
-#endif /* SUPPORT_BT_SCO_DETECT */
-
-/* -------------------------------- MGR MAIN --------------------------------------------*/
-int MMSoundMgrPulseHandleIsBtA2DPOnReq (bool* is_bt_on, char** bt_name)
-{
-       int ret = 0;
-       char* _bt_name;
-       bool _is_bt_on = false;
-
-       pthread_mutex_lock(&g_mutex);
-       _bt_name = MMSoundMgrSessionGetBtA2DPName();
-       if (_bt_name && strlen(_bt_name) > 0) {
-               _is_bt_on = true;
-       }
-
-       debug_log ("is_bt_on = [%d], name = [%s]\n", _is_bt_on, _bt_name);
-
-       *is_bt_on = _is_bt_on;
-       *bt_name = strdup(_bt_name);
-
-       pthread_mutex_unlock(&g_mutex);
-
-       debug_leave("\n");
-
-       return ret;
-}
-
-static void set_default_sink_cb(pa_context *c, int success, void *userdata)
-{
-       pulse_info_t *pinfo = (pulse_info_t *)userdata;
-       if (pinfo == NULL) {
-               debug_error ("pinfo is null");
-               return;
-       }
-
-       if (success) {
-               debug_msg("[PA_CB] m[%p] c[%p] set default sink success\n", pinfo->m, c);
-       } else {
-               debug_error("[PA_CB] m[%p] c[%p] set default sink fail:%s", pinfo->m, c, pa_strerror(pa_context_errno(c)));
-       }
-       pa_threaded_mainloop_signal(pinfo->m, 0);
-}
-
-static void set_default_sink_nosignal_cb(pa_context *c, int success, void *userdata)
-{
-       pulse_info_t *pinfo = (pulse_info_t *)userdata;
-       if (pinfo == NULL) {
-               debug_error ("pinfo is null");
-               return;
-       }
-
-       if (success) {
-               debug_msg("[PA_CB] m[%p] c[%p] set default sink success\n", pinfo->m, c);
-       } else {
-               debug_error("[PA_CB] m[%p] c[%p] set default sink fail:%s", pinfo->m, c, pa_strerror(pa_context_errno(c)));
-       }
-}
-
-static void set_cork_all_cb(pa_context *c, int success, void *userdata)
-{
-       pulse_info_t *pinfo = (pulse_info_t *)userdata;
-       if (pinfo == NULL) {
-               debug_error ("pinfo is null");
-               return;
-       }
-
-       if (success) {
-               debug_msg("[PA_CB] m[%p] c[%p] set cork all success\n", pinfo->m, c);
-       } else {
-               debug_error("[PA_CB] m[%p] c[%p] set cork all fail:%s", pinfo->m, c, pa_strerror(pa_context_errno(c)));
-       }
-       pa_threaded_mainloop_signal(pinfo->m, 0);
-}
-
-static void set_cork_all_nosignal_cb(pa_context *c, int success, void *userdata)
-{
-       pulse_info_t *pinfo = (pulse_info_t *)userdata;
-       if (pinfo == NULL) {
-               debug_error ("pinfo is null");
-               return;
-       }
-
-       if (success) {
-               debug_msg("[PA_CB] m[%p] c[%p] set cork all success\n", pinfo->m, c);
-       } else {
-               debug_error("[PA_CB] m[%p] c[%p] set cork all fail:%s", pinfo->m, c, pa_strerror(pa_context_errno(c)));
-       }
-}
-
-static void set_voicecontrol_state_cb(pa_context *c, int success, void *userdata)
-{
-       pulse_info_t *pinfo = (pulse_info_t *)userdata;
-       if (pinfo == NULL) {
-               debug_error ("pinfo is null");
-               return;
-       }
-
-       if (success) {
-               debug_msg("[PA_CB] m[%p] c[%p] set voicecontrol state success\n", pinfo->m, c);
-       } else {
-               debug_error("[PA_CB] m[%p] c[%p] set voicecontrol state fail:%s", pinfo->m, c, pa_strerror(pa_context_errno(c)));
-       }
-       pa_threaded_mainloop_signal(pinfo->m, 0);
-}
-
-static void set_voicecontrol_state_nosignal_cb(pa_context *c, int success, void *userdata)
-{
-       pulse_info_t *pinfo = (pulse_info_t *)userdata;
-       if (pinfo == NULL) {
-               debug_error ("pinfo is null");
-               return;
-       }
-
-       if (success) {
-               debug_msg("[PA_CB] m[%p] c[%p] set voicecontrol state success\n", pinfo->m, c);
-       } else {
-               debug_error("[PA_CB] m[%p] c[%p] set voicecontrol state fail:%s", pinfo->m, c, pa_strerror(pa_context_errno(c)));
-       }
-}
-
-void MMSoundMgrPulseSetUSBDefaultSink (int usb_device)
-{
-       pa_operation *o = NULL;
-
-       debug_enter("\n");
-
-       if (pa_threaded_mainloop_in_thread(pulse_info->m)) {
-               o = pa_context_set_default_sink_for_usb(pulse_info->context,
-                               (usb_device == MM_SOUND_DEVICE_OUT_USB_AUDIO)? pulse_info->usb_sink_name : pulse_info->dock_sink_name,
-                               set_default_sink_nosignal_cb, pulse_info);
-               pa_operation_unref(o);
-       } else {
-               pa_threaded_mainloop_lock(pulse_info->m);
-               CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail);
-
-               debug_msg("[PA] pa_context_set_default_sink m[%p] c[%p]", pulse_info->m, pulse_info->context);
-               o = pa_context_set_default_sink_for_usb(pulse_info->context,
-                               (usb_device == MM_SOUND_DEVICE_OUT_USB_AUDIO)? pulse_info->usb_sink_name : pulse_info->dock_sink_name,
-                               set_default_sink_cb, pulse_info);
-               CHECK_CONTEXT_SUCCESS_GOTO(pulse_info->context, o, unlock_and_fail);
-               while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) {
-                       pa_threaded_mainloop_wait(pulse_info->m);
-                       CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail);
-               }
-               pa_operation_unref(o);
-
-               pa_threaded_mainloop_unlock(pulse_info->m);
-       }
-
-       debug_leave("\n");
-       return;
-
-unlock_and_fail:
-       if (o) {
-               pa_operation_cancel(o);
-               pa_operation_unref(o);
-       }
-       pa_threaded_mainloop_unlock(pulse_info->m);
-
-       debug_leave("\n");
-}
-
-void MMSoundMgrPulseSetDefaultSink (char* device_api_name, char* device_bus_name)
-{
-       pa_operation *o = NULL;
-
-       debug_enter("\n");
-
-       if (device_api_name == NULL || device_bus_name == NULL) {
-               debug_error ("one of string is null\n");
-               return;
-       }
-
-       MMSOUND_STRNCPY(pulse_info->device_api_name, device_api_name, MAX_STRING);
-       MMSOUND_STRNCPY(pulse_info->device_bus_name, device_bus_name, MAX_STRING);
-
-       if (pa_threaded_mainloop_in_thread(pulse_info->m)) {
-               o = pa_context_set_default_sink_by_api_bus(pulse_info->context, pulse_info->device_api_name, pulse_info->device_bus_name, set_default_sink_nosignal_cb, pulse_info);
-               pa_operation_unref(o);
-       } else {
-               pa_threaded_mainloop_lock(pulse_info->m);
-               CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail);
-
-               debug_msg("[PA] pa_context_set_default_sink_by_api_bus m[%p] c[%p]", pulse_info->m, pulse_info->context);
-               o = pa_context_set_default_sink_by_api_bus(pulse_info->context, pulse_info->device_api_name, pulse_info->device_bus_name, set_default_sink_cb, pulse_info);
-               CHECK_CONTEXT_SUCCESS_GOTO(pulse_info->context, o, unlock_and_fail);
-               while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) {
-                       pa_threaded_mainloop_wait(pulse_info->m);
-                       CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail);
-               }
-               pa_operation_unref(o);
-
-               pa_threaded_mainloop_unlock(pulse_info->m);
-       }
-       debug_leave("\n");
-       return;
-
-unlock_and_fail:
-       if (o) {
-               pa_operation_cancel(o);
-               pa_operation_unref(o);
-       }
-       pa_threaded_mainloop_unlock(pulse_info->m);
-       debug_leave("\n");
-}
-
-
-void MMSoundMgrPulseSetDefaultSinkByName (char* name)
-{
-       pa_operation *o = NULL;
-
-       debug_enter("\n");
-
-       if (!name) {
-               debug_error ("Invalid param\n");
-               return;
-       }
-
-       if (pa_threaded_mainloop_in_thread(pulse_info->m)) {
-               o = pa_context_set_default_sink(pulse_info->context, name, set_default_sink_cb, pulse_info);
-               pa_operation_unref(o);
-       } else {
-               pa_threaded_mainloop_lock(pulse_info->m);
-               CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail);
-
-               debug_msg("[PA] MMSoundMgrPulseSetDefaultSinkByName m[%p] c[%p]", pulse_info->m, pulse_info->context);
-               o = pa_context_set_default_sink(pulse_info->context, name, set_default_sink_cb, pulse_info);
-               CHECK_CONTEXT_SUCCESS_GOTO(pulse_info->context, o, unlock_and_fail);
-               while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) {
-                       pa_threaded_mainloop_wait(pulse_info->m);
-                       CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail);
-               }
-               pa_operation_unref(o);
-
-               pa_threaded_mainloop_unlock(pulse_info->m);
-       }
-       debug_leave("\n");
-       return;
-
-unlock_and_fail:
-       if (o) {
-               pa_operation_cancel(o);
-               pa_operation_unref(o);
-       }
-       pa_threaded_mainloop_unlock(pulse_info->m);
-       debug_leave("\n");
-}
-
-void MMSoundMgrPulseSetCorkAll (bool cork)
-{
-       pa_operation *o = NULL;
-
-       debug_enter("\n");
-
-       if (pa_threaded_mainloop_in_thread(pulse_info->m)) {
-               o = pa_context_set_cork_all(pulse_info->context, cork, set_cork_all_nosignal_cb, pulse_info);
-               pa_operation_unref(o);
-       } else {
-               pa_threaded_mainloop_lock(pulse_info->m);
-               CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail);
-
-               debug_msg("[PA] MMSoundMgrPulseSetCorkAll m[%p] c[%p]", pulse_info->m, pulse_info->context);
-               o = pa_context_set_cork_all(pulse_info->context, cork, set_cork_all_cb, pulse_info);
-               CHECK_CONTEXT_SUCCESS_GOTO(pulse_info->context, o, unlock_and_fail);
-               while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) {
-                       pa_threaded_mainloop_wait(pulse_info->m);
-                       CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail);
-               }
-               pa_operation_unref(o);
-
-               pa_threaded_mainloop_unlock(pulse_info->m);
-       }
-       debug_leave("\n");
-       return;
-
-unlock_and_fail:
-       if (o) {
-               pa_operation_cancel(o);
-               pa_operation_unref(o);
-       }
-       pa_threaded_mainloop_unlock(pulse_info->m);
-       debug_leave("\n");
-}
-
-void MMSoundMgrPulseSetVoicecontrolState (bool state)
-{
-       pa_operation *o = NULL;
-
-       debug_enter("\n");
-
-       if (pa_threaded_mainloop_in_thread(pulse_info->m)) {
-               //o = pa_ext_policy_set_voicecontrol_state(pulse_info->context, (uint32_t)state, set_voicecontrol_state_nosignal_cb, pulse_info);
-               pa_operation_unref(o);
-       } else {
-               pa_threaded_mainloop_lock(pulse_info->m);
-               CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail);
-
-               debug_msg("[PA] MMSoundMgrPulseSetCorkAll m[%p] c[%p]", pulse_info->m, pulse_info->context);
-               //o = pa_ext_policy_set_voicecontrol_state(pulse_info->context, (uint32_t)state, set_voicecontrol_state_cb, pulse_info);
-               CHECK_CONTEXT_SUCCESS_GOTO(pulse_info->context, o, unlock_and_fail);
-               while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) {
-                       pa_threaded_mainloop_wait(pulse_info->m);
-                       CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail);
-               }
-               pa_operation_unref(o);
-
-               pa_threaded_mainloop_unlock(pulse_info->m);
-       }
-       debug_leave("\n");
-       return;
-
-unlock_and_fail:
-       if (o) {
-               pa_operation_cancel(o);
-               pa_operation_unref(o);
-       }
-       pa_threaded_mainloop_unlock(pulse_info->m);
-       debug_leave("\n");
-}
-
-void MMSoundMgrPulseUnLoadHDMI()
-{
-       pa_operation *o = NULL;
-       if (pulse_info == NULL) {
-               debug_error ("Pulse module in sound server not loaded");
-               return;
-       }
-
-       pa_threaded_mainloop_lock(pulse_info->m);
-       CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail);
-
-       debug_msg("[PA] pa_context_unload_hdmi m[%p] c[%p]", pulse_info->m, pulse_info->context);
-       o = pa_ext_policy_unload_hdmi(pulse_info->context, unload_hdmi_cb, pulse_info);
-       CHECK_CONTEXT_SUCCESS_GOTO(pulse_info->context, o, unlock_and_fail);
-       while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) {
-               pa_threaded_mainloop_wait(pulse_info->m);
-               CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail);
-       }
-       pa_operation_unref(o);
-
-       pa_threaded_mainloop_unlock(pulse_info->m);
-       return;
-
-unlock_and_fail:
-       if (o) {
-               pa_operation_cancel(o);
-               pa_operation_unref(o);
-       }
-       pa_threaded_mainloop_unlock(pulse_info->m);
-}
-
-#if 0
-static void set_source_mute_by_name_cb (pa_context *c, int success, void *userdata)
-{
-       pulse_info_t *pinfo = (pulse_info_t *)userdata;
-       if (pinfo == NULL) {
-               debug_error ("pinfo is null");
-               return;
-       }
-
-       if (success) {
-               debug_msg("[PA_CB] m[%p] c[%p] set source mute by name success\n", pinfo->m, c);
-       } else {
-               debug_error("[PA_CB] m[%p] c[%p] set source mute by name fail:%s", pinfo->m, c, pa_strerror(pa_context_errno(c)));
-       }
-       pa_threaded_mainloop_signal(pinfo->m, 0);
-}
-
-static void set_source_mute_by_name_nosignal_cb (pa_context *c, int success, void *userdata)
-{
-       pulse_info_t *pinfo = (pulse_info_t *)userdata;
-       if (pinfo == NULL) {
-               debug_error ("pinfo is null");
-               return;
-       }
-
-       if (success) {
-               debug_msg("[PA_CB] m[%p] c[%p] set source mute by name success\n", pinfo->m, c);
-       } else {
-               debug_error("[PA_CB] m[%p] c[%p] set source mute by name fail:%s", pinfo->m, c, pa_strerror(pa_context_errno(c)));
-       }
-}
-#endif
-
-void MMSoundMgrPulseSetSourcemutebyname (char* sourcename, int mute)
-{
-#if 0
-       pa_operation *o = NULL;
-
-       debug_enter("\n");
-
-       if (sourcename == NULL) {
-               debug_error ("Invalid arguments!!!\n");
-               return;
-       }
-
-       if (pa_threaded_mainloop_in_thread(pulse_info->m)) {
-               o = pa_context_set_source_mute_by_name(pulse_info->context, sourcename, mute, set_source_mute_by_name_nosignal_cb, pulse_info);
-               pa_operation_unref(o);
-       } else {
-               pa_threaded_mainloop_lock(pulse_info->m);
-               CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail);
-
-               debug_msg("[PA] pa_context_set_source_mute_by_name m[%p] c[%p] name:%s mute:%d", pulse_info->m, pulse_info->context, sourcename, mute);
-               o = pa_context_set_source_mute_by_name (pulse_info->context, sourcename, mute, set_source_mute_by_name_cb, pulse_info);
-               CHECK_CONTEXT_SUCCESS_GOTO(pulse_info->context, o, unlock_and_fail);
-               while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) {
-                       pa_threaded_mainloop_wait(pulse_info->m);
-                       CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail);
-               }
-               pa_operation_unref(o);
-
-               pa_threaded_mainloop_unlock(pulse_info->m);
-       }
-       debug_leave("\n");
-       return;
-
-unlock_and_fail:
-       if (o) {
-               pa_operation_cancel(o);
-               pa_operation_unref(o);
-       }
-       pa_threaded_mainloop_unlock(pulse_info->m);
-
-       debug_leave("\n");
-#endif
-}
-
-void MMSoundMgrPulseGetInitialBTStatus (bool *a2dp, bool *sco)
-{
-       int bt_status = VCONFKEY_BT_DEVICE_NONE;
-
-       if (a2dp == NULL || sco == NULL) {
-               debug_error ("Invalid arguments!!!\n");
-               return;
-       }
-
-       /* Get saved bt status */
-       *a2dp = pulse_info->init_bt_status;
-
-       /* Get actual vconf value */
-       vconf_get_int(VCONFKEY_BT_DEVICE, &bt_status);
-       debug_msg ("key value = 0x%x\n", bt_status);
-       *sco = (bt_status & VCONFKEY_BT_DEVICE_HEADSET_CONNECTED)? true : false;
-
-       debug_msg ("returning a2dp=[%d], sco=[%d]\n", *a2dp, *sco);
-}
-
-static void set_session_cb(pa_context *c, int success, void *userdata)
-{
-       pulse_info_t *pinfo = (pulse_info_t *)userdata;
-       if (pinfo == NULL) {
-               debug_error ("pinfo is null");
-               return;
-       }
-
-       if (success) {
-               debug_msg ("[PA_CB] m[%p] c[%p] set session success", pinfo->m, c);
-       } else {
-               debug_error("[PA_CB] m[%p] c[%p] set session fail:%s", pinfo->m, c, pa_strerror(pa_context_errno(c)));
-       }
-
-       pa_threaded_mainloop_signal(pinfo->m, 0);
-}
-
-static void set_session_nosignal_cb(pa_context *c, int success, void *userdata)
-{
-       pulse_info_t *pinfo = (pulse_info_t *)userdata;
-       if (pinfo == NULL) {
-               debug_error ("pinfo is null");
-               return;
-       }
-
-       if (success) {
-               debug_msg ("[PA_CB] m[%p] c[%p] set session success", pinfo->m, c);
-       } else {
-               debug_error("[PA_CB] m[%p] c[%p] set session fail:%s", pinfo->m, c, pa_strerror(pa_context_errno(c)));
-       }
-}
-
-void MMSoundMgrPulseSetSession(session_t session, session_state_t state)
-{
-       pa_operation *o = NULL;
-       uint32_t session_pa = 0;
-
-       /* convert subsession enum for PA */
-       switch (session) {
-       case SESSION_MEDIA:                                     session_pa = PA_TIZEN_SESSION_MEDIA;                    break;
-       case SESSION_VOICECALL:                         session_pa = PA_TIZEN_SESSION_VOICECALL;                break;
-       case SESSION_VIDEOCALL:                         session_pa = PA_TIZEN_SESSION_VIDEOCALL;                break;
-       case SESSION_VOIP:                                      session_pa = PA_TIZEN_SESSION_VOIP;                             break;
-       case SESSION_FMRADIO:                           session_pa = PA_TIZEN_SESSION_FMRADIO;                  break;
-       case SESSION_NOTIFICATION:                      session_pa = PA_TIZEN_SESSION_NOTIFICATION;             break;
-       case SESSION_ALARM:                                     session_pa = PA_TIZEN_SESSION_ALARM;                    break;
-       case SESSION_EMERGENCY:                         session_pa = PA_TIZEN_SESSION_EMERGENCY;                break;
-       case SESSION_VOICE_RECOGNITION:         session_pa = PA_TIZEN_SESSION_VOICE_RECOGNITION;break;
-       default:
-               debug_error("inavlid session:%d", session);
-               return;
-       }
-
-       if (pa_threaded_mainloop_in_thread(pulse_info->m)) {
-               o = pa_ext_policy_set_session(pulse_info->context, session_pa, state, set_session_nosignal_cb, pulse_info);
-               pa_operation_unref(o);
-       } else {
-               pa_threaded_mainloop_lock(pulse_info->m);
-               CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail);
-
-               debug_msg("[PA] pa_ext_policy_set_session m[%p] c[%p] session:%d state:%d", pulse_info->m, pulse_info->context, session_pa, state);
-               o = pa_ext_policy_set_session(pulse_info->context, session_pa, state, set_session_cb, pulse_info);
-               CHECK_CONTEXT_SUCCESS_GOTO(pulse_info->context, o, unlock_and_fail);
-               while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) {
-                       pa_threaded_mainloop_wait(pulse_info->m);
-                       CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail);
-               }
-               pa_operation_unref(o);
-               pa_threaded_mainloop_unlock(pulse_info->m);
-       }
-       return;
-
-unlock_and_fail:
-       if (o) {
-               pa_operation_cancel(o);
-               pa_operation_unref(o);
-       }
-       pa_threaded_mainloop_unlock(pulse_info->m);
-}
-
-static void set_subsession_cb(pa_context *c, int success, void *userdata)
-{
-       pulse_info_t *pinfo = (pulse_info_t *)userdata;
-       if (pinfo == NULL) {
-               debug_error ("pinfo is null");
-               return;
-       }
-
-       if (success) {
-               debug_msg ("[PA_CB] m[%p] c[%p] set subsession success", pinfo->m, c);
-       } else {
-               debug_error("[PA_CB] m[%p] c[%p] set subsession fail:%s", pinfo->m, c, pa_strerror(pa_context_errno(c)));
-       }
-
-       pa_threaded_mainloop_signal(pinfo->m, 0);
-}
-
-static void set_subsession_nosignal_cb(pa_context *c, int success, void *userdata)
-{
-       pulse_info_t *pinfo = (pulse_info_t *)userdata;
-       if (pinfo == NULL) {
-               debug_error ("pinfo is null");
-               return;
-       }
-
-       if (success) {
-               debug_msg ("[PA_CB] m[%p] c[%p] set subsession success", pinfo->m, c);
-       } else {
-               debug_error("[PA_CB] m[%p] c[%p] set subsession fail:%s", pinfo->m, c, pa_strerror(pa_context_errno(c)));
-       }
-}
-
-void MMSoundMgrPulseSetSubsession(subsession_t subsession, int subsession_opt)
-{
-       pa_operation *o = NULL;
-       uint32_t subsession_pa = 0, subsession_opt_pa = 0;
-
-       /* convert subsession enum for PA */
-       switch (subsession) {
-       case SUBSESSION_VOICE:                          subsession_pa = PA_TIZEN_SUBSESSION_VOICE;              break;
-       case SUBSESSION_RINGTONE:                       subsession_pa = PA_TIZEN_SUBSESSION_RINGTONE;   break;
-       case SUBSESSION_MEDIA:                          subsession_pa = PA_TIZEN_SUBSESSION_MEDIA;              break;
-       case SUBSESSION_INIT:                           subsession_pa = PA_TIZEN_SUBSESSION_VR_INIT;    break;
-       case SUBSESSION_VR_NORMAL:                      subsession_pa = PA_TIZEN_SUBSESSION_VR_NORMAL;  break;
-       case SUBSESSION_VR_DRIVE:                       subsession_pa = PA_TIZEN_SUBSESSION_VR_DRIVE;   break;
-#ifndef _TIZEN_PUBLIC_
-       case SUBSESSION_RECORD_MONO:
-       case SUBSESSION_RECORD_STEREO:
-#endif
-       default:
-               debug_error("inavlid subsession:%d", subsession);
-               return;
-       }
-
-       if (pa_threaded_mainloop_in_thread(pulse_info->m)) {
-               o = pa_ext_policy_set_subsession(pulse_info->context, subsession_pa, subsession_opt_pa, set_subsession_nosignal_cb, pulse_info);
-               pa_operation_unref(o);
-       } else {
-               pa_threaded_mainloop_lock(pulse_info->m);
-               CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail);
-
-               debug_msg("[PA] pa_ext_policy_set_session m[%p] c[%p] subsession:%d opt:%x", pulse_info->m, pulse_info->context, subsession_pa, subsession_opt);
-               o = pa_ext_policy_set_subsession(pulse_info->context, subsession_pa, subsession_opt_pa, set_subsession_cb, pulse_info);
-               CHECK_CONTEXT_SUCCESS_GOTO(pulse_info->context, o, unlock_and_fail);
-               while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) {
-                       pa_threaded_mainloop_wait(pulse_info->m);
-                       CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail);
-               }
-               pa_operation_unref(o);
-               pa_threaded_mainloop_unlock(pulse_info->m);
-       }
-       return;
-
-unlock_and_fail:
-       if (o) {
-               pa_operation_cancel(o);
-               pa_operation_unref(o);
-       }
-       pa_threaded_mainloop_unlock(pulse_info->m);
-}
-
-static void set_active_device_cb(pa_context *c, int success, int need_update, void *userdata)
-{
-       pulse_info_t *pinfo = (pulse_info_t *)userdata;
-       if (pinfo == NULL) {
-               debug_error ("pinfo is null");
-               return;
-       }
-
-       if (success) {
-               debug_msg ("[PA_CB] c[%p] set active device success. need_update(%d)", c, need_update);
-       } else {
-               debug_error("[PA_CB] c[%p] set active device fail:%s", c, pa_strerror(pa_context_errno(c)));
-       }
-
-       pa_threaded_mainloop_signal(pinfo->m, 0);
-}
-
-static void set_active_device_nosignal_cb(pa_context *c, int success, int need_update, void *userdata)
-{
-       pulse_info_t *pinfo = (pulse_info_t *)userdata;
-       if (pinfo == NULL) {
-               debug_error ("pinfo is null");
-               return;
-       }
-
-       if (success) {
-               debug_msg ("[PA_CB] c[%p] set active device success. need_update(%d)", c, need_update);
-       } else {
-               debug_error("[PA_CB] c[%p] set active device fail:%s", c, pa_strerror(pa_context_errno(c)));
-       }
-}
-
-void MMSoundMgrPulseGetPathInfo(mm_sound_device_out *device_out, mm_sound_device_in *device_in)
-{
-       if(device_in == NULL || device_out == NULL) {
-               debug_error("inavlid device_in or device_out is null");
-               return;
-       }
-       *device_in = g_path_info.device_in;
-       *device_out = g_path_info.device_out;
-}
-
-void MMSoundMgrPulseSetActiveDevice(mm_sound_device_in device_in, mm_sound_device_out device_out)
-{
-       pa_operation *o = NULL;
-       uint32_t device_in_pa = 0, device_out_pa = 0;
-
-       /* convert device_in enum for PA */
-       switch (device_in) {
-       case MM_SOUND_DEVICE_IN_NONE:                           device_in_pa = PA_TIZEN_DEVICE_IN_NONE;                                 break;
-       case MM_SOUND_DEVICE_IN_MIC:                            device_in_pa = PA_TIZEN_DEVICE_IN_MIC;                                  break;
-       case MM_SOUND_DEVICE_IN_WIRED_ACCESSORY:        device_in_pa = PA_TIZEN_DEVICE_IN_WIRED_ACCESSORY;              break;
-       case MM_SOUND_DEVICE_IN_BT_SCO:                         device_in_pa = PA_TIZEN_DEVICE_IN_BT_SCO;                               break;
-       default:
-               debug_error("inavlid device_in:%x", device_in);
-               return;
-       }
-
-       /* convert device_out enum for PA */
-       switch (device_out) {
-       case MM_SOUND_DEVICE_OUT_NONE:                          device_out_pa = PA_TIZEN_DEVICE_OUT_NONE;                               break;
-       case MM_SOUND_DEVICE_OUT_SPEAKER:                       device_out_pa = PA_TIZEN_DEVICE_OUT_SPEAKER;                    break;
-       case MM_SOUND_DEVICE_OUT_RECEIVER:                      device_out_pa = PA_TIZEN_DEVICE_OUT_RECEIVER;                   break;
-       case MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY:       device_out_pa = PA_TIZEN_DEVICE_OUT_WIRED_ACCESSORY;    break;
-       case MM_SOUND_DEVICE_OUT_BT_SCO:                        device_out_pa = PA_TIZEN_DEVICE_OUT_BT_SCO;                             break;
-       case MM_SOUND_DEVICE_OUT_BT_A2DP:                       device_out_pa = PA_TIZEN_DEVICE_OUT_BT_A2DP;                    break;
-       case MM_SOUND_DEVICE_OUT_DOCK:                          device_out_pa = PA_TIZEN_DEVICE_OUT_DOCK;                               break;
-       case MM_SOUND_DEVICE_OUT_HDMI:                          device_out_pa = PA_TIZEN_DEVICE_OUT_HDMI;                               break;
-       case MM_SOUND_DEVICE_OUT_MIRRORING:                     device_out_pa = PA_TIZEN_DEVICE_OUT_MIRRORING;                  break;
-       case MM_SOUND_DEVICE_OUT_USB_AUDIO:                     device_out_pa = PA_TIZEN_DEVICE_OUT_USB_AUDIO;                  break;
-       case MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK:       device_out_pa = PA_TIZEN_DEVICE_OUT_MULTIMEDIA_DOCK;    break;
-       default:
-               debug_error("inavlid device_out:%x", device_out);
-               return;
-       }
-
-       if (pa_threaded_mainloop_in_thread(pulse_info->m)) {
-               debug_msg("[PA] pa_ext_policy_set_active_device device_in:%d device_out:%d", device_in_pa, device_out_pa);
-               o = pa_ext_policy_set_active_device(pulse_info->context, device_in_pa, device_out_pa, set_active_device_nosignal_cb, pulse_info);
-               pa_operation_unref(o);
-       } else {
-               pa_threaded_mainloop_lock(pulse_info->m);
-               CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail);
-
-               debug_msg("[PA] pa_ext_policy_set_active_device m[%p] c[%p] device_in:%d device_out:%d", pulse_info->m, pulse_info->context, device_in_pa, device_out_pa);
-               o = pa_ext_policy_set_active_device(pulse_info->context, device_in_pa, device_out_pa, set_active_device_cb, pulse_info);
-               CHECK_CONTEXT_SUCCESS_GOTO(pulse_info->context, o, unlock_and_fail);
-               while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) {
-                       pa_threaded_mainloop_wait(pulse_info->m);
-                       CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail);
-               }
-               pa_operation_unref(o);
-               pa_threaded_mainloop_unlock(pulse_info->m);
-       }
-       g_path_info.device_in = device_in;
-       g_path_info.device_out = device_out;
-       debug_msg("device_in:%x  device_out:%x",device_in, device_out);
-       return;
-
-unlock_and_fail:
-       if (o) {
-               pa_operation_cancel(o);
-               pa_operation_unref(o);
-       }
-       pa_threaded_mainloop_unlock(pulse_info->m);
-}
-
-#ifdef TIZEN_MICRO
-
-static void set_volume_level_cb(pa_context *c, int success, void *userdata)
-{
-       pulse_info_t *pinfo = (pulse_info_t *)userdata;
-       if (pinfo == NULL) {
-               debug_error ("pinfo is null");
-               return;
-       }
-
-       if (success) {
-               debug_msg ("[PA_CB] m[%p] c[%p] set volume level success", pinfo->m, c);
-       } else {
-               debug_error("[PA_CB] m[%p] c[%p] set volume level fail:%s", pinfo->m, c, pa_strerror(pa_context_errno(c)));
-       }
-
-       pa_threaded_mainloop_signal(pinfo->m, 0);
-}
-
-static void set_volume_level_nosignal_cb(pa_context *c, int success, void *userdata)
-{
-       pulse_info_t *pinfo = (pulse_info_t *)userdata;
-       if (pinfo == NULL) {
-               debug_error ("pinfo is null");
-               return;
-       }
-
-       if (success) {
-               debug_msg ("[PA_CB] m[%p] c[%p] set volume level success", pinfo->m, c);
-       } else {
-               debug_error("[PA_CB] m[%p] c[%p] set volume level fail:%s", pinfo->m, c, pa_strerror(pa_context_errno(c)));
-       }
-}
-
-void MMSoundMgrPulseSetVolumeLevel(volume_type_t volume_type, unsigned int volume_level)
-{
-       pa_operation *o = NULL;
-
-       if (pa_threaded_mainloop_in_thread(pulse_info->m)) {
-               o = pa_ext_policy_set_volume_level(pulse_info->context, -1, volume_type, volume_level, set_volume_level_nosignal_cb, pulse_info);
-               pa_operation_unref(o);
-       } else {
-               pa_threaded_mainloop_lock(pulse_info->m);
-               CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail);
-
-               debug_msg("[PA] pa_ext_policy_set_volume_level volume_level(%d)", volume_level);
-               o = pa_ext_policy_set_volume_level(pulse_info->context, -1, volume_type, volume_level, set_volume_level_cb, pulse_info);
-               CHECK_CONTEXT_SUCCESS_GOTO(pulse_info->context, o, unlock_and_fail);
-               while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) {
-                       pa_threaded_mainloop_wait(pulse_info->m);
-                       CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, unlock_and_fail);
-               }
-               pa_operation_unref(o);
-               pa_threaded_mainloop_unlock(pulse_info->m);
-       }
-       return;
-
-unlock_and_fail:
-       if (o) {
-               pa_operation_cancel(o);
-               pa_operation_unref(o);
-       }
-       pa_threaded_mainloop_unlock(pulse_info->m);
-}
-
-#endif /* TIZEN_MICRO */
-
-
-static void set_update_volume_cb(pa_context *c, int success, void *userdata)
-{
-       pulse_info_t *pinfo = (pulse_info_t *)userdata;
-       if (pinfo == NULL) {
-               debug_error ("pinfo is null");
-               return;
-       }
-
-       if (success) {
-               debug_msg ("[PA_CB] m[%p] c[%p] update volume success", pinfo->m, c);
-       } else {
-               debug_error("[PA_CB] m[%p] c[%p] update volume fail:%s", pinfo->m, c, pa_strerror(pa_context_errno(c)));
-       }
-
-       pa_threaded_mainloop_signal(pinfo->m, 0);
-}
-
-static void set_update_volume_nosignal_cb(pa_context *c, int success, void *userdata)
-{
-       pulse_info_t *pinfo = (pulse_info_t *)userdata;
-       if (pinfo == NULL) {
-               debug_error ("pinfo is null");
-               return;
-       }
-
-       if (success) {
-               debug_msg ("[PA_CB] m[%p] c[%p] update volume success", pinfo->m, c);
-       } else {
-               debug_error("[PA_CB] m[%p] c[%p] update volume fail:%s", pinfo->m, c, pa_strerror(pa_context_errno(c)));
-       }
-}
-
-void* MMSoundMgrPulseInit(pa_disconnect_cb cb, void* user_data)
-{
-       pulse_info = (pulse_info_t*) malloc (sizeof(pulse_info_t));
-       memset (pulse_info, 0, sizeof(pulse_info_t));
-
-       debug_enter("\n");
-
-       pulse_init(pulse_info);
-       pulse_client_thread_init(pulse_info);
-
-       pulse_info->device_in_out = PA_INVALID_INDEX;
-       pulse_info->aec_module_idx = PA_INVALID_INDEX;
-       pulse_info->bt_idx = PA_INVALID_INDEX;
-       pulse_info->usb_idx = PA_INVALID_INDEX;
-       pulse_info->dock_idx = PA_INVALID_INDEX;
-       pulse_info->device_type = PA_INVALID_INDEX;
-
-       pulse_info->disconnect_cb = cb;
-       pulse_info->user_data = user_data;
-
-#ifdef SUPPORT_BT_SCO
-       MMSoundMgrPulseHandleRegisterBluetoothStatus(pulse_info);
-#endif
-
-       debug_leave("\n");
-       return pulse_info;
-}
-
-int MMSoundMgrPulseFini(void* handle)
-{
-       pulse_info_t *pinfo = (pulse_info_t *)handle;
-
-       debug_enter("\n");
-
-       if (handle == NULL) {
-               debug_warning ("handle is NULL....");
-               return MM_ERROR_INVALID_ARGUMENT;
-       }
-
-       pulse_deinit(pinfo);
-#ifdef SUPPORT_BT_SCO
-       bt_deinitialize();
-#endif
-
-       g_async_queue_push(pinfo->queue, (gpointer)PA_CLIENT_DESTROY);
-
-       pthread_join(pinfo->thread, 0);
-       g_async_queue_unref(pinfo->queue);
-
-       debug_leave("\n");
-       return MM_ERROR_NONE;
-}
-#endif
-
diff --git a/server/mm_sound_mgr_session.c b/server/mm_sound_mgr_session.c
deleted file mode 100644 (file)
index de783fb..0000000
+++ /dev/null
@@ -1,2863 +0,0 @@
-/*
- * libmm-sound
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Seungbae Shin <seungbae.shin@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#if 0
-#include <stdlib.h>
-#include <string.h>
-#include <pthread.h>
-#include <sys/shm.h>
-#include <sys/msg.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdbool.h>
-#include <errno.h>
-#ifdef TIZEN_MICRO
-#include <gio/gio.h>
-#endif
-#include <vconf.h>
-#include <mm_error.h>
-#include <mm_debug.h>
-#include <audio-session-manager.h>
-
-#include "../include/mm_sound_common.h"
-#include "../include/mm_sound_utils.h"
-#include "../include/mm_sound_device.h"
-#include "include/mm_sound_mgr_common.h"
-#include "include/mm_sound_mgr_session.h"
-#include "include/mm_sound_mgr_device.h"
-#include "include/mm_sound_mgr_device_headset.h"
-#include "include/mm_sound_mgr_device_dock.h"
-#include "include/mm_sound_mgr_pulse.h"
-#include "include/mm_sound_mgr_asm.h"
-
-#define EARJACK_UNPLUGGED      0
-#define EARJACK_WITH_MIC       3
-
-#define MAX_STRING_LEN 256
-
-#define DEVICE_API_BLUETOOTH   "bluez"
-#define DEVICE_API_ALSA        "alsa"
-#define DEVICE_BUS_BLUETOOTH "bluetooth"
-#define DEVICE_BUS_USB "usb"
-#define DEVICE_BUS_BUILTIN "builtin"
-
-#define MIRRORING_MONITOR_SOURCE       "alsa_output.0.analog-stereo.monitor"
-#define ALSA_SINK_HDMI "alsa_output.1.analog-stereo"
-
-#ifdef TIZEN_MICRO
-/* Call pause resume scenario with D-bus */
-/* Call application send dbus dbus signal */
-#define DBUS_CALL_STATUS_PATH          "/Org/Tizen/Call/Status"
-#define DBUS_CALL_STATUS_INTERFACE   "org.tizen.call.status"
-#define DBUS_CALL_STATUS_CHANGED_SIGNAL        "call_status"
-#endif
-
-#define        MM_SOUND_DEVICE_OUT_ANY 0x000FFF00
-#define MM_SOUND_DEVICE_IN_ANY  0x000000FF
-
-#define        MM_SOUND_DEVICE_OUT_FILTER 0x000000FF
-#define MM_SOUND_DEVICE_IN_FILTER       0x000FFF00
-
-#define MAX_BURST_CHECK_RETRY 10
-#define BURST_CHECK_INTERVAL 300000
-
-#define STR_LEN 128
-
-pthread_mutex_t g_mutex_session = PTHREAD_MUTEX_INITIALIZER;
-
-#define LOCK_SESSION()  /* do { debug_log("(*)LOCKING\n"); pthread_mutex_lock(&g_mutex_session); debug_log("(+)LOCKED\n"); }while(0) */
-#define UNLOCK_SESSION()  /* do { pthread_mutex_unlock(&g_mutex_session); debug_log("(-)UNLOCKED\n"); }while(0) */
-
-pthread_mutex_t g_mutex_path = PTHREAD_MUTEX_INITIALIZER;
-
-#define LOCK_PATH()  do { debug_log("(*)LOCKING\n"); pthread_mutex_lock(&g_mutex_path); debug_log("(+)LOCKED\n"); }while(0)
-#define UNLOCK_PATH()  do {  pthread_mutex_unlock(&g_mutex_path); debug_log("(-)UNLOCKED\n"); }while(0)
-
-#define RESET_ACTIVE(x)    (g_info.device_active &= x)
-#define RESET_AVAILABLE(x)    (g_info.device_available &= x)
-
-#define SET_ACTIVE(x)    (g_info.device_active |= x)
-#define SET_AVAILABLE(x)    (g_info.device_available |= x)
-
-#define SET_PLAYBACK_ONLY_ACTIVE(x)  do { RESET_ACTIVE(MM_SOUND_DEVICE_OUT_FILTER); SET_ACTIVE(x); }while(0)
-#define SET_CAPTURE_ONLY_ACTIVE(x)  do {  RESET_ACTIVE(MM_SOUND_DEVICE_IN_FILTER); SET_ACTIVE(x); }while(0)
-
-
-#define UNSET_ACTIVE(x)    (g_info.device_active &= (~x))
-#define UNSET_AVAILABLE(x)    (g_info.device_available &= (~x))
-
-#define TOGGLE_ACTIVE(x)    (g_info.device_active ^= x)
-#define TOGGLE_AVAILABLE(x)    (g_info.device_available ^= x)
-
-#define IS_ACTIVE(x)    (g_info.device_active & x)
-#define IS_AVAILABLE(x)    (g_info.device_available & x)
-
-#define GET_AVAILABLE_PLAYBACK()       IS_AVAILABLE(MM_SOUND_DEVICE_OUT_ANY)
-#define GET_AVAILABLE_CAPTURE()        IS_AVAILABLE(MM_SOUND_DEVICE_IN_ANY)
-
-#define GET_ACTIVE_PLAYBACK()  IS_ACTIVE(MM_SOUND_DEVICE_OUT_ANY)
-#define GET_ACTIVE_CAPTURE()   IS_ACTIVE(MM_SOUND_DEVICE_IN_ANY)
-
-#define IS_CALL_SESSION() ((g_info.session == SESSION_VOICECALL) || (g_info.session == SESSION_VIDEOCALL) || (g_info.session == SESSION_VOIP))
-#define IS_ALARM_SESSION() (g_info.session == SESSION_ALARM)
-#define IS_NOTIFICATION_SESSION() (g_info.session == SESSION_NOTIFICATION)
-#define IS_EMERGENCY_SESSION() (g_info.session == SESSION_EMERGENCY)
-#define IS_MEDIA_SESSION() (g_info.session == SESSION_MEDIA)
-
-
-typedef enum {
-    ROUTE_PARAM_NONE = 0x00000000,
-    ROUTE_PARAM_BROADCASTING = 0x00000001,
-    ROUTE_PARAM_CORK_DEVICE = 0x00000010,
-} mm_sound_route_param_t;
-
-#ifdef TIZEN_MICRO
-enum {
-       MM_SOUND_CALL_STATUS_RESUME = 0,
-       MM_SOUND_CALL_STATUS_PAUSE = 1,
-};
-#endif
-
-static int __set_route(bool need_broadcast, bool need_cork);
-static int __set_sound_path_for_current_active (bool need_broadcast, bool need_cork);
-static int __set_sound_path_to_dual ();
-static int __set_sound_path_to_earphone_only (void);
-static int __set_sound_path_to_speaker ();
-static int __set_sound_path_for_voicecontrol (void);
-static void __select_playback_active_device (void);
-static void __select_capture_active_device (void);
-
-static const char* __get_session_string(session_t session);
-static const char* __get_subsession_string(subsession_t session);
-#ifndef _TIZEN_PUBLIC_
-#ifndef TIZEN_MICRO
-static bool __is_noise_reduction_on (void);
-static bool __is_extra_volume_on (void);
-#endif
-static bool __is_upscaling_needed (void);
-static bool __is_right_hand_on (void);
-static bool __get_bt_nrec_status (void);
-static int __get_ag_wb_status(void);
-static int __get_hf_wb_status(void);
-static int __get_hf_connection_state(void);
-static const char* __get_bt_bandwidth_string(int bandwidth);
-#endif
-
-#define ENABLE_CALLBACK
-#ifndef ENABLE_CALLBACK
-#define _mm_sound_mgr_device_available_device_callback(a,b,c)  MM_ERROR_NONE
-#define _mm_sound_mgr_device_active_device_callback(a,b)       MM_ERROR_NONE
-#endif
-
-typedef struct _bt_info_struct
-{
-#ifdef TIZEN_MICRO
-       int ag_wb;
-       int hf_wb;
-       int hfp_conn_state;
-#endif
-       bool is_nrec;
-       bool is_wb;
-       char name[MAX_STRING_LEN];
-} BT_INFO_STRUCT;
-
-typedef struct _session_info_struct
-{
-       int asm_handle;
-       int device_available;
-       int device_active;
-       int headset_type;
-       bool is_noise_reduction;
-       bool is_extra_volume;
-       bool is_upscaling_needed;
-       bool is_voicecontrol;
-
-       session_t session;
-       subsession_t subsession;
-       mm_subsession_option_t option;
-
-       device_type_t previous_playback_device;
-       device_type_t previous_capture_device;
-       int previous_device_available;
-
-       BT_INFO_STRUCT bt_info;
-       char default_sink_name[MAX_STRING_LEN];
-
-} SESSION_INFO_STRUCT;
-
-
-SESSION_INFO_STRUCT g_info;
-#ifdef TIZEN_MICRO
-GDBusConnection *conn_callstatus;
-guint sig_id_callstatus;
-#endif
-
-static void dump_info ()
-{
-       int i = 0;
-
-       const char *playback_device_str[] = { "SPEAKER ", "RECEIVER ", "HEADSET ", "BTSCO ", "BTA2DP ", "DOCK ", "HDMI ", "MIRRORING ", "USB " };
-       const char *capture_device_str[] = { "MAINMIC ", "HEADSET ", "BTMIC "  };
-
-       int playback_max = sizeof (playback_device_str) / sizeof (char*);
-       int capture_max = sizeof (capture_device_str) / sizeof (char*);
-
-       static char tmp_str[STR_LEN];
-       static char tmp_str2[STR_LEN];
-
-       debug_log ("<----------------------------------------------------->\n");
-
-
-       strcpy (tmp_str, "PLAYBACK = [ ");
-       for (i=0; i<playback_max; i++) {
-               if (((g_info.device_available & MM_SOUND_DEVICE_OUT_ANY) >> 8) & (0x01 << i)) {
-                       strncat (tmp_str, playback_device_str[i], STR_LEN - strlen(tmp_str) -1);
-               }
-       }
-       strcat (tmp_str, "]");
-
-       strcpy (tmp_str2, "CAPTURE = [ ");
-               for (i=0; i<capture_max; i++) {
-                       if ((g_info.device_available & MM_SOUND_DEVICE_IN_ANY) & (0x01 << i)) {
-                               strncat (tmp_str2, capture_device_str[i], STR_LEN - strlen(tmp_str2) -1);
-                       }
-       }
-       strcat (tmp_str2, "]");
-       debug_warning ("*** Available = [0x%08x], %s %s", g_info.device_available, tmp_str, tmp_str2);
-
-       strcpy (tmp_str, "PLAYBACK = [ ");
-       for (i=0; i<playback_max; i++) {
-               if (((g_info.device_active & MM_SOUND_DEVICE_OUT_ANY) >> 8) & (0x01 << i)) {
-                       strncat (tmp_str, playback_device_str[i], STR_LEN - strlen(tmp_str) -1);
-               }
-       }
-       strcat (tmp_str, "]");
-
-       strcpy (tmp_str2, "CAPTURE = [ ");
-               for (i=0; i<capture_max; i++) {
-                       if ((g_info.device_active & MM_SOUND_DEVICE_IN_ANY) & (0x01 << i)) {
-                               strncat (tmp_str2, capture_device_str[i], STR_LEN - strlen(tmp_str2) -1);
-                       }
-       }
-       strcat (tmp_str2, "]");
-       debug_warning ("***    Active = [0x%08x], %s %s", g_info.device_active, tmp_str, tmp_str2);
-
-
-       debug_warning ("*** Headset type = [%d], BT = [%s], default sink = [%s]\n", g_info.headset_type, g_info.bt_info.name, g_info.default_sink_name);
-       debug_warning ("*** Session = [%d], SubSession = [%d]\n", g_info.session, g_info.subsession);
-       debug_log ("<----------------------------------------------------->\n");
-}
-
-/* ------------------------- ASM ------------------------------------*/
-static pthread_mutex_t _asm_mutex = PTHREAD_MUTEX_INITIALIZER;
-
-static bool _asm_register_for_headset (int * handle)
-{
-       int asm_error = 0;
-
-       if (handle == NULL) {
-               debug_error ("Handle is not valid!!!\n");
-               return false;
-       }
-
-       if (!ASM_register_sound_ex (-1, handle, ASM_EVENT_EARJACK_UNPLUG, ASM_STATE_NONE, NULL, NULL, ASM_RESOURCE_NONE, &asm_error, __asm_process_message)) {
-               debug_warning("earjack event register failed with 0x%x\n", asm_error);
-               return false;
-       }
-
-       return true;
-}
-
-static void _asm_pause_process(int handle)
-{
-       int asm_error = 0;
-
-       MMSOUND_ENTER_CRITICAL_SECTION( &_asm_mutex )
-
-       /* If no asm handle register here */
-       if (g_info.asm_handle ==  -1) {
-               debug_msg ("ASM handle is not valid, try to register once more\n");
-
-               /* This register should be success */
-               if (_asm_register_for_headset (&g_info.asm_handle)) {
-                       debug_msg("_asm_register_for_headset() success\n");
-               } else {
-                       debug_error("_asm_register_for_headset() failed\n");
-               }
-       }
-
-       //do pause
-       debug_warning("Send earphone unplug event to Audio Session Manager Server\n");
-
-       if (!ASM_set_sound_state_ex(handle, ASM_EVENT_EARJACK_UNPLUG, ASM_STATE_PLAYING, ASM_RESOURCE_NONE, &asm_error, __asm_process_message)) {
-               debug_error("earjack event set sound state to playing failed with 0x%x\n", asm_error);
-       }
-
-       if (!ASM_set_sound_state_ex(handle, ASM_EVENT_EARJACK_UNPLUG, ASM_STATE_STOP, ASM_RESOURCE_NONE, &asm_error, __asm_process_message)) {
-               debug_error("earjack event set sound state to stop failed with 0x%x\n", asm_error);
-       }
-
-       MMSOUND_LEAVE_CRITICAL_SECTION( &_asm_mutex )
-}
-
-static bool _asm_unregister_for_headset (int *handle)
-{
-       int asm_error = 0;
-
-       if (handle == NULL) {
-               debug_error ("Handle is not valid!!!\n");
-               return false;
-       }
-
-       if (!ASM_unregister_sound_ex(*handle, ASM_EVENT_EARJACK_UNPLUG, &asm_error, __asm_process_message)) {
-               debug_error("earjack event unregister failed with 0x%x\n", asm_error);
-               return false;
-       }
-
-       return true;
-}
-
-/* ------------------------- INTERNAL FUNCTIONS ------------------------------------*/
-
-static void __backup_current_active_device()
-{
-       g_info.previous_playback_device = GET_ACTIVE_PLAYBACK();
-       g_info.previous_capture_device = GET_ACTIVE_CAPTURE();
-       g_info.previous_device_available = g_info.device_available;
-}
-
-static void __restore_previous_active_device()
-{
-       RESET_ACTIVE(0);
-
-       debug_msg ("available device (0x%x => 0x%x)", g_info.previous_device_available, g_info.device_available);
-       if (g_info.previous_device_available == g_info.device_available) {
-               /* No Changes */
-               g_info.device_active |= g_info.previous_playback_device;
-               g_info.device_active |= g_info.previous_capture_device;
-       } else {
-               /* Changes happens */
-               __select_playback_active_device();
-               __select_capture_active_device();
-       }
-}
-
-
-static int __set_route(bool need_broadcast, bool need_cork)
-{
-       int ret = MM_ERROR_NONE;
-
-       debug_msg ("need_broadcast=%d, need_cork=%d\n", need_broadcast, need_cork);
-
-       LOCK_PATH();
-
-       /* Set path based on current active device */
-       ret = __set_sound_path_for_current_active(need_broadcast, need_cork);
-       if (ret != MM_ERROR_NONE) {
-               debug_error ("__set_sound_path_for_current_active() failed [%x]\n", ret);
-               UNLOCK_PATH();
-               return ret;
-       }
-
-       UNLOCK_PATH();
-       return ret;
-}
-
-static int __set_route_nolock(bool need_broadcast, bool need_cork)
-{
-       int ret = MM_ERROR_NONE;
-
-       debug_msg ("need_broadcast=%d, need_cork=%d\n", need_broadcast, need_cork);
-
-       /* Set path based on current active device */
-       ret = __set_sound_path_for_current_active(need_broadcast, need_cork);
-       if (ret != MM_ERROR_NONE) {
-               debug_error ("__set_sound_path_for_current_active() failed [%x]\n", ret);
-               UNLOCK_PATH();
-               return ret;
-       }
-
-       return ret;
-}
-
-static int __set_playback_route_media (session_state_t state)
-{
-       int ret = MM_ERROR_NONE;
-
-       debug_fenter();
-
-       if (state == SESSION_START) {
-               dump_info();
-       } else { /* SESSION_END */
-               __set_route(false, false);
-               dump_info();
-       }
-
-       debug_fleave();
-       return ret;
-}
-
-static int __set_playback_route_voip (session_state_t state)
-{
-       int ret = MM_ERROR_NONE;
-
-       debug_fenter();
-       if (state == SESSION_START) {
-               /* Enable Receiver Device */
-               debug_log ("voip call session started...");
-
-               /* Backup current active for future restore */
-               __backup_current_active_device();
-
-               /* Set default subsession as VOICE */
-#ifdef TIZEN_MICRO
-               g_info.subsession = SUBSESSION_MEDIA;
-#else
-               g_info.subsession = SUBSESSION_VOICE;
-#endif
-
-               /* OUT */
-#ifdef TIZEN_MICRO
-               SET_PLAYBACK_ONLY_ACTIVE(MM_SOUND_DEVICE_OUT_SPEAKER);
-               SET_CAPTURE_ONLY_ACTIVE(MM_SOUND_DEVICE_IN_MIC);
-#else
-               if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_SPEAKER)) {
-                       debug_log ("active out was SPEAKER => activate receiver!!\n");
-                       SET_PLAYBACK_ONLY_ACTIVE(MM_SOUND_DEVICE_OUT_RECEIVER);
-               } else if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_BT_A2DP)) {
-                       debug_log ("active out was BT A2DP => activate BT SCO!!\n");
-                       SET_PLAYBACK_ONLY_ACTIVE(MM_SOUND_DEVICE_OUT_BT_SCO);
-                       SET_CAPTURE_ONLY_ACTIVE(MM_SOUND_DEVICE_IN_BT_SCO);
-               }
-               __set_route(true, false);
-#endif
-               dump_info();
-       } else { /* SESSION_END */
-               /* RESET */
-               if (g_info.session != SESSION_VOIP) {
-                       debug_warning ("Must be VOIP session but current session is [%s]\n",
-                               __get_session_string(g_info.session));
-               }
-               debug_log ("Reset ACTIVE, activate previous active device if still available, if not, set based on priority");
-               __restore_previous_active_device();
-
-               debug_log ("voip call session stopped...set path based on current active device");
-               __set_route(true, false);
-
-               dump_info();
-       }
-       debug_fleave();
-       return ret;
-}
-
-static int __set_playback_route_call (session_state_t state)
-{
-       int ret = MM_ERROR_NONE;
-
-       debug_fenter();
-
-       if (state == SESSION_START) {
-               debug_log ("voicecall session started...");
-
-               /* Backup current active for future restore */
-               __backup_current_active_device();
-
-               /* Set default subsession as MEDIA */
-               g_info.subsession = SUBSESSION_MEDIA;
-#ifndef TIZEN_MICRO
-               /* (speaker = receiver, headset = headset, bt a2dp = bt sco) */
-               /* OUT */
-               if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_SPEAKER)) {
-                       debug_log ("active out was SPEAKER => activate receiver!!\n");
-                       SET_PLAYBACK_ONLY_ACTIVE(MM_SOUND_DEVICE_OUT_RECEIVER);
-               } else if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_BT_A2DP)) {
-                       debug_log ("active out was BT A2DP => activate BT SCO!!\n");
-                       SET_PLAYBACK_ONLY_ACTIVE(MM_SOUND_DEVICE_OUT_BT_SCO);
-                       SET_CAPTURE_ONLY_ACTIVE(MM_SOUND_DEVICE_IN_BT_SCO);
-               }
-               /* FIXME : Do we have to set IN device ??? */
-               /* __set_path_with_notification(DO_NOTI); */
-               /* For sharing device information with PulseAudio */
-               MMSoundMgrPulseSetActiveDevice(GET_ACTIVE_CAPTURE(), GET_ACTIVE_PLAYBACK());
-#endif
-               dump_info();
-       } else {
-               /* SESSION_END */
-               debug_log ("Reset ACTIVE, activate previous active device if still available, if not, set based on priority");
-               __restore_previous_active_device();
-
-               debug_log ("voicecall session stopped...set path based on current active device");
-               __set_route(true, false);
-
-               dump_info();
-       }
-       debug_fleave();
-
-       return ret;
-}
-
-static int __set_playback_route_fmradio (session_state_t state)
-{
-       int ret = MM_ERROR_NONE;
-       int out = MM_SOUND_DEVICE_OUT_NONE;
-
-       debug_fenter();
-
-       if (state == SESSION_START) {
-               if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_SPEAKER))
-                       out = MM_SOUND_DEVICE_OUT_SPEAKER;
-               else if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY))
-                       out = MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY;
-               else if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_BT_A2DP))
-                       out = MM_SOUND_DEVICE_OUT_BT_A2DP;
-               /* Note : FM radio input is internal device, not exported */
-       } else {
-               /* SESSION_END */
-               /* Set as current active status */
-               /* FIXME : Need to release path on fm radio scenario */
-               __set_route(false, false);
-       }
-       /* FIXME : Need to update device status */
-       debug_fleave();
-       return ret;
-}
-
-static int __set_playback_route_notification (session_state_t state)
-{
-       int ret = MM_ERROR_NONE;
-
-       debug_fenter();
-
-       if (state == SESSION_START) {
-               /* FIXME : Need to check using vconf key with check status and policy */
-               if (mm_sound_util_is_recording() || mm_sound_util_is_mute_policy()) {
-                       /* Force earphone path for mute case */
-                       if ((ret = __set_sound_path_to_earphone_only ()) != MM_ERROR_NONE) {
-                               debug_error ("__set_sound_path_to_earphone_only() failed [%x]\n", ret);
-                       }
-               } else {
-                       /* In case of B2s, lockup issue is occurred */
-                       /* No HEADSET device */
-                       /* No matter on YMU chipset */
-                       if ((ret = __set_sound_path_to_dual ()) != MM_ERROR_NONE) {
-                               debug_error ("__set_sound_path_to_dual() failed [%x]\n", ret);
-                       }
-               }
-       } else { 
-               /* SESSION_END */
-               __set_route(false, false);
-       }
-       debug_fleave();
-
-       return ret;
-}
-
-static int __set_playback_route_alarm (session_state_t state)
-{
-       int ret = MM_ERROR_NONE;
-
-       debug_fenter();
-
-       if (state == SESSION_START) {
-               if ((ret = __set_sound_path_to_dual ()) != MM_ERROR_NONE) {
-                       debug_error ("__set_sound_path_to_dual() failed [%x]\n", ret);
-               }
-       } else { /* SESSION_END */
-               __set_route(false, false);
-       }
-
-       debug_fleave();
-
-       return ret;
-}
-
-static int __set_playback_route_emergency (session_state_t state)
-{
-       int ret = MM_ERROR_NONE;
-
-       debug_fenter();
-
-       if (state == SESSION_START) {
-               ret = __set_sound_path_to_speaker ();
-               if (ret != MM_ERROR_NONE) {
-                       debug_error ("__set_sound_path_to_speaker() failed [%x]\n", ret);
-               }
-
-       } else { /* SESSION_END */
-               __set_route(false, false);
-       }
-
-       debug_fleave();
-
-       return ret;
-}
-
-static int __set_playback_route_voicerecognition (session_state_t state)
-{
-       int ret = MM_ERROR_NONE;
-
-       debug_fenter();
-
-       if (state == SESSION_START) {
-               g_info.subsession = SUBSESSION_INIT;
-               /* audio path is changed when subsession is set */
-       } else { /* SESSION_END */
-               /* FIXME : On MICRO profile, need to check release path here */
-               __set_route(true, false);
-       }
-
-       debug_fleave();
-
-       return ret;
-}
-
-#if 0
-/* FIXME : Need to check for private function */
-static int __set_playback_route_timer_shot_and_recorder (subsession_state_t state)
-{
-       int ret = MM_ERROR_NONE;
-       mm_sound_device_in device_in_after = MM_SOUND_DEVICE_IN_NONE;
-       mm_sound_device_out device_out_after = MM_SOUND_DEVICE_OUT_NONE;
-       bool is_available = 0;
-       debug_fenter();
-
-       LOCK_PATH();
-       if (state == SUBSESSION_START) {
-               MMSoundMgrSessionGetDeviceActive(&g_info.device_out_previous, &g_info.device_in_previous);
-               g_info.device_available_previous = g_info.device_available;
-               if(g_info.device_out_previous != MM_SOUND_DEVICE_OUT_SPEAKER) {
-                       __set_sound_path_for_active_device_nolock(MM_SOUND_DEVICE_OUT_SPEAKER, MM_SOUND_DEVICE_IN_NONE);
-               }
-               /* audio path is changed when subsession is set */
-       } else { /* SESSION_END */
-               MMSoundMgrSessionGetDeviceActive(&device_out_after, &device_in_after);
-               if(device_out_after != MM_SOUND_DEVICE_OUT_SPEAKER) {
-                       __set_sound_path_for_active_device_nolock(device_out_after, device_in_after);
-               } else if(device_out_after == MM_SOUND_DEVICE_OUT_SPEAKER && g_info.device_out_previous != MM_SOUND_DEVICE_OUT_SPEAKER) {
-                       MMSoundMgrSessionIsDeviceAvailable(g_info.device_out_previous, g_info.device_in_previous, &is_available);
-                       if(is_available) {
-                               __set_sound_path_for_active_device_nolock(g_info.device_out_previous, g_info.device_in_previous);
-                       } else {
-                               __select_playback_active_device();
-                               __select_capture_active_device();
-                               MMSoundMgrSessionGetDeviceActive(&device_out_after, &device_in_after);
-                               if(device_out_after != MM_SOUND_DEVICE_OUT_SPEAKER) {
-                                       __set_sound_path_for_active_device_nolock(device_out_after, device_in_after);
-                               }
-                       }
-               }
-               MMSoundMgrSessionGetDeviceActive(&g_info.device_out_previous, &g_info.device_in_previous);
-               g_info.device_available_previous = g_info.device_available;
-       }
-
-       UNLOCK_PATH();
-
-       debug_fleave();
-
-       return ret;
-}
-#endif
-
-static bool __is_forced_session ()
-{
-       return (IS_ALARM_SESSION() || IS_NOTIFICATION_SESSION() || IS_EMERGENCY_SESSION())? true : false;
-}
-
-static bool __is_recording_subsession ()
-{
-       /* FIXME : Need to check routing option flag */
-       /* On private, by record option routing flag is changed */
-       bool is_recording = true;
-       switch (g_info.subsession) {
-               case SUBSESSION_RECORD_STEREO:
-               case SUBSESSION_RECORD_MONO:
-                       break;
-               default:
-                       is_recording = false;
-                       break;
-       }
-       return is_recording;
-}
-
-static int __set_sound_path_for_current_active (bool need_broadcast, bool need_cork)
-{
-       int ret = MM_ERROR_NONE;
-       int in = 0, out = 0;
-
-       debug_fenter();
-       debug_msg ("session:%s, subsession:%s, option:%d, active in:0x%x, out:0x%x, need_cork:%d",
-                       __get_session_string(g_info.session), __get_subsession_string(g_info.subsession),
-                       g_info.option, GET_ACTIVE_CAPTURE(), GET_ACTIVE_PLAYBACK(), need_cork);
-
-       if (__is_forced_session()) {
-               debug_warning ("Current session is ALARM/NOTI/EMER, pending path setting. path set will be done after session ends");
-               return MM_ERROR_SOUND_INVALID_STATE;
-       }
-
-       if (need_cork)
-               MMSoundMgrPulseSetCorkAll (true);
-
-       in = GET_ACTIVE_CAPTURE();
-       out = GET_ACTIVE_PLAYBACK();
-
-#ifdef TIZEN_MICRO
-       /* Wearable BT SCO headset case. Should be check nrec, wb, hf does't use sco */
-       if (in == MM_SOUND_DEVICE_IN_BT_SCO && out == MM_SOUND_DEVICE_OUT_BT_SCO) {
-               bool nrec = 0;
-               int bandwidth = MM_SOUND_BANDWIDTH_UNKNOWN;
-               /* Remove BT dependency */
-               /* ret = MMSoundMgrPulseGetBluetoothInfo(&nrec, &bandwidth); */
-               if(ret == MM_ERROR_NONE) {
-                       g_info.bt_info.is_nrec = nrec;
-                       g_info.bt_info.ag_wb = bandwidth;
-                       debug_msg("get bt information successfully. nrec(%d), wb(%s)",
-                               g_info.bt_info.is_nrec, __get_bt_bandwidth_string(g_info.bt_info.ag_wb));
-               } else {
-                       g_info.bt_info.is_nrec = false;
-                       g_info.bt_info.ag_wb = MM_SOUND_BANDWIDTH_NB;
-                       debug_msg("failed to get bt information. use default setting. nrec(off), wb(off)");
-               }
-               /* FIXME : How to send status of nrec & ag wideband state with option flag, on MICRO profile */
-       }
-#else
-       if (in == MM_SOUND_DEVICE_IN_BT_SCO && out == MM_SOUND_DEVICE_OUT_BT_SCO) {
-               /* FIXME : How to send status of nrec & ag wideband state with option flag */
-       }
-#endif
-
-       /* prepare GAIN */
-       switch (g_info.session) {
-       case SESSION_MEDIA:
-       case SESSION_NOTIFICATION:
-       case SESSION_ALARM:
-       case SESSION_EMERGENCY:
-               if (IS_MEDIA_SESSION() && __is_recording_subsession()) {
-                       /* gain & recording option */
-               } else {
-                       /* gain option */
-                       if (g_info.is_voicecontrol) {
-                               debug_warning ("VoiceControl");
-                               /* voice control option */
-                       }
-               }
-               break;
-       case SESSION_VOIP:
-               if (g_info.subsession == SUBSESSION_RINGTONE) {
-                       in = MM_SOUND_DEVICE_OUT_NONE;
-                       /* gain option */
-                       /* If active device was WFD(mirroring), set option */
-                       if (out == MM_SOUND_DEVICE_OUT_MIRRORING) {
-                               /* mirroring option */
-                       }
-                       if (mm_sound_util_is_mute_policy ()) {
-                               /* Mute Ringtone */
-                               out = MM_SOUND_DEVICE_OUT_BT_A2DP;
-                       } else {
-                               /* Normal Ringtone */
-                               out = MM_SOUND_DEVICE_OUT_SPEAKER;
-                               /* dual out option */
-                       }
-               } else if (g_info.subsession == SUBSESSION_VOICE) {
-                       /* gain option */
-               } else {
-                       debug_warning ("Unexpected SUBSESSION [%s]\n", __get_subsession_string(g_info.subsession));
-                               /* gain voip option */
-               }
-               break;
-
-       case SESSION_VOICECALL:
-       case SESSION_VIDEOCALL:
-               if (g_info.subsession == SUBSESSION_RINGTONE) {
-                       in = MM_SOUND_DEVICE_IN_NONE;
-                       /* If active device was WFD(mirroring), set option */
-                       if (out == MM_SOUND_DEVICE_OUT_MIRRORING) {
-                               /* mirroring option */
-                       }
-
-                       if (_mm_sound_is_mute_policy ()) {
-                               /* Mute Ringtone */
-#ifdef TIZEN_MICRO
-                               out = MM_SOUND_DEVICE_OUT_SPEAKER;
-#else
-                               out = MM_SOUND_DEVICE_OUT_BT_A2DP;
-#endif
-                       } else {
-                               out = MM_SOUND_DEVICE_OUT_SPEAKER;
-#ifdef TIZEN_MICRO
-                               /* for inband ringtone. hfp call ringtone is not used sco */
-                               int state = MM_SOUND_HFP_STATUS_UNKNOWN;
-                               state = __get_hf_connection_state();
-
-                               if(state == MM_SOUND_HFP_STATUS_INCOMMING_CALL) {
-                                       /* call by BT option */
-                               }
-#endif                         
-                               /* Normal Ringtone */
-                               /* dual out option */
-                       }
-               } else if (g_info.subsession == SUBSESSION_MEDIA) {
-                       /* call gain option */
-                       in = MM_SOUND_DEVICE_IN_NONE;
-               } else if (g_info.subsession == SUBSESSION_VOICE) {
-                       /* gain for voicecall or videocall */
-#ifdef _TIZEN_PUBLIC_
-                       if (out ==  MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY) {
-                               debug_log ("Fix in path to headsetmic when out path is headset\n");
-                               in = MM_SOUND_DEVICE_IN_WIRED_ACCESSORY;
-                       }
-                       /* FIXME : Check to NB / WB option */
-#endif /* _TIZEN_PUBLIC_*/
-               } else {
-                       debug_warning ("Unexpected SUBSESSION [%s]\n", __get_subsession_string(g_info.subsession));
-               }
-               break;
-
-       case SESSION_FMRADIO:
-               break;
-
-       case SESSION_VOICE_RECOGNITION:
-#ifdef TIZEN_MICRO
-               if (__is_right_hand_on()) {
-               }
-#endif
-               if (g_info.subsession == SUBSESSION_VR_NORMAL) {
-                       /* NORMAL mode */
-               } else if (g_info.subsession == SUBSESSION_VR_DRIVE) {
-                       /* DRIVE mode */
-                       /* FIXME : Need to check private mode or not */
-               } else {
-                               debug_warning ("Unexpected SUBSESSION [%s]\n", __get_subsession_string(g_info.subsession));
-               }
-               break;
-       default:
-               debug_warning ("session [%s] is not handled...\n", __get_session_string(g_info.session));
-               break;
-       }
-
-       debug_warning ("Trying to set device to pulseaudio : in[%d], out[%d]\n", in, out);
-
-       /* Update Pulseaudio Active Device */
-       if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_BT_A2DP)) {
-               MMSoundMgrPulseSetActiveDevice(GET_ACTIVE_CAPTURE(), GET_ACTIVE_PLAYBACK());
-       } else if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_USB_AUDIO)) {
-               MMSoundMgrPulseSetActiveDevice(GET_ACTIVE_CAPTURE(), GET_ACTIVE_PLAYBACK());
-       } else if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK)) {
-               MMSoundMgrPulseSetActiveDevice(GET_ACTIVE_CAPTURE(), GET_ACTIVE_PLAYBACK());
-       } else {
-               /* ALSA route */
-               MMSoundMgrPulseSetActiveDevice(in, out);
-       }
-
-       /* Pulseaudio Default Sink route */
-       if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_BT_A2DP)) {
-               MMSoundMgrPulseSetDefaultSink (DEVICE_API_BLUETOOTH, DEVICE_BUS_BLUETOOTH);
-       } else if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_USB_AUDIO)) {
-               MMSoundMgrPulseSetUSBDefaultSink (MM_SOUND_DEVICE_OUT_USB_AUDIO);
-       } else if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK)) {
-               MMSoundMgrPulseSetUSBDefaultSink (MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK);
-       } else if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_HDMI)) {
-               MMSoundMgrPulseSetDefaultSinkByName (ALSA_SINK_HDMI);
-       } else {
-               MMSoundMgrPulseSetDefaultSink (DEVICE_API_ALSA, DEVICE_BUS_BUILTIN);
-       }
-
-       /* Set Source Mute */
-       MMSoundMgrPulseSetSourcemutebyname(MIRRORING_MONITOR_SOURCE,
-                       IS_ACTIVE(MM_SOUND_DEVICE_OUT_MIRRORING)? MM_SOUND_AUDIO_UNMUTE : MM_SOUND_AUDIO_MUTE);
-
-       if (need_broadcast) {
-               /* Notify current active device */
-               ret = _mm_sound_mgr_device_active_device_callback(GET_ACTIVE_CAPTURE(), GET_ACTIVE_PLAYBACK());
-               if (ret != MM_ERROR_NONE) {
-                       debug_error ("_mm_sound_mgr_device_active_device_callback() failed [%x]\n", ret);
-               }
-       }
-
-       if (need_cork) {
-               /* FIXME : Private issues, workaround for earjack inserting scenario during media playback */
-               if (g_info.session == SESSION_MEDIA && (IS_ACTIVE(MM_SOUND_DEVICE_OUT_BT_A2DP) || IS_ACTIVE(MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY))) {
-                       usleep(20000);
-               }               
-               MMSoundMgrPulseSetCorkAll (false);
-       }
-
-       /* clean up */
-       debug_fleave();
-       return ret;
-}
-
-static int __set_sound_path_for_voicecontrol (void)
-{
-       int ret = MM_ERROR_NONE;
-       int in = MM_SOUND_DEVICE_IN_NONE, out = MM_SOUND_DEVICE_OUT_NONE;
-
-       debug_fenter();
-
-       /* prepare IN */
-       if (IS_ACTIVE(MM_SOUND_DEVICE_IN_MIC)) {
-               in = MM_SOUND_DEVICE_IN_MIC;
-       } else if (IS_ACTIVE(MM_SOUND_DEVICE_IN_WIRED_ACCESSORY)) {
-               in = MM_SOUND_DEVICE_IN_WIRED_ACCESSORY;
-       } else if (IS_ACTIVE(MM_SOUND_DEVICE_IN_BT_SCO)) {
-               debug_warning ("[NOT EXPECTED CASE] BT SCO");
-       }
-
-       debug_warning ("g_info.session = %s ", __get_session_string(g_info.session));
-       /* prepare GAIN */
-       switch (g_info.session) {
-       case SESSION_MEDIA:
-       case SESSION_NOTIFICATION:
-       case SESSION_ALARM:
-       case SESSION_EMERGENCY:
-       case SESSION_VOICECALL:
-       case SESSION_VIDEOCALL:
-       case SESSION_VOIP:
-               if (IS_MEDIA_SESSION() && __is_recording_subsession(NULL)) {
-                       debug_warning ("[NOT EXPECTED CASE] already RECORDING....return");
-                       return MM_ERROR_NONE;
-               }
-               /* gain control KEYTONE */
-       if (g_info.is_voicecontrol) {
-#ifdef TIZEN_MICRO
-                       /* For inband ringtone. hfp call ringtone is not used sco */
-                       int state = MM_SOUND_HFP_STATUS_UNKNOWN;
-                       state = __get_hf_connection_state();
-                       if(state == MM_SOUND_HFP_STATUS_INCOMMING_CALL) {
-                               /* Call by BT option */
-                       }
-#endif
-                       debug_warning ("VoiceControl\n");
-                       /* Bargein option */
-               }
-               break;
-
-       case SESSION_FMRADIO:
-       case SESSION_VOICE_RECOGNITION:
-               debug_warning ("[NOT EXPECTED CASE] ");
-               break;
-
-       default:
-               debug_warning ("session [%s] is not handled...\n", __get_session_string(g_info.session));
-               break;
-       }
-
-       debug_warning ("Trying to set device to pulseaudio : in[%d], out[%d]\n", in, GET_ACTIVE_PLAYBACK());
-
-       /* Set Path (IN, OUT) */
-       MMSoundMgrPulseSetActiveDevice(in, GET_ACTIVE_PLAYBACK());
-
-       debug_fleave();
-       return ret;
-
-}
-
-
-static int __set_sound_path_to_dual (void)
-{
-       int ret = MM_ERROR_NONE;
-       int in = MM_SOUND_DEVICE_IN_NONE;
-
-       debug_fenter();
-
-       in = IS_ACTIVE(MM_SOUND_DEVICE_IN_WIRED_ACCESSORY)? MM_SOUND_DEVICE_IN_WIRED_ACCESSORY : MM_SOUND_DEVICE_IN_MIC;
-
-       /* If active device was WFD(mirroring), set option */
-       if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_MIRRORING)) {
-               /* mirorring option */
-       }
-       if (g_info.is_voicecontrol) {
-               debug_msg ("VoiceControl\n");
-               /* bargein option */
-       }
-       /* Sound path for ALSA */
-       debug_msg ("not supported, set path to DUAL-OUT");
-       MMSoundMgrPulseSetActiveDevice(in, MM_SOUND_DEVICE_OUT_SPEAKER);
-
-       /* clean up */
-       debug_fleave();
-       return ret;
-}
-
-static int __set_sound_path_to_earphone_only (void)
-{
-       int ret = MM_ERROR_NONE;
-       int in = MM_SOUND_DEVICE_IN_NONE;
-
-       debug_fenter();
-
-       in = IS_ACTIVE(MM_SOUND_DEVICE_IN_WIRED_ACCESSORY)? MM_SOUND_DEVICE_IN_WIRED_ACCESSORY : MM_SOUND_DEVICE_IN_MIC;
-
-       if (g_info.is_voicecontrol) {
-               debug_msg ("VoiceControl\n");
-               /* bargein option */
-       }
-
-       /* Sound path for ALSA */
-       debug_msg ("Set path to EARPHONE only.\n");
-       MMSoundMgrPulseSetActiveDevice(in, MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY);
-
-       /* clean up */
-       debug_fleave();
-       return ret;
-}
-
-int  MMSoundMgrSessionSetSoundPathForActiveDevice (mm_sound_device_out playback, mm_sound_device_in capture)
-{
-       int ret = MM_ERROR_NONE;
-
-       debug_fenter();
-
-       /* Sound path for ALSA */
-       debug_log ("Set path for active device.playback:%x, capture:%x\n",playback,capture);
-       if ((playback && !IS_AVAILABLE(playback)) || (capture && !IS_AVAILABLE(capture))) {
-               debug_warning ("Failed to set active state to unavailable device!!!\n");
-               ret = MM_ERROR_INVALID_ARGUMENT;
-               goto END_SET_DEVICE;
-       }
-
-       LOCK_PATH();
-       /* Update active state */
-       debug_log ("Update active device as request\n");
-       if (playback) {
-               SET_PLAYBACK_ONLY_ACTIVE(playback);
-       }
-       if (capture) {
-               SET_CAPTURE_ONLY_ACTIVE(capture);
-       }
-       MMSoundMgrPulseSetActiveDevice(GET_ACTIVE_CAPTURE(), GET_ACTIVE_PLAYBACK());
-
-       if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_BT_A2DP)) {
-               MMSoundMgrPulseSetDefaultSink (DEVICE_API_BLUETOOTH, DEVICE_BUS_BLUETOOTH);
-       } else if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_USB_AUDIO)) {
-               MMSoundMgrPulseSetUSBDefaultSink (MM_SOUND_DEVICE_OUT_USB_AUDIO);
-       } else if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK)) {
-               MMSoundMgrPulseSetUSBDefaultSink (MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK);
-       } else if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_HDMI)) {
-               MMSoundMgrPulseSetDefaultSinkByName (ALSA_SINK_HDMI);
-       } else {
-               MMSoundMgrPulseSetDefaultSink (DEVICE_API_ALSA, DEVICE_BUS_BUILTIN);
-       }
-       UNLOCK_PATH();
-
-END_SET_DEVICE:
-       debug_fleave();
-       return ret;
-}
-
-static int __set_sound_path_for_active_device_nolock (mm_sound_device_out playback, mm_sound_device_in capture)
-{
-       int ret = MM_ERROR_NONE;
-
-       debug_fenter();
-
-       /* Sound path for ALSA */
-       debug_log ("Set path for active device.playback:%x, capture:%x\n",playback,capture);
-       if ((playback && !IS_AVAILABLE(playback)) || (capture && !IS_AVAILABLE(capture))) {
-               debug_warning ("Failed to set active state to unavailable device!!!\n");
-               ret = MM_ERROR_INVALID_ARGUMENT;
-               goto END_SET_DEVICE;
-       }
-
-       /* Update active state */
-       debug_log ("Update active device as request\n");
-       if (playback) {
-               SET_PLAYBACK_ONLY_ACTIVE(playback);
-       }
-       if (capture) {
-               SET_CAPTURE_ONLY_ACTIVE(capture);
-       }
-       MMSoundMgrPulseSetActiveDevice(GET_ACTIVE_CAPTURE(), GET_ACTIVE_PLAYBACK());
-
-       if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_BT_A2DP)) {
-               MMSoundMgrPulseSetDefaultSink (DEVICE_API_BLUETOOTH, DEVICE_BUS_BLUETOOTH);
-       } else if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_USB_AUDIO)) {
-               MMSoundMgrPulseSetUSBDefaultSink (MM_SOUND_DEVICE_OUT_USB_AUDIO);
-       } else if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK)) {
-               MMSoundMgrPulseSetUSBDefaultSink (MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK);
-       } else if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_HDMI)) {
-               MMSoundMgrPulseSetDefaultSinkByName (ALSA_SINK_HDMI);
-       } else {
-               MMSoundMgrPulseSetDefaultSink (DEVICE_API_ALSA, DEVICE_BUS_BUILTIN);
-       }
-
-END_SET_DEVICE:
-       debug_fleave();
-       return ret;
-}
-
-static int __set_sound_path_to_speaker (void)
-{
-       int ret = MM_ERROR_NONE;
-
-       debug_fenter();
-
-       /* Sound path for ALSA */
-       debug_log ("Set path to SPEAKER.\n");
-       MMSoundMgrPulseSetActiveDevice(GET_ACTIVE_CAPTURE(), MM_SOUND_DEVICE_OUT_SPEAKER);
-
-       /* clean up */
-       debug_fleave();
-       return ret;
-}
-
-static void __select_playback_active_device (void)
-{
-       if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_ANY)) {
-               debug_log ("Active device exists. Nothing needed...\n");
-               return;
-       }
-
-       debug_warning ("No playback active device, set active based on priority!!\n");
-
-       /* set active device based on device priority (bt>ear>spk) */
-       if (IS_AVAILABLE(MM_SOUND_DEVICE_OUT_BT_A2DP)) {
-               debug_log ("BT A2DP available, set as active!!\n");
-               SET_ACTIVE(MM_SOUND_DEVICE_OUT_BT_A2DP);
-               MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_IO_DIRECTION, DEVICE_TYPE_BLUETOOTH, DEVICE_IO_DIRECTION_OUT, DEVICE_ID_AUTO, NULL, DEVICE_STATE_ACTIVATED, NULL);
-               MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_BLUETOOTH, DEVICE_IO_DIRECTION_OUT, DEVICE_ID_AUTO, NULL, DEVICE_STATE_ACTIVATED, NULL);
-       } else if (IS_AVAILABLE(MM_SOUND_DEVICE_OUT_MIRRORING)) {
-               debug_log ("MIRRORING available, set as active!!\n");
-               SET_ACTIVE(MM_SOUND_DEVICE_OUT_MIRRORING);
-               MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_MIRRORING, DEVICE_IO_DIRECTION_OUT, DEVICE_ID_AUTO, NULL, DEVICE_STATE_ACTIVATED, NULL);
-       } else if (IS_AVAILABLE(MM_SOUND_DEVICE_OUT_DOCK)) {
-               debug_log ("DOCK available, set as active!!\n");
-               SET_ACTIVE(MM_SOUND_DEVICE_OUT_DOCK);
-       } else if (IS_AVAILABLE(MM_SOUND_DEVICE_OUT_HDMI)) {
-               debug_log ("HDMI available, set as active!!\n");
-               SET_ACTIVE(MM_SOUND_DEVICE_OUT_HDMI);
-               MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_HDMI, DEVICE_IO_DIRECTION_OUT, DEVICE_ID_AUTO, NULL, DEVICE_STATE_ACTIVATED, NULL);
-       } else if (IS_AVAILABLE(MM_SOUND_DEVICE_OUT_USB_AUDIO)) {
-               debug_log ("USB Audio available, set as active!!\n");
-               SET_ACTIVE(MM_SOUND_DEVICE_OUT_USB_AUDIO);
-               MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_USB_AUDIO, DEVICE_IO_DIRECTION_OUT, DEVICE_ID_AUTO, NULL, DEVICE_STATE_ACTIVATED, NULL);
-       } else if (IS_AVAILABLE(MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK)) {
-               debug_log ("Multimedia Dock available, set as active!!\n");
-               SET_ACTIVE(MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK);
-       } else if (IS_AVAILABLE(MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY)) {
-               debug_log ("WIRED available, set as active!!\n");
-               SET_ACTIVE(MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY);
-               MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_AUDIOJACK, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_ACTIVATED, NULL);
-       } else {
-               debug_log ("SPEAKER/RECEIVER available, set SPEAKER as active!!\n");
-               SET_ACTIVE(MM_SOUND_DEVICE_OUT_SPEAKER);
-               MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_BUILTIN_SPEAKER, DEVICE_IO_DIRECTION_OUT, DEVICE_ID_AUTO, NULL, DEVICE_STATE_ACTIVATED, NULL);
-       }
-}
-
-static void __select_capture_active_device (void)
-{
-       if (IS_ACTIVE(MM_SOUND_DEVICE_IN_ANY)) {
-               debug_log ("Active device exists. Nothing needed...\n");
-               return;
-       }
-
-       debug_warning ("No capture active device, set active based on priority!!\n");
-
-       /* set active device based on device priority (bt>ear>spk) */
-       if (IS_AVAILABLE(MM_SOUND_DEVICE_IN_BT_SCO) && IS_CALL_SESSION()) {
-               debug_log ("BT SCO available, set as active!!\n");
-               SET_ACTIVE(MM_SOUND_DEVICE_IN_BT_SCO);
-               MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_BLUETOOTH, DEVICE_IO_DIRECTION_BOTH, DEVICE_ID_AUTO, NULL, DEVICE_STATE_ACTIVATED, NULL);
-       } else if (IS_AVAILABLE(MM_SOUND_DEVICE_IN_WIRED_ACCESSORY)) {
-               debug_log ("WIRED available, set as active!!\n");
-               SET_ACTIVE(MM_SOUND_DEVICE_IN_WIRED_ACCESSORY);
-               MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_AUDIOJACK, DEVICE_IO_DIRECTION_BOTH, DEVICE_ID_AUTO, NULL, DEVICE_STATE_ACTIVATED, NULL);
-       } else {
-               debug_log ("MIC available, set as active!!\n");
-               SET_ACTIVE(MM_SOUND_DEVICE_IN_MIC);
-               MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_BUILTIN_MIC, DEVICE_IO_DIRECTION_IN, DEVICE_ID_AUTO, NULL, DEVICE_STATE_ACTIVATED, NULL);
-       }
-}
-
-static int __get_device_type_from_old_device (int old_device_type, device_type_e *device_type)
-{
-       int ret = MM_ERROR_NONE;
-
-       switch(old_device_type) {
-       case MM_SOUND_DEVICE_IN_MIC:
-               *device_type = DEVICE_TYPE_BUILTIN_MIC;
-               break;
-       case MM_SOUND_DEVICE_IN_WIRED_ACCESSORY:
-       case MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY:
-               *device_type = DEVICE_TYPE_AUDIOJACK;
-               break;
-       case MM_SOUND_DEVICE_IN_BT_SCO:
-       case MM_SOUND_DEVICE_OUT_BT_SCO:
-       case MM_SOUND_DEVICE_OUT_BT_A2DP:
-               *device_type = DEVICE_TYPE_BLUETOOTH;
-               break;
-       case MM_SOUND_DEVICE_OUT_SPEAKER:
-               *device_type = DEVICE_TYPE_BUILTIN_SPEAKER;
-               break;
-       case MM_SOUND_DEVICE_OUT_RECEIVER:
-               *device_type = DEVICE_TYPE_BUILTIN_RECEIVER;
-               break;
-       case MM_SOUND_DEVICE_OUT_HDMI:
-               *device_type = DEVICE_TYPE_HDMI;
-               break;
-       case MM_SOUND_DEVICE_OUT_MIRRORING:
-               *device_type = DEVICE_TYPE_MIRRORING;
-               break;
-       case MM_SOUND_DEVICE_OUT_USB_AUDIO:
-               *device_type = DEVICE_TYPE_USB_AUDIO;
-               break;
-       default:
-               ret = MM_ERROR_NOT_SUPPORT_API;
-               break;
-       }
-       return ret;
-}
-
-static void __set_deactivate_all_device_auto (mm_sound_device_in exception_in, mm_sound_device_out exception_out)
-{
-       /* DEACTIVATE OTHERS */
-       /* IN */
-       if (exception_in != MM_SOUND_DEVICE_IN_MIC) {
-               MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_BUILTIN_MIC, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_DEACTIVATED, NULL);
-       }
-       if ((exception_in != MM_SOUND_DEVICE_IN_WIRED_ACCESSORY) && (exception_out != MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY)) {
-               MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_AUDIOJACK, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_DEACTIVATED, NULL);
-       }
-       if ((exception_in != MM_SOUND_DEVICE_IN_BT_SCO) && (exception_out != MM_SOUND_DEVICE_OUT_BT_A2DP) && (exception_out != MM_SOUND_DEVICE_OUT_BT_SCO)) {
-               MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_BLUETOOTH, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_DEACTIVATED, NULL);
-       }
-       /* OUT */
-       if (exception_out != MM_SOUND_DEVICE_OUT_SPEAKER) {
-               MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_BUILTIN_SPEAKER, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_DEACTIVATED, NULL);
-       }
-       if (exception_out != MM_SOUND_DEVICE_OUT_RECEIVER) {
-               MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_BUILTIN_RECEIVER, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_DEACTIVATED, NULL);
-       }
-       if ((exception_out != MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY) && (exception_in != MM_SOUND_DEVICE_IN_WIRED_ACCESSORY)) {
-               MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_AUDIOJACK, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_DEACTIVATED, NULL);
-       }
-       if (exception_out != MM_SOUND_DEVICE_OUT_MIRRORING) {
-               MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_MIRRORING, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_DEACTIVATED, NULL);
-       }
-       if (exception_out != MM_SOUND_DEVICE_OUT_USB_AUDIO) {
-               MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_USB_AUDIO, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_DEACTIVATED, NULL);
-       }
-       if ((exception_out != MM_SOUND_DEVICE_OUT_BT_A2DP) && (exception_out != MM_SOUND_DEVICE_OUT_BT_SCO) && (exception_in != MM_SOUND_DEVICE_IN_BT_SCO)) {
-               MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_BLUETOOTH, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_DEACTIVATED, NULL);
-       }
-       if (exception_out != MM_SOUND_DEVICE_OUT_HDMI) {
-               MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_HDMI, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_DEACTIVATED, NULL);
-       }
-}
-
-static void __set_initial_active_device (void)
-{
-       int dock_type = 0;
-       bool a2dp = 0, sco = 0;
-
-       /* Set SPK/RECIEVER(for OUT) & MIC(for IN) as default available device */
-       /* FIXME : spk & mic can be always on??? */
-#ifdef TIZEN_MICRO
-       SET_AVAILABLE(MM_SOUND_DEVICE_OUT_SPEAKER);
-#else
-       SET_AVAILABLE(MM_SOUND_DEVICE_OUT_SPEAKER|MM_SOUND_DEVICE_OUT_RECEIVER);
-#endif
-       SET_AVAILABLE(MM_SOUND_DEVICE_IN_MIC);
-
-       /* Get wired status and set available status */
-       mm_sound_util_get_earjack_type (&g_info.headset_type);
-       if (g_info.headset_type > EARJACK_UNPLUGGED) {
-               SET_AVAILABLE(MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY);
-               if (g_info.headset_type == DEVICE_EARJACK_TYPE_SPK_WITH_MIC) {
-                       SET_AVAILABLE(MM_SOUND_DEVICE_IN_WIRED_ACCESSORY);
-                       MMSoundMgrDeviceUpdateStatus(DEVICE_UPDATE_STATUS_CONNECTED, DEVICE_TYPE_AUDIOJACK, DEVICE_IO_DIRECTION_BOTH, DEVICE_ID_AUTO, DEVICE_NAME_AUDIOJACK_4P, 0, NULL);
-                       MMSoundMgrDeviceUpdateStatus(DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_AUDIOJACK, DEVICE_IO_DIRECTION_BOTH, DEVICE_ID_AUTO, DEVICE_NAME_AUDIOJACK_4P, DEVICE_STATE_ACTIVATED, NULL);
-               } else {
-                       MMSoundMgrDeviceUpdateStatus(DEVICE_UPDATE_STATUS_CONNECTED, DEVICE_TYPE_AUDIOJACK, DEVICE_IO_DIRECTION_BOTH, DEVICE_ID_AUTO, DEVICE_NAME_AUDIOJACK_3P, 0, NULL);
-                       MMSoundMgrDeviceUpdateStatus(DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_AUDIOJACK, DEVICE_IO_DIRECTION_BOTH, DEVICE_ID_AUTO, DEVICE_NAME_AUDIOJACK_3P, DEVICE_STATE_ACTIVATED, NULL);
-               }
-       }
-
-       /* Get Dock status and set available status */
-       mm_sound_util_get_dock_type (&dock_type);
-       if (dock_type == DOCK_DESKDOCK) {
-               SET_AVAILABLE(MM_SOUND_DEVICE_OUT_DOCK);
-       }
-
-       /* Get BT status and set available status */
-       MMSoundMgrPulseGetInitialBTStatus (&a2dp, &sco);
-       if (a2dp) {
-               SET_AVAILABLE(MM_SOUND_DEVICE_OUT_BT_A2DP);
-               MMSoundMgrDeviceUpdateStatus(DEVICE_UPDATE_STATUS_CONNECTED, DEVICE_TYPE_BLUETOOTH, DEVICE_IO_DIRECTION_OUT, DEVICE_ID_AUTO, NULL, 0, NULL);
-       }
-       if (sco) {
-               SET_AVAILABLE(MM_SOUND_DEVICE_OUT_BT_SCO);
-               SET_AVAILABLE(MM_SOUND_DEVICE_IN_BT_SCO);
-               MMSoundMgrDeviceUpdateStatus(DEVICE_UPDATE_STATUS_CONNECTED, DEVICE_TYPE_BLUETOOTH, DEVICE_IO_DIRECTION_BOTH, DEVICE_ID_AUTO, NULL, 0, NULL);
-       }
-
-       /* Set Active device based on priority */
-       __select_playback_active_device ();
-       __select_capture_active_device ();
-
-       __set_route(true, false);
-       dump_info();
-}
-
-static void __handle_bt_a2dp_on (void)
-{
-       int ret = MM_ERROR_NONE;
-
-       /* at this time, pulseaudio default sink is bt sink */
-       if (IS_CALL_SESSION()) {
-               debug_warning ("Current session is VOICECALL or VIDEOCALL or VOIP, no auto-activation!!!\n");
-               return;
-       }
-
-       debug_log ("Activate BT_A2DP device\n");
-       SET_PLAYBACK_ONLY_ACTIVE(MM_SOUND_DEVICE_OUT_BT_A2DP);
-
-       /* ACTIVATE BLUETOOTH */
-       MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_BLUETOOTH, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_ACTIVATED, NULL);
-       /* DEACTIVATE OTHERS */
-       __set_deactivate_all_device_auto (GET_ACTIVE_CAPTURE(), GET_ACTIVE_PLAYBACK());
-
-       /* For sharing device information with PulseAudio */
-       MMSoundMgrPulseSetActiveDevice(MM_SOUND_DEVICE_IN_NONE, GET_ACTIVE_PLAYBACK());
-
-       ret = _mm_sound_mgr_device_active_device_callback(GET_ACTIVE_CAPTURE(), GET_ACTIVE_PLAYBACK());
-       if (ret != MM_ERROR_NONE) {
-               debug_error ("_mm_sound_mgr_device_active_device_callback() failed [%x]\n", ret);
-       }
-
-       dump_info ();
-}
-
-static void __handle_bt_a2dp_off (void)
-{
-       if (!IS_ACTIVE(MM_SOUND_DEVICE_OUT_BT_A2DP)) {
-               debug_warning("MM_SOUND_DEVICE_OUT_BT_A2DP was not active. nothing to do here.");
-               dump_info ();
-               return;
-       }
-
-       /* if bt was active, then do asm pause */
-       debug_msg("Do pause here");
-       _asm_pause_process (g_info.asm_handle);
-
-       /* set BT A2DP device to none */
-       debug_msg("Deactivate BT_A2DP device\n");
-       UNSET_ACTIVE(MM_SOUND_DEVICE_OUT_BT_A2DP);
-
-       /* DEACTIVATE BLUETOOTH */
-       MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_BLUETOOTH, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_DEACTIVATED, NULL);
-
-       /* activate current available device based on priority */
-       __select_playback_active_device();
-
-       /* Do set path and notify result */
-       __set_route_nolock(true, true);
-
-       dump_info ();
-}
-
-static void __handle_bt_sco_on ()
-{
-       /* if fmradio session, do nothing */
-
-       /* Skip when noti session */
-
-       /* ToDo : alarm/notification session ???? */
-       if (IS_CALL_SESSION()) {
-               debug_warning ("Current session is VOICECALL or VIDEOCALL or VOIP, no auto-activation!!!\n");
-               return;
-       }
-
-       debug_log ("Activate BT SCO IN/OUT device\n");
-       SET_PLAYBACK_ONLY_ACTIVE(MM_SOUND_DEVICE_OUT_BT_SCO);
-       SET_CAPTURE_ONLY_ACTIVE(MM_SOUND_DEVICE_IN_BT_SCO);
-
-       /* For wearable history */
-       /* __set_route_nolock(ROUTE_PARAM_BROADCASTING | ROUTE_PARAM_CORK_DEVICE); */
-       /* Do set path and notify result */
-       __set_route(true, true);
-
-       /* ACTIVATE BLUETOOTH */
-       MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_BLUETOOTH, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_ACTIVATED, NULL);
-       /* DEACTIVATE OTHERS */
-       __set_deactivate_all_device_auto (GET_ACTIVE_CAPTURE(), GET_ACTIVE_PLAYBACK());
-
-       dump_info ();
-}
-
-static void __handle_bt_sco_off (void)
-{
-       /* DEACTIVATE BLUETOOTH */
-       MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_BLUETOOTH, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_DEACTIVATED, NULL);
-
-       /* If sco is not activated, just return */
-       if (!IS_ACTIVE(MM_SOUND_DEVICE_OUT_BT_SCO) && !IS_ACTIVE(MM_SOUND_DEVICE_IN_BT_SCO)) {
-               debug_warning("BT SCO was not active. nothing to do here.");
-               dump_info ();
-               return;
-       }
-
-       /* set bt device to none */
-       debug_msg("Deactivate BT_SCO device\n");
-       UNSET_ACTIVE(MM_SOUND_DEVICE_OUT_BT_SCO);
-       UNSET_ACTIVE(MM_SOUND_DEVICE_IN_BT_SCO);
-
-       if (IS_CALL_SESSION()) {
-               debug_warning ("Current session is VOICECALL or VIDEOCALL or VOIP, no auto-activation!!!\n");
-               return;
-       }
-
-       /* activate current available device based on priority */
-       __select_playback_active_device();
-       __select_capture_active_device();
-
-       /* Do set path and notify result */
-       __set_route_nolock(true, true);
-
-       dump_info ();
-}
-
-static void __handle_headset_on (int type)
-{
-       /* at this time, pulseaudio default sink is bt sink */
-       /* if fmradio session, do nothing */
-
-       /* Skip when noti session */
-
-       /* ToDo : alarm/notification session ???? */
-       if (IS_CALL_SESSION()) {
-               debug_warning ("Current session is VOICECALL or VIDEOCALL or VOIP, no auto-activation!!!\n");
-               return;
-       }
-
-       debug_log ("Activate WIRED OUT device\n");
-       SET_PLAYBACK_ONLY_ACTIVE(MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY);
-       if (type == DEVICE_EARJACK_TYPE_SPK_WITH_MIC) {
-               debug_log ("Activate WIRED IN device\n");
-               SET_CAPTURE_ONLY_ACTIVE(MM_SOUND_DEVICE_IN_WIRED_ACCESSORY);
-       }
-
-       /* Do set path and notify result */
-       __set_route(true, true);
-
-       /* ACTIVATE AUDIOJACK */
-       MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_AUDIOJACK, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_ACTIVATED, NULL);
-       /* DEACTIVATE OTHERS */
-       __set_deactivate_all_device_auto (GET_ACTIVE_CAPTURE(), GET_ACTIVE_PLAYBACK());
-       if (type == DEVICE_EARJACK_TYPE_SPK_WITH_MIC) {
-               MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_BUILTIN_MIC, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_DEACTIVATED, NULL);
-       }
-
-       dump_info ();
-}
-
-static void __handle_headset_off (void)
-{
-       /* FIXME : Need to be removed volume seperation on public */
-       if (!IS_ACTIVE(MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY)) {
-               debug_warning("MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY was not active. nothing to do here.");
-               return;
-       }
-
-       /* if Headset was active, then do asm pause */
-       debug_msg("Do pause here");
-       _asm_pause_process (g_info.asm_handle);
-
-       /* set Headset device to none */
-       debug_msg("Deactivate WIRED IN/OUT device\n");
-       UNSET_ACTIVE(MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY);
-       UNSET_ACTIVE(MM_SOUND_DEVICE_IN_WIRED_ACCESSORY);
-
-       /* For call or voip session, activation device is up-to application policy */
-       if (IS_CALL_SESSION()) {
-               debug_warning ("Current session is VOICECALL or VIDEOCALL or VOIP, no auto-activation!!!\n");
-               return;
-       }
-
-       /* activate current available device based on priority */
-       __select_playback_active_device();
-       __select_capture_active_device();
-
-       /* Do set path and notify result */
-       __set_route(true, true);
-
-       /* DEACTIVATE AUDIOJACK */
-       MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_AUDIOJACK, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_DEACTIVATED, NULL);
-
-       dump_info ();
-}
-
-static void __handle_dock_on (void)
-{
-       /* ToDo : alarm/notification session ???? */
-       if (IS_CALL_SESSION()) {
-               debug_warning ("Current session is VOICECALL or VIDEOCALL or VOIP, no auto-activation!!!\n");
-               return;
-       }
-
-       debug_log ("Activate DOCK device\n");
-       SET_PLAYBACK_ONLY_ACTIVE(MM_SOUND_DEVICE_OUT_DOCK);
-
-       /* Do set path and notify result */
-       __set_route(true, true);
-
-       dump_info ();
-}
-
-static void __handle_dock_off (void)
-{
-       if (!IS_ACTIVE(MM_SOUND_DEVICE_OUT_DOCK)) {
-               debug_warning("MM_SOUND_DEVICE_OUT_DOCK was not active. nothing to do here.");
-               return;
-       }
-
-       /* if Dock was active, then do asm pause */
-       debug_msg("Do pause here");
-       _asm_pause_process (g_info.asm_handle);
-
-       /* set DOCK device to none */
-       debug_msg("Deactivate DOCK device\n");
-       UNSET_ACTIVE(MM_SOUND_DEVICE_OUT_DOCK);
-
-       /* activate current available device based on priority */
-       __select_playback_active_device();
-
-       /* Do set path and notify result */
-       __set_route(true, true);
-
-       dump_info ();
-}
-
-static void __handle_hdmi_on (void)
-{
-       /* ToDo : alarm/notification session ???? */
-       if (IS_CALL_SESSION()) {
-               debug_warning ("Current session is VOICECALL or VIDEOCALL or VOIP, no auto-activation!!!\n");
-               return;
-       }
-
-       debug_log ("Activate HDMI device\n");
-       SET_PLAYBACK_ONLY_ACTIVE(MM_SOUND_DEVICE_OUT_HDMI);
-
-       /* ACTIVATE HDMI */
-       MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_HDMI, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_ACTIVATED, NULL);
-       /* DEACTIVATE OTHERS */
-       __set_deactivate_all_device_auto (GET_ACTIVE_CAPTURE(), GET_ACTIVE_PLAYBACK());
-
-       /* Do set path and notify result */
-       __set_route(true, true);
-
-       dump_info ();
-}
-
-static void __handle_hdmi_off (void)
-{
-       if (!IS_ACTIVE(MM_SOUND_DEVICE_OUT_HDMI)) {
-               debug_warning("MM_SOUND_DEVICE_OUT_HDMI was not active. nothing to do here.");
-               return;
-       }
-
-       /* if HDMI was active, then do asm pause */
-       debug_msg("Do pause here");
-       _asm_pause_process (g_info.asm_handle);
-
-       MMSoundMgrPulseUnLoadHDMI();
-
-       /* set HDMI device to none */
-       debug_msg("Deactivate HDMI device\n");
-       UNSET_ACTIVE(MM_SOUND_DEVICE_OUT_HDMI);
-
-
-       /* DEACTIVATE HDMI */
-       MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_HDMI, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_DEACTIVATED, NULL);
-
-       /* activate current available device based on priority */
-       __select_playback_active_device();
-
-       /* Do set path and notify result */
-       __set_route(true, true);
-
-       dump_info ();
-}
-
-static void __handle_mirroring_on (void)
-{
-       /* ToDo : alarm/notification session ???? */
-       if (IS_CALL_SESSION()) {
-               debug_warning ("Current session is VOICECALL or VIDEOCALL or VOIP, no auto-activation!!!\n");
-               return;
-       }
-
-       debug_log ("Activate MIRRORING device\n");
-       SET_PLAYBACK_ONLY_ACTIVE(MM_SOUND_DEVICE_OUT_MIRRORING);
-
-       /* ACTIVATE MIRRORING */
-       MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_MIRRORING, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_ACTIVATED, NULL);
-       /* DEACTIVATE OTHERS */
-       __set_deactivate_all_device_auto (GET_ACTIVE_CAPTURE(), GET_ACTIVE_PLAYBACK());
-
-       /* Do set path and notify result */
-       __set_route(true, true);
-
-       dump_info ();
-}
-
-static void __handle_mirroring_off (void)
-{
-       if (!IS_ACTIVE(MM_SOUND_DEVICE_OUT_MIRRORING)) {
-               debug_warning("MM_SOUND_DEVICE_OUT_MIRRORING was not active. nothing to do here.");
-               return;
-       }
-
-       /* if MIRRORING was active, then do asm pause */
-       debug_msg("Do pause here");
-       _asm_pause_process (g_info.asm_handle);
-
-       /* set MIRRORING device to none */
-       debug_msg("Deactivate MIRRORING device\n");
-       UNSET_ACTIVE(MM_SOUND_DEVICE_OUT_MIRRORING);
-
-       /* DEACTIVATE MIRRORING */
-       MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_MIRRORING, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_DEACTIVATED, NULL);
-
-       /* activate current available device based on priority */
-       __select_playback_active_device();
-
-       /* Do set path and notify result */
-       __set_route(true, true);
-
-       dump_info ();
-}
-
-static void __handle_usb_audio_on (void)
-{
-       int ret = MM_ERROR_NONE;
-
-       if (IS_CALL_SESSION()) {
-               debug_warning ("Current session is VOICECALL or VIDEOCALL or VOIP, no auto-activation!!!\n");
-               return;
-       }
-
-       debug_log ("Activate USB Audio device\n");
-       SET_PLAYBACK_ONLY_ACTIVE(MM_SOUND_DEVICE_OUT_USB_AUDIO);
-
-       /* ACTIVATE USB_AUDIO */
-       MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_USB_AUDIO, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_ACTIVATED, NULL);
-       /* DEACTIVATE OTHERS */
-       __set_deactivate_all_device_auto (GET_ACTIVE_CAPTURE(), GET_ACTIVE_PLAYBACK());
-
-       /* For sharing device information with PulseAudio */
-       MMSoundMgrPulseSetActiveDevice(MM_SOUND_DEVICE_IN_NONE, GET_ACTIVE_PLAYBACK());
-
-       ret = _mm_sound_mgr_device_active_device_callback(GET_ACTIVE_CAPTURE(), GET_ACTIVE_PLAYBACK());
-       if (ret != MM_ERROR_NONE) {
-               debug_error ("_mm_sound_mgr_device_active_device_callback() failed [%x]\n", ret);
-       }
-
-       dump_info ();
-}
-
-static void __handle_usb_audio_off (void)
-{
-       if (!IS_ACTIVE(MM_SOUND_DEVICE_OUT_USB_AUDIO)) {
-               debug_warning("MM_SOUND_DEVICE_OUT_USB_AUDIO was not active. nothing to do here.");
-               dump_info ();
-               return;
-       }
-
-       /* if device was active, then do asm pause */
-       debug_msg("Do pause here");
-       _asm_pause_process (g_info.asm_handle);
-
-       /* set USB Audio device to none */
-       debug_msg("Deactivate USB Audio device\n");
-       UNSET_ACTIVE(MM_SOUND_DEVICE_OUT_USB_AUDIO);
-
-       /* DEACTIVATE USB_AUDIO */
-       MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, DEVICE_TYPE_USB_AUDIO, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_DEACTIVATED, NULL);
-
-       /* activate current available device based on priority */
-       __select_playback_active_device();
-
-       /* Do set path and notify result */
-       __set_route(true, true);
-
-       dump_info ();
-}
-
-static void __handle_multimedia_dock_on (void)
-{
-       if (IS_CALL_SESSION()) {
-               debug_warning ("Current session is VOICECALL or VIDEOCALL or VOIP, no auto-activation!!!\n");
-               return;
-       }
-
-       /* If HDMI has already been actived, we just skip active. */
-       if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_HDMI)) {
-               debug_warning ("HDMI device has been already actived. Just skip Multimedia Dock active action.\n");
-               return;
-       }
-
-       debug_log ("Activate Multimedia Dock device\n");
-       SET_PLAYBACK_ONLY_ACTIVE(MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK);
-
-       /* Do set path and notify result */
-       __set_route(true, true);
-
-       dump_info ();
-}
-
-static void __handle_multimedia_dock_off (void)
-{
-       if (!IS_ACTIVE(MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK)) {
-               debug_warning("MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK was not active. nothing to do here.");
-               dump_info ();
-               return;
-       }
-
-       /* if device was active, then do asm pause */
-       debug_msg("Do pause here");
-       _asm_pause_process (g_info.asm_handle);
-
-       /* set MultimediaDock device to none */
-       debug_msg("Deactivate Multimedia Dock device\n");
-       UNSET_ACTIVE(MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK);
-
-       /* activate current available device based on priority */
-       __select_playback_active_device();
-
-       /* Do set path and notify result */
-       __set_route(true, true);
-
-       dump_info ();
-}
-
-static const char* __get_session_string(session_t session)
-{
-       switch(session) {
-               case SESSION_MEDIA:
-                       return "MEDIA";
-               case SESSION_VOICECALL:
-                       return "VOICECALL";
-               case SESSION_VIDEOCALL:
-                       return "VIDEOCALL";
-               case SESSION_VOIP:
-                       return "VOIP";
-               case SESSION_FMRADIO:
-                       return "FMRADIO";
-               case SESSION_NOTIFICATION:
-                       return "NOTOFICATION";
-               case SESSION_ALARM:
-                       return "ALARM";
-               case SESSION_EMERGENCY:
-                       return "EMERGENCY";
-               case SESSION_VOICE_RECOGNITION:
-                       return "VOICE_RECOGNITION";
-               default:
-               return "unknow session";
-       }
-}
-
-static const char* __get_subsession_string(subsession_t session)
-{
-       switch(session) {
-               case SUBSESSION_VOICE:
-                       return "VOICECALL";
-               case SUBSESSION_RINGTONE:
-                       return "RINGTONE";
-               case SUBSESSION_MEDIA:
-                       return "MEDIA";
-               case SUBSESSION_INIT:
-                       return "SUBSESSION_INIT";
-               case SUBSESSION_VR_NORMAL:
-                       return "VR_NORMAL";
-               case SUBSESSION_VR_DRIVE:
-                       return "VR_DRIVE";
-               case SUBSESSION_RECORD_STEREO:
-                       return "RECORD_STEREO";
-               case SUBSESSION_RECORD_MONO:
-                       return "RECORD_MONO";
-               default:
-                       return "unknow subsession";
-       }
-}
-
-#ifdef TIZEN_MICRO
-static const char* __get_bt_bandwidth_string(int bandwidth)
-{
-    switch(bandwidth) {
-        case MM_SOUND_BANDWIDTH_UNKNOWN:
-            return "none. maybe bt is disconnected";
-        case MM_SOUND_BANDWIDTH_NB:
-            return "NB";
-        case MM_SOUND_BANDWIDTH_WB:
-            return "WB";
-        default:
-            return "unknow bandwidth";
-    }
-}
-
-static const char* __get_hfp_connection_state_string(int bandwidth)
-{
-    switch(bandwidth) {
-        case MM_SOUND_HFP_STATUS_UNKNOWN:
-            return "unknown";
-        case MM_SOUND_HFP_STATUS_INCOMMING_CALL:
-            return "HFP_INCOMMING_CALL:RINGTONE";
-        default:
-            return "unknow";
-    }
-}
-#endif
-
-static const char* __get_device_type_string(int device)
-{
-    switch(device) {
-        case DEVICE_BUILTIN:
-            return "builtin";
-        case DEVICE_WIRED:
-            return "wired";
-        case DEVICE_BT_A2DP:
-            return "bt-a2dp";
-        case DEVICE_BT_SCO:
-            return "bt-sco";
-        case DEVICE_DOCK:
-            return "dock";
-        case DEVICE_HDMI:
-            return "hdmi";
-        case DEVICE_MIRRORING:
-            return "mirroring";
-        case DEVICE_USB_AUDIO:
-            return "usb-audio";
-        case DEVICE_MULTIMEDIA_DOCK:
-            return "multimedia-dock";
-        default:
-            return "unknow device";
-    }
-}
-
-/* ------------------------- EXTERNAL FUNCTIONS ------------------------------------*/
-#ifdef TIZEN_MICRO
-int MMSoundMgrSessionMediaPause ()
-{
-       debug_msg ("[SESSION] Media pause requested...");
-       _asm_pause_process (g_info.asm_handle);
-
-       return MM_ERROR_NONE;
-}
-
-int MMSoundMgrSessionSetHFBandwidth (int bandwidth)
-{
-       debug_msg ("Set HF SCO bandwidth=(%s)", __get_bt_bandwidth_string(bandwidth));
-       g_info.bt_info.hf_wb = bandwidth;
-       return MM_ERROR_NONE;
-}
-
-int MMSoundMgrSessionSetHFPConnectionState (int stat)
-{
-       debug_msg ("Set HF SCO Stat=(%s)", __get_hfp_connection_state_string(stat));
-       g_info.bt_info.hfp_conn_state = stat;
-       return MM_ERROR_NONE;
-}
-#endif /* TIZEN_MICRO */
-
-int MMSoundMgrSessionEnableAgSCO (bool enable)
-{
-       debug_msg ("Set AG SCO enable=%d\n", enable);
-
-       if (enable) {
-               __handle_bt_sco_on();
-       } else {
-               __handle_bt_sco_off();
-       }
-       return MM_ERROR_NONE;
-}
-
-int MMSoundMgrSessionSetSCO (bool is_sco_on, bool is_bt_nrec, bool is_bt_wb)
-{
-       debug_msg ("[SESSION] Set SCO enable=%d, nrec=%d, wb=%d", is_sco_on, is_bt_nrec, is_bt_wb);
-       g_info.bt_info.is_nrec = (is_sco_on)? is_bt_nrec : false;
-       g_info.bt_info.is_wb = (is_sco_on)? is_bt_wb : false;
-
-       if (is_sco_on) {
-               __handle_bt_sco_on();
-       } else {
-               __handle_bt_sco_off();
-       }
-       return MM_ERROR_NONE;
-}
-
-/* DEVICE : Called by mgr_pulse for updating current default_sink_name */
-int MMSoundMgrSessionSetDefaultSink (const char * const default_sink_name)
-{
-       LOCK_SESSION();
-
-       MMSOUND_STRNCPY(g_info.default_sink_name, default_sink_name, MAX_STRING_LEN);
-
-       debug_msg ("[SESSION] default sink=[%s]\n", default_sink_name);
-
-       /* ToDo: do something */
-
-       UNLOCK_SESSION();
-
-       return MM_ERROR_NONE;
-}
-
-/* DEVICE : Called by mgr_pulse for bt and mgr_headset for headset */
-int MMSoundMgrSessionSetDeviceAvailable (device_type_t device, int available, int type, const char* name)
-{
-       LOCK_SESSION();
-
-       debug_warning ("[SESSION]set device available. device(%s), available(%d), type(%d), name(%s)\n",
-               __get_device_type_string(device), available, type, name != NULL ? name : "null");
-       switch (device) {
-       case DEVICE_WIRED:
-               if (available) {
-
-                       if (!IS_AVAILABLE(MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY)) {
-                               SET_AVAILABLE(MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY);
-                               /* available device & send available callback */
-                               if (type == DEVICE_EARJACK_TYPE_SPK_WITH_MIC) {
-                                       SET_AVAILABLE(MM_SOUND_DEVICE_IN_WIRED_ACCESSORY);
-                                       _mm_sound_mgr_device_available_device_callback(
-                                                                                       MM_SOUND_DEVICE_IN_WIRED_ACCESSORY,
-                                                                                       MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY,
-                                                                                       AVAILABLE);
-                               } else {
-                                       _mm_sound_mgr_device_available_device_callback(
-                                                                                       MM_SOUND_DEVICE_IN_NONE,
-                                                                                       MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY,
-                                                                                       AVAILABLE);
-                               }
-
-                               /* Store earphone type */
-                               g_info.headset_type = type;
-
-                               /* activate device & send activated callback */
-                               __handle_headset_on(type);
-                       } else {
-                               debug_log ("Already device [%d] is available...\n", device);
-                       }
-
-               } else {
-                       if (IS_AVAILABLE(MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY)) {
-
-                               /* unavailable earphone & earmic(if available)*/
-                               UNSET_AVAILABLE(MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY);
-                               if (g_info.headset_type == DEVICE_EARJACK_TYPE_SPK_WITH_MIC) {
-                                       UNSET_AVAILABLE(MM_SOUND_DEVICE_IN_WIRED_ACCESSORY);
-                               }
-                               /* Clear earphone type */
-                               g_info.headset_type = EARJACK_UNPLUGGED;
-
-                               /* unactivate device & send callback  */
-                               __handle_headset_off();
-
-                               /* Send unavailable callback */
-                               if (g_info.headset_type == DEVICE_EARJACK_TYPE_SPK_WITH_MIC) {
-                                       _mm_sound_mgr_device_available_device_callback(
-                                                                                       MM_SOUND_DEVICE_IN_WIRED_ACCESSORY,
-                                                                                       MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY,
-                                                                                       NOT_AVAILABLE);
-                               } else {
-                                       _mm_sound_mgr_device_available_device_callback(
-                                                                                       MM_SOUND_DEVICE_IN_NONE,
-                                                                                       MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY,
-                                                                                       NOT_AVAILABLE);
-                               }
-
-                       } else {
-                               debug_log ("Already device [%d] is unavailable...\n", device);
-                       }
-               }
-               break;
-
-       case DEVICE_BT_A2DP:
-               if (name)
-                       MMSOUND_STRNCPY(g_info.bt_info.name, name, MAX_STRING_LEN);
-               else
-                       memset(g_info.bt_info.name, 0, MAX_STRING_LEN);
-
-               if (available) {
-                       if (!IS_AVAILABLE(MM_SOUND_DEVICE_OUT_BT_A2DP)) {
-                               SET_AVAILABLE(MM_SOUND_DEVICE_OUT_BT_A2DP);
-                               _mm_sound_mgr_device_available_device_callback(
-                                                                                       MM_SOUND_DEVICE_IN_NONE,
-                                                                                       MM_SOUND_DEVICE_OUT_BT_A2DP,
-                                                                                       AVAILABLE);
-
-                               __handle_bt_a2dp_on();
-                       } else {
-                               debug_log ("Already device [%d] is available...\n", device);
-                       }
-               } else {
-                       if (IS_AVAILABLE(MM_SOUND_DEVICE_OUT_BT_A2DP)) {
-                               UNSET_AVAILABLE(MM_SOUND_DEVICE_OUT_BT_A2DP);
-                               __handle_bt_a2dp_off();
-                               _mm_sound_mgr_device_available_device_callback(
-                                                                                       MM_SOUND_DEVICE_IN_NONE,
-                                                                                       MM_SOUND_DEVICE_OUT_BT_A2DP,
-                                                                                       NOT_AVAILABLE);
-
-
-                       } else {
-                               debug_log ("Already device [%d] is unavailable...\n", device);
-                       }
-               }
-               break;
-
-       case DEVICE_BT_SCO:
-               if (available) {
-                       if (!IS_AVAILABLE(MM_SOUND_DEVICE_OUT_BT_SCO)) {
-                               SET_AVAILABLE(MM_SOUND_DEVICE_OUT_BT_SCO);
-                               SET_AVAILABLE(MM_SOUND_DEVICE_IN_BT_SCO);
-                               _mm_sound_mgr_device_available_device_callback(
-                                                                                       MM_SOUND_DEVICE_IN_BT_SCO,
-                                                                                       MM_SOUND_DEVICE_OUT_BT_SCO,
-                                                                                       AVAILABLE);
-                       } else {
-                               debug_log ("Already device [%d] is available...\n", device);
-                       }
-               } else {
-                       if (IS_AVAILABLE(MM_SOUND_DEVICE_OUT_BT_SCO)) {
-                               UNSET_AVAILABLE(MM_SOUND_DEVICE_OUT_BT_SCO);
-                               UNSET_AVAILABLE(MM_SOUND_DEVICE_IN_BT_SCO);
-                               __handle_bt_sco_off();
-                               _mm_sound_mgr_device_available_device_callback(
-                                                                                       MM_SOUND_DEVICE_IN_BT_SCO,
-                                                                                       MM_SOUND_DEVICE_OUT_BT_SCO,
-                                                                                       NOT_AVAILABLE);
-
-                       } else {
-                               debug_log ("Already device [%d] is unavailable...\n", device);
-                       }
-               }
-               break;
-
-       case DEVICE_DOCK:
-               if (available) {
-                       if (!IS_AVAILABLE(MM_SOUND_DEVICE_OUT_DOCK)) {
-                               SET_AVAILABLE(MM_SOUND_DEVICE_OUT_DOCK);
-                               _mm_sound_mgr_device_available_device_callback(
-                                                                                       MM_SOUND_DEVICE_IN_NONE,
-                                                                                       MM_SOUND_DEVICE_OUT_DOCK,
-                                                                                       AVAILABLE);
-                               __handle_dock_on();
-                       } else {
-                               debug_log ("Already device [%d] is available...\n", device);
-                       }
-               } else {
-                       if (IS_AVAILABLE(MM_SOUND_DEVICE_OUT_DOCK)) {
-                               UNSET_AVAILABLE(MM_SOUND_DEVICE_OUT_DOCK);
-                               __handle_dock_off();
-                               _mm_sound_mgr_device_available_device_callback(
-                                                                                       MM_SOUND_DEVICE_IN_NONE,
-                                                                                       MM_SOUND_DEVICE_OUT_DOCK,
-                                                                                       NOT_AVAILABLE);
-
-                       } else {
-                               debug_log ("Already device [%d] is unavailable...\n", device);
-                       }
-               }
-               break;
-
-       case DEVICE_HDMI:
-               if (available) {
-                       if (!IS_AVAILABLE(MM_SOUND_DEVICE_OUT_HDMI)) {
-                               SET_AVAILABLE(MM_SOUND_DEVICE_OUT_HDMI);
-                               _mm_sound_mgr_device_available_device_callback(
-                                                                                       MM_SOUND_DEVICE_IN_NONE,
-                                                                                       MM_SOUND_DEVICE_OUT_HDMI,
-                                                                                       AVAILABLE);
-                               __handle_hdmi_on();
-                       } else {
-                               debug_log ("Already device [%d] is available...\n", device);
-                       }
-               } else {
-                       if (IS_AVAILABLE(MM_SOUND_DEVICE_OUT_HDMI)) {
-                               UNSET_AVAILABLE(MM_SOUND_DEVICE_OUT_HDMI);
-                               __handle_hdmi_off();
-                               _mm_sound_mgr_device_available_device_callback(
-                                                                                       MM_SOUND_DEVICE_IN_NONE,
-                                                                                       MM_SOUND_DEVICE_OUT_HDMI,
-                                                                                       NOT_AVAILABLE);
-
-                       } else {
-                               debug_log ("Already device [%d] is unavailable...\n", device);
-                       }
-               }
-               break;
-
-       case DEVICE_MIRRORING:
-               if (available) {
-                       if (!IS_AVAILABLE(MM_SOUND_DEVICE_OUT_MIRRORING)) {
-                               SET_AVAILABLE(MM_SOUND_DEVICE_OUT_MIRRORING);
-                               _mm_sound_mgr_device_available_device_callback(
-                                                                                       MM_SOUND_DEVICE_IN_NONE,
-                                                                                       MM_SOUND_DEVICE_OUT_MIRRORING,
-                                                                                       AVAILABLE);
-                               __handle_mirroring_on();
-                       } else {
-                               debug_log ("Already device [%d] is available...\n", device);
-                       }
-               } else {
-                       if (IS_AVAILABLE(MM_SOUND_DEVICE_OUT_MIRRORING)) {
-                               UNSET_AVAILABLE(MM_SOUND_DEVICE_OUT_MIRRORING);
-                               __handle_mirroring_off();
-                               _mm_sound_mgr_device_available_device_callback(
-                                                                                       MM_SOUND_DEVICE_IN_NONE,
-                                                                                       MM_SOUND_DEVICE_OUT_MIRRORING,
-                                                                                       NOT_AVAILABLE);
-
-                       } else {
-                               debug_log ("Already device [%d] is unavailable...\n", device);
-                       }
-               }
-               break;
-
-       case DEVICE_USB_AUDIO:
-               if (available) {
-                       if (!IS_AVAILABLE(MM_SOUND_DEVICE_OUT_USB_AUDIO)) {
-                               SET_AVAILABLE(MM_SOUND_DEVICE_OUT_USB_AUDIO);
-                               _mm_sound_mgr_device_available_device_callback(
-                                                                                       MM_SOUND_DEVICE_IN_NONE,
-                                                                                       MM_SOUND_DEVICE_OUT_USB_AUDIO,
-                                                                                       AVAILABLE);
-                               __handle_usb_audio_on();
-                       } else {
-                               debug_log ("Already device [%d] is available...\n", device);
-                       }
-               } else {
-                       if (IS_AVAILABLE(MM_SOUND_DEVICE_OUT_USB_AUDIO)) {
-                               UNSET_AVAILABLE(MM_SOUND_DEVICE_OUT_USB_AUDIO);
-                               __handle_usb_audio_off();
-                               _mm_sound_mgr_device_available_device_callback(
-                                                                                       MM_SOUND_DEVICE_IN_NONE,
-                                                                                       MM_SOUND_DEVICE_OUT_USB_AUDIO,
-                                                                                       NOT_AVAILABLE);
-
-                       } else {
-                               debug_log ("Already device [%d] is unavailable...\n", device);
-                       }
-               }
-               break;
-       case DEVICE_MULTIMEDIA_DOCK:
-               if (available) {
-                       if (!IS_AVAILABLE(MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK)) {
-                               SET_AVAILABLE(MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK);
-                               _mm_sound_mgr_device_available_device_callback(
-                                               MM_SOUND_DEVICE_IN_NONE,
-                                               MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK,
-                                               AVAILABLE);
-                               __handle_multimedia_dock_on();
-                       } else {
-                               debug_log ("Already device [%d] is available...\n", device);
-                       }
-               } else {
-                       if (IS_AVAILABLE(MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK)) {
-                               UNSET_AVAILABLE(MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK);
-                               if (IS_AVAILABLE(MM_SOUND_DEVICE_OUT_USB_AUDIO)) {
-                                       UNSET_AVAILABLE(MM_SOUND_DEVICE_OUT_USB_AUDIO);
-                               }
-                               __handle_multimedia_dock_off();
-                               _mm_sound_mgr_device_available_device_callback(
-                                               MM_SOUND_DEVICE_IN_NONE,
-                                               MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK,
-                                               NOT_AVAILABLE);
-
-                       } else {
-                               debug_log ("Already device [%d] is unavailable...\n", device);
-                       }
-               }
-               break;
-
-       default:
-               debug_warning ("device [%d] is not handled...\n", device);
-               break;
-       }
-
-       UNLOCK_SESSION();
-
-       return MM_ERROR_NONE;
-}
-
-int MMSoundMgrSessionIsDeviceAvailableNoLock (mm_sound_device_out playback, mm_sound_device_in capture, bool *available)
-{
-       int ret = MM_ERROR_NONE;
-       debug_log ("[SESSION] query playback=[0x%X] capture=[0x%X], current available = [0x%X]\n",
-                       playback, capture, g_info.device_available);
-
-       if (available) {
-               if (playback == MM_SOUND_DEVICE_OUT_NONE) {
-                       *available = IS_AVAILABLE(capture);
-               } else if (capture == MM_SOUND_DEVICE_IN_NONE) {
-                       *available = IS_AVAILABLE(playback);
-               } else {
-                       *available = (IS_AVAILABLE(playback) && IS_AVAILABLE(capture));
-               }
-               debug_log ("return available = [%d]\n", *available);
-       } else {
-               debug_warning ("Invalid argument!!!\n");
-               ret = MM_ERROR_INVALID_ARGUMENT;
-       }
-
-       return ret;
-}
-
-
-int MMSoundMgrSessionIsDeviceAvailable (mm_sound_device_out playback, mm_sound_device_in capture, bool *available)
-{
-       int ret = MM_ERROR_NONE;
-
-       LOCK_SESSION();
-       ret = MMSoundMgrSessionIsDeviceAvailableNoLock (playback, capture, available);
-       UNLOCK_SESSION();
-
-       return ret;
-}
-
-int MMSoundMgrSessionGetAvailableDevices (int *playback, int *capture)
-{
-       if (playback == NULL || capture == NULL) {
-               debug_error ("Invalid input parameter\n");
-               return MM_ERROR_INVALID_ARGUMENT;
-       }
-
-       LOCK_SESSION();
-
-       *playback = GET_AVAILABLE_PLAYBACK();
-       *capture  = GET_AVAILABLE_CAPTURE();
-       debug_msg ("[SESSION] return available playback=[0x%X]/capture=[0x%X]\n",  *playback, *capture);
-
-       UNLOCK_SESSION();
-
-       return MM_ERROR_NONE;
-}
-
-int MMSoundMgrSessionSetDeviceActive (mm_sound_device_out playback, mm_sound_device_in capture, bool need_broadcast)
-{
-       int ret = MM_ERROR_NONE;
-       int old_active = g_info.device_active;
-       bool need_update = false;
-       bool need_cork = true;
-       LOCK_SESSION();
-
-       debug_warning ("[SESSION] playback=[0x%X] capture=[0x%X]\n", playback, capture);
-
-       /* Check whether device is available */
-       if ((playback && !IS_AVAILABLE(playback)) || (capture && !IS_AVAILABLE(capture))) {
-               debug_warning ("Failed to set active state to unavailable device!!!\n");
-               ret = MM_ERROR_INVALID_ARGUMENT;
-               goto END_SET_DEVICE;
-       }
-
-       LOCK_PATH();
-       /* Update active state */
-       debug_log ("Update active device as request\n");
-       if (playback) {
-               int d_ret = MM_ERROR_NONE;
-               device_type_e device;
-
-               SET_PLAYBACK_ONLY_ACTIVE(playback);
-
-               d_ret = __get_device_type_from_old_device(playback, &device);
-               if(d_ret) {
-                       debug_warning ("Failed to __get_device_type_from_old_device\n");
-               } else {
-                       /* ACTIVATE device */
-                       MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, device, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_ACTIVATED, NULL);
-               }
-       }
-       if (capture) {
-               int d_ret = MM_ERROR_NONE;
-               device_type_e device;
-               SET_CAPTURE_ONLY_ACTIVE(capture);
-
-               d_ret = __get_device_type_from_old_device(capture, &device);
-               if(d_ret) {
-                       debug_warning ("Failed to __get_device_type_from_old_device\n");
-               } else {
-                       /* ACTIVATE device */
-                       MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_STATE, device, 0, DEVICE_ID_AUTO, NULL, DEVICE_STATE_ACTIVATED, NULL);
-               }
-       }
-       /* DEACTIVATE OTHERS */
-       __set_deactivate_all_device_auto (GET_ACTIVE_CAPTURE(), GET_ACTIVE_PLAYBACK());
-
-       if (((g_info.session == SESSION_VOICECALL) || (g_info.session == SESSION_VIDEOCALL))) {
-               bool is_wb, is_nrec;
-#ifndef _TIZEN_PUBLIC_
-#ifndef TIZEN_MICRO
-               bool is_noise_reduction, is_extra_volume, is_upscaling_needed;
-               is_noise_reduction = __is_noise_reduction_on();
-               is_extra_volume = __is_extra_volume_on();
-               is_upscaling_needed = __is_upscaling_needed();
-               if ((g_info.is_noise_reduction != is_noise_reduction)
-                       || (g_info.is_extra_volume != is_extra_volume)
-                       || (g_info.is_upscaling_needed != is_upscaling_needed)) {
-                       need_update = true;
-               }
-               g_info.is_noise_reduction = is_noise_reduction;
-               g_info.is_extra_volume = is_extra_volume;
-               g_info.is_upscaling_needed = is_upscaling_needed;
-#endif /* TIZEN_MICRO */
-#endif
-#ifdef SUPPORT_BT_SCO
-               /* FIXME : Check all BT SCO */
-               if (playback == MM_SOUND_DEVICE_OUT_BT_SCO && capture == MM_SOUND_DEVICE_IN_BT_SCO) {
-                       is_wb = MMSoundMgrPulseBTSCOWBStatus();
-                       is_nrec = MMSoundMgrPulseBTSCONRECStatus();
-                       if ((g_info.bt_info.is_nrec != is_nrec) || (g_info.bt_info.is_wb != is_wb)) {
-                               g_info.bt_info.is_wb = is_wb;
-                               g_info.bt_info.is_nrec = is_nrec;
-                               need_update = true;
-                       }
-               }
-#endif /* SUPPORT_BT_SCO */
-               /* NOT need to cork during voice call */
-               need_cork = false;
-       }
-       UNLOCK_PATH();
-
-       /* If there's changes do path set and inform callback */
-       if (old_active != g_info.device_active || need_update == true) {
-               debug_msg ("Changes happens....set path based on current active device and inform callback(%d)!!!\n", need_broadcast);
-
-               /* Do set path based on current active state */
-               __set_route(need_broadcast, need_cork);
-       } else {
-               debug_msg ("No changes....nothing to do...\n");
-       }
-
-END_SET_DEVICE:
-       UNLOCK_SESSION();
-       return ret;
-}
-
-int MMSoundMgrSessionSetDeviceActiveAuto (void)
-{
-       int ret = MM_ERROR_NONE;
-
-       /* activate current available device based on priority */
-       __select_playback_active_device();
-       __select_capture_active_device();
-       /* Do set path and notify result */
-       ret = __set_route(true, true);
-       if (ret != MM_ERROR_NONE) {
-               debug_error("fail to MMSoundMgrSessionSetDeviceActiveAuto.\n");
-       } else {
-               debug_msg ("success : MMSoundMgrSessionSetDeviceActiveAuto\n");
-       }
-       return ret;
-}
-
-int MMSoundMgrSessionGetDeviceActive (mm_sound_device_out *playback, mm_sound_device_in *capture)
-{
-       if (playback == NULL || capture == NULL) {
-               debug_error ("Invalid input parameter\n");
-               return MM_ERROR_INVALID_ARGUMENT;
-       }
-
-       LOCK_SESSION();
-
-       *playback = GET_ACTIVE_PLAYBACK();
-       *capture  = GET_ACTIVE_CAPTURE();
-       debug_msg ("[SESSION] return active playback=[0x%X]/capture=[0x%X]\n", *playback,*capture);
-
-       UNLOCK_SESSION();
-       return MM_ERROR_NONE;
-}
-
-int MMSoundMgrSessionGetAudioPath (mm_sound_device_out *playback, mm_sound_device_in *capture)
-{
-       if (playback == NULL || capture == NULL) {
-               debug_error ("Invalid input parameter\n");
-               return MM_ERROR_INVALID_ARGUMENT;
-       }
-
-       LOCK_SESSION();
-       MMSoundMgrPulseGetPathInfo(playback, capture);
-       debug_msg ("[SESSION] return current audio path which is set to ALSA . playback=[0x%X]/capture=[0x%X]\n", *playback,*capture);
-
-       UNLOCK_SESSION();
-       return MM_ERROR_NONE;
-}
-
-/* SUBSESSION */
-int MMSoundMgrSessionSetSession(session_t session, session_state_t state)
-{
-       LOCK_SESSION();
-
-       debug_warning ("[SESSION] session=[%s] state=[%s]\n", __get_session_string(session), state==SESSION_START ? "start" : "end");
-
-       /* Update Enable session */
-       if (state) {
-               g_info.session = session;
-       } else {
-               g_info.session = SESSION_MEDIA;
-               g_info.subsession = SUBSESSION_VOICE; /* initialize subsession */
-       }
-
-       MMSoundMgrPulseSetSession(session, state);
-
-       /* Do action based on new session */
-       switch (session) {
-       case SESSION_MEDIA:
-               __set_playback_route_media (state);
-               break;
-
-       case SESSION_VOICECALL:
-       case SESSION_VIDEOCALL:
-               __set_playback_route_call (state);
-               break;
-       case SESSION_VOIP:
-               __set_playback_route_voip (state);
-               break;
-
-       case SESSION_FMRADIO:
-               __set_playback_route_fmradio (state);
-               break;
-
-       case SESSION_NOTIFICATION:
-               __set_playback_route_notification (state);
-               break;
-
-       case SESSION_ALARM:
-               __set_playback_route_alarm (state);
-               break;
-
-       case SESSION_EMERGENCY:
-               __set_playback_route_emergency (state);
-               break;
-
-       case SESSION_VOICE_RECOGNITION:
-               __set_playback_route_voicerecognition (state);
-               break;
-
-       default:
-               debug_warning ("session [%s] is not handled...\n", __get_session_string(session));
-               break;
-       }
-
-       UNLOCK_SESSION();
-       return MM_ERROR_NONE;
-}
-
-int MMSoundMgrSessionGetSession(session_t *session)
-{
-       if (session == NULL) {
-               debug_error ("Invalid input parameter\n");
-               return MM_ERROR_INVALID_ARGUMENT;
-       }
-
-       /* LOCK_SESSION(); */
-       *session = g_info.session;
-       /* UNLOCK_SESSION(); */
-
-       return MM_ERROR_NONE;
-}
-
-const char* MMSoundMgrSessionGetSessionString(session_t session)
-{
-    return __get_session_string(session);
-}
-#ifdef TIZEN_MICRO
-int MMSoundMgrSessionSetDuplicateSubSession()
-{
-       /* This function is for set sub session duplicate
-               When BT wb/nb is changed, the call application cannot set
-               normal alsa scenario.
-               Because call app is set sub session before BT band is decided.
-               (Actually BT frw can know the band after SCO request
-               from phone)
-
-               Ref. mm_sound_mgr_pulse.c _bt_hf_cb function.
-       */
-
-       int ret = 0;
-       debug_msg ("Duplicated path control");
-
-       LOCK_SESSION();
-
-       ret = __set_route(false, false);
-       if(ret != MM_ERROR_NONE)
-               debug_warning("Fail to set route");
-
-       UNLOCK_SESSION();
-       return MM_ERROR_NONE;
-}
-#endif
-
-/* SUBSESSION */
-int MMSoundMgrSessionSetSubSession(subsession_t subsession, int subsession_opt)
-{
-       bool need_update = false;
-       bool need_cork = false;
-       static subsession_t prev_subsession = SUBSESSION_VOICE; /* Initialize subsession */
-       bool set_route_flag = true;
-       int sub_session_opt = 0;
-       LOCK_SESSION();
-
-       if (g_info.subsession == subsession) {
-               debug_warning ("[SESSION] already subsession is [%s]. skip this!!\n", __get_subsession_string(subsession));
-       } else {
-               MMSoundMgrPulseSetSubsession(subsession, subsession_opt);
-               g_info.subsession = subsession;
-               need_update = true;
-       }
-
-       /* FIXME : Need to check with private */
-       /* FIXME : Need to check with private */
-       /* FIXME : Need to check with private */        
-       switch(subsession) {
-#ifdef TIZEN_MICRO
-               // FIXME: we got timing issue between music and player and sound_server
-               case SUBSESSION_VOICE:
-               case SUBSESSION_RINGTONE:
-                       debug_msg("session(%s), subsession(%s). sound path will change to spk/mic",
-                               __get_session_string(g_info.session), __get_subsession_string(subsession));
-                       SET_PLAYBACK_ONLY_ACTIVE(MM_SOUND_DEVICE_OUT_SPEAKER);
-                       SET_CAPTURE_ONLY_ACTIVE(MM_SOUND_DEVICE_IN_MIC);
-                       need_update = true;
-                       /* suspend ALSA devices when starting call */
-                       if (subsession != SUBSESSION_RINGTONE) {
-                               need_cork |= true;
-                       }
-                       dump_info();
-                       break;
-#endif /* TIZEN_MICRO */
-               case SUBSESSION_VR_NORMAL:
-               case SUBSESSION_VR_DRIVE:
-                       if(g_info.option != subsession_opt) {
-                               g_info.option = subsession_opt;
-                               need_update = true;
-                       }
-                       break;
-               default:
-                       if (g_info.option != subsession_opt) {
-                               g_info.option = MM_SUBSESSION_OPTION_NONE;
-                               need_update = true;
-                       }
-                       break;
-       }
-       if (g_info.subsession == SUBSESSION_VOICE) {
-#ifdef SUPPORT_BT_SCO
-               if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_BT_SCO) && IS_ACTIVE(MM_SOUND_DEVICE_IN_BT_SCO)) {
-                       /* Update BT info */
-                       /* Remove BT dependency */
-                       /* MMSoundMgrPulseUpdateBluetoothAGCodec(); */
-               }
-#endif
-       }
-       
-       if (need_update) {
-               debug_warning ("[SESSION] subsession=[%s], resource=[%d]\n", __get_subsession_string(g_info.subsession), g_info.option);
-               __set_route(true, need_cork);
-       }
-       UNLOCK_SESSION();
-
-       return MM_ERROR_NONE;
-}
-
-int MMSoundMgrSessionGetSubSession(subsession_t *subsession)
-{
-       if (subsession == NULL) {
-               debug_error ("Invalid input parameter\n");
-               return MM_ERROR_INVALID_ARGUMENT;
-       }
-
-       LOCK_SESSION();
-
-       *subsession = g_info.subsession;
-
-       UNLOCK_SESSION();
-
-       return MM_ERROR_NONE;
-}
-
-const char* MMSoundMgrSessionGetSubSessionString(subsession_t subsession)
-{
-    return __get_subsession_string(subsession);
-}
-
-
-char* MMSoundMgrSessionGetBtA2DPName ()
-{
-       return g_info.bt_info.name;
-}
-
-void MMSoundMgrSessionSetVoiceControlState (bool enable)
-{
-       int ret = MM_ERROR_NONE;
-       LOCK_SESSION();
-       g_info.is_voicecontrol = enable;
-       /* FIXME : Check whether need to set state to pulse, need to check with private */
-       /* MMSoundMgrPulseSetVoicecontrolState(enable); */
-
-       debug_warning("MMSoundMgrSessionSetVoiceControlState --------g_info.session = %s,g_info.subsession = %s ",
-               __get_session_string(g_info.session), __get_subsession_string(g_info.subsession));
-       if (IS_CALL_SESSION() && g_info.subsession == SUBSESSION_VOICE) {
-               debug_warning("already voice subsession in voice session");
-               return;
-       }
-
-       ret = __set_sound_path_for_voicecontrol();
-       UNLOCK_SESSION();
-       if (ret != MM_ERROR_NONE) {
-               debug_error ("__set_sound_path_for_voicecontrol() failed [%x]\n", ret);
-               return;
-       }
-
-}
-
-bool MMSoundMgrSessionGetVoiceControlState ()
-{
-       return g_info.is_voicecontrol;
-}
-
-#ifndef _TIZEN_PUBLIC_
-#ifndef TIZEN_MICRO
-/* -------------------------------- NOISE REDUCTION --------------------------------------------*/
-static bool __is_noise_reduction_on (void)
-{
-       int noise_reduction_on = 0;
-
-       return (noise_reduction_on == 1) ? true : false;
-}
-
-/* -------------------------------- EXTRA VOLUME --------------------------------------------*/
-static bool __is_extra_volume_on (void)
-{
-       int extra_volume_on = 0;
-
-       return (extra_volume_on  == 1) ? true : false;
-}
-#endif
-
-/* -------------------------------- UPSCALING --------------------------------------------*/
-static bool __is_upscaling_needed (void)
-{
-       int is_wbamr = 0;
-
-       return (is_wbamr == 0) ? true : false;
-}
-/* -------------------------------- BT NREC --------------------------------------------*/
-static bool __get_bt_nrec_status(void)
-{
-       debug_msg ("get bt nrec status.(%s)\n", g_info.bt_info.is_nrec==true ? "ON" : "OFF");
-       return g_info.bt_info.is_nrec;
-}
-
-#ifdef TIZEN_MICRO
-static int __get_ag_wb_status(void)
-{
-       debug_msg ("get ag wb status.(%s)\n", __get_bt_bandwidth_string(g_info.bt_info.ag_wb));
-       return g_info.bt_info.ag_wb;
-}
-
-static int __get_hf_wb_status(void)
-{
-       debug_msg ("get hf wb status.(%s)\n", __get_bt_bandwidth_string(g_info.bt_info.hf_wb));
-       return g_info.bt_info.hf_wb;
-}
-
-static int __get_hf_connection_state(void)
-{
-    debug_msg ("Set HF SCO connection state(%s)", __get_hfp_connection_state_string(g_info.bt_info.hfp_conn_state));
-    return g_info.bt_info.hfp_conn_state;
-}
-
-/* ------------------------------- RIGHT HAND ------------------------------------------*/
-static bool __is_right_hand_on (void)
-{
-       int is_right_hand = 0;
-       if (vconf_get_bool(VCONF_KEY_VR_LEFTHAND_ENABLED, &is_right_hand)) {
-               debug_warning("vconf_get_bool for %s failed\n", VCONF_KEY_VR_LEFTHAND_ENABLED);
-       }
-       debug_msg("is_right_hand : %d",is_right_hand);
-       return (is_right_hand == 0) ? true : false;
-}
-#endif /* TIZEN_MICRO */
-#endif /* _TIZEN_PUBLIC_ */
-#ifdef TIZEN_MICRO
-static void __media_pause_by_call (void)
-{
-       int asm_error = 0;
-       int asm_status = 0;
-       int handle = -1;
-
-       debug_msg ("[SESSION] Media pause requested by call dbus ...");
-       MMSOUND_ENTER_CRITICAL_SECTION( &_asm_mutex )
-
-       if (vconf_get_int(SOUND_STATUS_KEY, &asm_status)) {
-               debug_error(" vconf_set_int fail\n");
-       }
-
-       if ((asm_status & ~(ASM_STATUS_CALL|ASM_STATUS_NOTIFY|ASM_STATUS_ALARM|ASM_STATUS_EXCLUSIVE_RESOURCE))> 0) {
-               /* Do Pause for call dbus event */
-               debug_warning("Change state to pause by call dbus");
-
-               if (!ASM_register_sound_ex (-1, &handle, ASM_EVENT_CALL, ASM_STATE_NONE, NULL, NULL, ASM_RESOURCE_NONE, &asm_error, __asm_process_message)) {
-                       debug_warning("Call event register failed with 0x%x", asm_error);
-                       MMSOUND_LEAVE_CRITICAL_SECTION( &_asm_mutex )
-                       return;
-               }
-
-               if (!ASM_set_sound_state_ex(handle, ASM_EVENT_CALL, ASM_STATE_PLAYING, ASM_RESOURCE_NONE, &asm_error, __asm_process_message)) {
-                       debug_error("Call event set sound state to playing failed with 0x%x\n", asm_error);
-               }
-
-               if (!ASM_set_sound_state_ex(handle, ASM_EVENT_CALL, ASM_STATE_STOP, ASM_RESOURCE_NONE, &asm_error, __asm_process_message)) {
-                       debug_error("Call event set sound state to stop failed with 0x%x", asm_error);
-               }
-
-               if (!ASM_unregister_sound_ex(handle, ASM_EVENT_CALL, &asm_error, __asm_process_message)) {
-                       debug_error("Call event unregister failed with 0x%x\n", asm_error);
-                       MMSOUND_LEAVE_CRITICAL_SECTION( &_asm_mutex )
-                       return;
-               }
-
-       } else {
-               debug_msg("no need to pause others");
-       }
-
-       MMSOUND_LEAVE_CRITICAL_SECTION( &_asm_mutex )
-       /* End of change of session state */
-
-       return;
-}
-static void __call_status_changed(GDBusConnection *conn,
-                                                          const gchar *sender_name,
-                                                          const gchar *object_path,
-                                                          const gchar *interface_name,
-                                                          const gchar *signal_name,
-                                                          GVariant *parameters,
-                                                          gpointer user_data)
-{
-       int value=0;
-       const GVariantType* value_type;
-
-       debug_msg ("sender : %s, object : %s, interface : %s, signal : %s",
-                       sender_name, object_path, interface_name, signal_name);
-       if(g_variant_is_of_type(parameters, G_VARIANT_TYPE("(i)")))
-       {
-               g_variant_get(parameters, "(i)",&value);
-               debug_msg("singal[%s] = %X", signal_name, value);
-               if(value==MM_SOUND_CALL_STATUS_PAUSE)
-               {
-                       __media_pause_by_call();
-               }
-       }
-       else
-       {
-               value_type = g_variant_get_type(parameters);
-               debug_warning("signal type is %s", value_type);
-       }
-
-}
-
-void _deinit_call_status_dbus(void)
-{
-       debug_fenter ();
-       g_dbus_connection_signal_unsubscribe(conn_callstatus, sig_id_callstatus);
-       g_object_unref(conn_callstatus);
-       debug_fleave ();
-}
-
-int _init_call_status_dbus(void)
-{
-       GError *err = NULL;
-       debug_fenter ();
-
-       g_type_init();
-
-       conn_callstatus = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
-       if (!conn_callstatus && err) {
-               debug_error ("g_bus_get_sync() error (%s) ", err->message);
-               g_error_free (err);
-               goto error;
-       }
-
-       sig_id_callstatus = g_dbus_connection_signal_subscribe(conn_callstatus,
-                       NULL, DBUS_CALL_STATUS_INTERFACE, DBUS_CALL_STATUS_CHANGED_SIGNAL, DBUS_CALL_STATUS_PATH, NULL, 0,
-                       __call_status_changed, NULL, NULL);
-       if (sig_id_callstatus < 0) {
-               debug_error ("g_dbus_connection_signal_subscribe() error (%d)", sig_id_callstatus);
-               goto sig_error;
-       }
-
-       debug_fleave ();
-       return 0;
-
-sig_error:
-       g_dbus_connection_signal_unsubscribe(conn_callstatus, sig_id_callstatus);
-       g_object_unref(conn_callstatus);
-
-error:
-       return -1;
-
-}
-#endif /* TIZEN_MICRO */
-int MMSoundMgrSessionInit(void)
-{
-       LOCK_SESSION();
-
-       debug_fenter();
-
-       memset (&g_info, 0, sizeof (SESSION_INFO_STRUCT));
-
-       /* FIXME: Initial status should be updated */
-       __set_initial_active_device ();
-
-       /* Register for headset unplug */
-       if (_asm_register_for_headset (&g_info.asm_handle) == false) {
-               debug_error ("Failed to register ASM for headset\n");
-       }
-#ifdef TIZEN_MICRO
-       if (_init_call_status_dbus() != 0) {
-               debug_error ("Registering call status signal handler failed\n");
-       }
-#endif
-
-       debug_fleave();
-
-       UNLOCK_SESSION();
-       return MM_ERROR_NONE;
-}
-
-int MMSoundMgrSessionFini(void)
-{
-       LOCK_SESSION();
-
-       debug_fenter();
-
-       /* Unregister for headset unplug */
-       _asm_unregister_for_headset (&g_info.asm_handle);
-
-       debug_fleave();
-
-       UNLOCK_SESSION();
-
-       return MM_ERROR_NONE;
-}
-#endif
-
index 6074ebe..00465c5 100644 (file)
 #include "include/mm_sound_mgr_codec.h"
 #include "include/mm_sound_mgr_ipc.h"
 #include "include/mm_sound_mgr_ipc_dbus.h"
-//#include "include/mm_sound_mgr_pulse.h"
 #include "include/mm_sound_mgr_asm.h"
-//#include "include/mm_sound_mgr_session.h"
-//#include "include/mm_sound_mgr_device.h"
-//#include "include/mm_sound_mgr_device_headset.h"
-//#include "include/mm_sound_mgr_device_dock.h"
-//#include "include/mm_sound_mgr_device_hdmi.h"
-//#include "include/mm_sound_mgr_device_wfd.h"
 #include <audio-session-manager.h>
 
 #include <glib.h>
 
 #define PLUGIN_ENV "MM_SOUND_PLUGIN_PATH"
 #define PLUGIN_MAX 30
+#define MAX_PLUGIN_DIR_PATH_LEN        256
 
-#define HIBERNATION_SOUND_CHECK_PATH   "/tmp/hibernation/sound_ready"
 #define USE_SYSTEM_SERVER_PROCESS_MONITORING
 
-#define VCONFKEY_CHECK_INTERVAL        10000
-
-#define MAX_PLUGIN_DIR_PATH_LEN        256
-
 typedef struct {
     char plugdir[MAX_PLUGIN_DIR_PATH_LEN];
     int startserver;
     int printlist;
     int testmode;
-    int poweroff;
-    int soundreset;
 } server_arg;
 
-static char *str_errormsg[] = {
-    "Operation is success.",
-    "Handle Init Fail",
-    "Path Init Fail",
-    "Handle Fini Fail",
-    "Path Fini Fail",
-    "Handle Reset Fail",
-    "Path Reset Fail",
-    "Handle Dump Fail",
-    "Path Dump Fail",
-    "Sync Dump Fail",
-};
-
 static int getOption(int argc, char **argv, server_arg *arg);
-static int usgae(int argc, char **argv);
+static int _usage(int argc, char **argv);
 
 static struct sigaction sigint_action;  /* Backup pointer of SIGINT handler */
 static struct sigaction sigabrt_action; /* Backup pointer of SIGABRT signal handler */
@@ -106,42 +80,15 @@ static void _exit_handler(int sig);
 
 GMainLoop *g_mainloop;
 
-void* pulse_handle;
-
-void mainloop_run()
+static void _mainloop_run()
 {
        g_mainloop = g_main_loop_new(NULL, TRUE);
-       if(g_mainloop == NULL) {
+       if (g_mainloop == NULL) {
                debug_error("g_main_loop_new() failed\n");
        }
        g_main_loop_run(g_mainloop);
 }
 
-static int _handle_power_off ()
-{
-       debug_warning ("not supported\n");
-       return 0;
-}
-
-static int _handle_sound_reset ()
-{
-       debug_warning ("not supported\n");
-       return 0;
-}
-
-static void _pa_disconnect_cb (void *user_data)
-{
-       debug_warning ("g_mainloop = %p, user_data = %p", g_mainloop, user_data);
-
-       if (pulse_handle) {
-               free(pulse_handle);
-               pulse_handle = NULL;
-       }
-
-       if (g_mainloop)
-               g_main_loop_quit(g_mainloop);
-}
-
 static sem_t* sem_create_n_wait()
 {
        sem_t* sem = NULL;
@@ -160,10 +107,6 @@ int main(int argc, char **argv)
        sem_t* sem = NULL;
        server_arg serveropt;
        struct sigaction action;
-#ifdef USE_HIBERNATION
-       int heynotifd = -1;
-#endif
-       int volumes[VOLUME_TYPE_MAX] = {0, };
 #if !defined(USE_SYSTEM_SERVER_PROCESS_MONITORING)
        int pid;
 #endif
@@ -186,23 +129,6 @@ int main(int argc, char **argv)
                daemon(0,0); //chdir to ("/"), and close stdio
 #endif
        }
-       if (serveropt.poweroff) {
-               if (_handle_power_off() == 0) {
-                       debug_log("_handle_power_off success!!\n");
-               } else {
-                       debug_error("_handle_power_off failed..\n");
-               }
-               return 0;
-       }
-
-       if (serveropt.soundreset) {
-               if (_handle_sound_reset() == 0) {
-                       debug_log("_handle_sound_reset success!!\n");
-               } else {
-                       debug_error("_handle_sound_reset failed..\n");
-               }
-               return 0;
-       }
 
        /* Sound Server Starts!!!*/
        debug_warning("sound_server [%d] start \n", getpid());
@@ -238,17 +164,8 @@ int main(int argc, char **argv)
                MMSoundThreadPoolInit();
                MMSoundMgrRunInit(serveropt.plugdir);
                MMSoundMgrCodecInit(serveropt.plugdir);
-
                MMSoundMgrDbusInit();
-
-//             pulse_handle = MMSoundMgrPulseInit(_pa_disconnect_cb, g_mainloop);
                MMSoundMgrASMInit();
-//             _mm_sound_mgr_device_init();
-//             MMSoundMgrHeadsetInit();
-//             MMSoundMgrDockInit();
-//             MMSoundMgrHdmiInit();
-//             MMSoundMgrWfdInit();
-//             MMSoundMgrSessionInit();
        }
 
        debug_warning("sound_server [%d] initialization complete...now, start running!!\n", getpid());
@@ -266,9 +183,9 @@ int main(int argc, char **argv)
                                debug_msg ("Ready to play booting sound!!!!");
                        }
                }
-               /* Start Ipc mgr */
 
-               mainloop_run();
+               /* Start MainLoop */
+               _mainloop_run();
        }
 
        debug_warning("sound_server [%d] terminating \n", getpid());
@@ -280,20 +197,7 @@ int main(int argc, char **argv)
                MMSoundMgrRunFini();
                MMSoundThreadPoolFini();
 
-//             MMSoundMgrWfdFini();
-//             MMSoundMgrHdmiFini();
-//             MMSoundMgrDockFini();
-//             MMSoundMgrHeadsetFini();
-//             MMSoundMgrSessionFini();
-//             _mm_sound_mgr_device_fini();
                MMSoundMgrASMFini();
-//             MMSoundMgrPulseFini(pulse_handle);
-#ifdef USE_HIBERNATION
-               if(heynoti_unsubscribe(heynotifd, "HIBERNATION_LEAVE", NULL)) {
-                       debug_error("heynoti_unsubscribe failed..\n");
-               }
-               heynoti_close(heynotifd);
-#endif
        }
 
        debug_warning("sound_server [%d] exit ----------------- END \n", getpid());
@@ -307,8 +211,6 @@ static int getOption(int argc, char **argv, server_arg *arg)
        char *plugin_env_dir = NULL;
        static struct option long_options[] = {
                {"start", 0, 0, 'S'},
-               {"poweroff", 0, 0, 'F'},
-               {"soundreset", 0, 0, 'R'},
                {"list", 0, 0, 'L'},
                {"help", 0, 0, 'H'},
                {"plugdir", 1, 0, 'P'},
@@ -338,12 +240,6 @@ static int getOption(int argc, char **argv, server_arg *arg)
                case 'S': /* Start daemon */
                        arg->startserver = 1;
                        break;
-               case 'F': /* Poweroff */
-                       arg->poweroff = 1;
-                       break;
-               case 'R': /* SoundReset */
-                       arg->soundreset = 1;
-                       break;
                case 'L': /* list of plugins */
                        arg->printlist = 1;
                        break;
@@ -355,11 +251,11 @@ static int getOption(int argc, char **argv, server_arg *arg)
                        break;
                case 'H': /* help msg */
                default:
-               return usgae(argc, argv);
+               return _usage(argc, argv);
                }
        }
        if (argc == 1)
-               return usgae(argc, argv);
+               return _usage(argc, argv);
        return 0;
 }
 
@@ -367,7 +263,7 @@ static int getOption(int argc, char **argv, server_arg *arg)
 static void _exit_handler(int sig)
 {
        int ret = MM_ERROR_NONE;
-       
+
        ret = MMSoundMgrRunStopAll();
        if (ret != MM_ERROR_NONE) {
                debug_error("Fail to stop run-plugin\n");
@@ -403,17 +299,11 @@ static void _exit_handler(int sig)
        raise(sig);
 }
 
-static int usgae(int argc, char **argv)
+static int _usage(int argc, char **argv)
 {
        fprintf(stderr, "Usage: %s [Options]\n", argv[0]);
        fprintf(stderr, "\t%-20s: start sound server.\n", "--start,-S");
-       fprintf(stderr, "\t%-20s: handle poweroff\n", "--poweroff,-F");
-       fprintf(stderr, "\t%-20s: handle soundreset\n", "--soundreset,-R");
        fprintf(stderr, "\t%-20s: help message.\n", "--help,-H");
-#if 0 /* currently not in use */
-       fprintf(stderr, "\t%-20s: print plugin list.\n", "--list,-L");
-       fprintf(stderr, "\t%-20s: print this message.\n", "--plugdir,-P");
-#endif
 
        return 1;
 }