summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjk7744.park <jk7744.park@samsung.com>2015-10-24 16:53:20 +0900
committerjk7744.park <jk7744.park@samsung.com>2015-10-24 16:53:20 +0900
commitb35c90ecb124f099e5e1f2239d90383671b15f5b (patch)
tree0570a216426bc79307c6afc96432e340e08f9766
parent92ce1a7124e7073f8e19a9de7ca3c6d8bd143efd (diff)
downloadlibmm-sound-b35c90ecb124f099e5e1f2239d90383671b15f5b.tar.gz
libmm-sound-b35c90ecb124f099e5e1f2239d90383671b15f5b.tar.bz2
libmm-sound-b35c90ecb124f099e5e1f2239d90383671b15f5b.zip
-rwxr-xr-xcommon/mm_sound_utils.c251
-rw-r--r--configure.ac3
-rw-r--r--[-rwxr-xr-x]include/mm_sound.h289
-rw-r--r--[-rwxr-xr-x]include/mm_sound_common.h22
-rw-r--r--include/mm_sound_pa_client.h9
-rw-r--r--include/mm_sound_pcm_async.h3
-rwxr-xr-xinclude/mm_sound_utils.h18
-rw-r--r--libmm-sound.manifest19
-rw-r--r--[-rwxr-xr-x]mm_sound.c539
-rw-r--r--mm_sound_bootsound.c3
-rw-r--r--mm_sound_client.c35
-rw-r--r--mm_sound_device.c4
-rw-r--r--mm_sound_pa_client.c109
-rw-r--r--mm_sound_pcm.c51
-rw-r--r--mm_sound_pcm_async.c110
-rw-r--r--packaging/libmm-sound.spec40
-rw-r--r--packaging/sound-server.service4
-rw-r--r--pkgconfig/Makefile.am2
-rw-r--r--server/Makefile.am2
-rwxr-xr-xserver/include/mm_sound_mgr_pulse.h5
-rw-r--r--server/mm_sound_mgr_asm.c177
-rwxr-xr-xserver/mm_sound_mgr_device.c123
-rwxr-xr-xserver/mm_sound_mgr_device_hdmi.c6
-rw-r--r--server/mm_sound_mgr_device_wfd.c88
-rw-r--r--server/mm_sound_mgr_ipc.c39
-rwxr-xr-xserver/mm_sound_mgr_pulse.c504
-rw-r--r--[-rwxr-xr-x]server/mm_sound_mgr_session.c161
-rw-r--r--server/mm_sound_server.c28
-rw-r--r--server/plugin/keytone/mm_sound_plugin_run_key_tone.c6
-rw-r--r--server/plugin/wav/mm_sound_plugin_codec_wave.c10
-rwxr-xr-x[-rw-r--r--]testsuite/mm_sound_testsuite_simple.c245
31 files changed, 1588 insertions, 1317 deletions
diff --git a/common/mm_sound_utils.c b/common/mm_sound_utils.c
index 0cae6f6..859b5cc 100755
--- a/common/mm_sound_utils.c
+++ b/common/mm_sound_utils.c
@@ -26,6 +26,7 @@
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
+#include <glib.h>
#include <vconf.h>
#include <vconf-keys.h>
@@ -53,9 +54,8 @@ static mm_sound_route g_valid_route[] = {
#define MM_SOUND_DEFAULT_VOLUME_CALL 4
#define MM_SOUND_DEFAULT_VOLUME_VOIP 4
#define MM_SOUND_DEFAULT_VOLUME_VOICE 7
-#define MM_SOUND_DEFAULT_VOLUME_ANDROID 0
-static char *g_volume_vconf[VOLUME_TYPE_MAX] = {
+static char *g_volume_vconf[VOLUME_TYPE_VCONF_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 */
@@ -64,9 +64,8 @@ static char *g_volume_vconf[VOLUME_TYPE_MAX] = {
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 */
};
-static char *g_volume_str[VOLUME_TYPE_MAX] = {
+static char *g_volume_str[VOLUME_TYPE_VCONF_MAX] = {
"SYSTEM",
"NOTIFICATION",
"ALARM",
@@ -75,7 +74,6 @@ static char *g_volume_str[VOLUME_TYPE_MAX] = {
"CALL",
"VOIP",
"VOICE",
- "FIXED",
};
EXPORT_API
@@ -154,27 +152,6 @@ int _mm_sound_volume_remove_callback(volume_type_t type, void *func)
return MM_ERROR_NONE;
}
-EXPORT_API
-int _mm_sound_muteall_add_callback(void *func)
-{
- if (vconf_notify_key_changed(VCONF_KEY_MUTE_ALL, func, NULL)) {
- debug_error ("vconf_notify_key_changed failed..\n");
- return MM_ERROR_SOUND_INTERNAL;
- }
-
- return MM_ERROR_NONE;
-}
-
-EXPORT_API
-int _mm_sound_muteall_remove_callback(void *func)
-{
- if (vconf_ignore_key_changed(VCONF_KEY_MUTE_ALL, func)) {
- debug_error ("vconf_ignore_key_changed failed..\n");
- return MM_ERROR_SOUND_INTERNAL;
- }
-
- return MM_ERROR_NONE;
-}
EXPORT_API
int _mm_sound_volume_get_value_by_type(volume_type_t type, unsigned int *value)
@@ -216,153 +193,209 @@ int _mm_sound_volume_set_value_by_type(volume_type_t type, unsigned int value)
}
EXPORT_API
-int _mm_sound_volume_set_balance(float balance)
+int _mm_sound_get_earjack_type (int *type)
{
- /* Set balance value to VCONF */
- if (vconf_set_dbl(VCONF_KEY_VOLUME_BALANCE, balance)) {
- debug_error ("vconf_set_dbl(%s) failed..\n", VCONF_KEY_VOLUME_BALANCE);
- return MM_ERROR_SOUND_INTERNAL;
+ int earjack_status = 0;
+
+ if (type == NULL) {
+ debug_error ("invalid parameter!!!");
+ return MM_ERROR_INVALID_ARGUMENT;
}
+ /* Get actual vconf value */
+ vconf_get_int(VCONFKEY_SYSMAN_EARJACK, &earjack_status);
+ debug_msg ("[%s] get status=[%d]\n", VCONFKEY_SYSMAN_EARJACK, earjack_status);
+
+ *type = (earjack_status >= 0)? earjack_status : VCONFKEY_SYSMAN_EARJACK_REMOVED;
+
return MM_ERROR_NONE;
}
EXPORT_API
-int _mm_sound_volume_get_balance(float *balance)
+int _mm_sound_get_dock_type (int *type)
{
- double balance_value = 0;
+ int dock_status = 0;
- /* Get balance value from VCONF */
- if (vconf_get_dbl(VCONF_KEY_VOLUME_BALANCE, &balance_value)) {
- debug_error ("vconf_get_int(%s) failed..\n", VCONF_KEY_VOLUME_BALANCE);
- return MM_ERROR_SOUND_INTERNAL;
+ if (type == NULL) {
+ debug_error ("invalid parameter!!!");
+ return MM_ERROR_INVALID_ARGUMENT;
}
- *balance = balance_value;
- debug_log("balance get value [%s]=[%f]", VCONF_KEY_VOLUME_BALANCE, *balance);
+ /* Get actual vconf value */
+ vconf_get_int(VCONFKEY_SYSMAN_CRADLE_STATUS, &dock_status);
+ debug_msg ("[%s] get dock status=[%d]\n", VCONFKEY_SYSMAN_CRADLE_STATUS, dock_status);
+
+ *type = dock_status;
return MM_ERROR_NONE;
}
EXPORT_API
-int _mm_sound_set_muteall(int muteall)
+bool _mm_sound_is_recording (void)
{
- /* Set muteall value to VCONF */
- if (vconf_set_int(VCONF_KEY_MUTE_ALL, muteall)) {
- debug_error ("vconf_set_int(%s) failed..\n", VCONF_KEY_MUTE_ALL);
- return MM_ERROR_SOUND_INTERNAL;
- }
+ int capture_status = 0;
+ bool result = false;
- return MM_ERROR_NONE;
+ /* Check whether audio is recording */
+ vconf_get_int(VCONFKEY_RECORDER_STATE, &capture_status);
+ if(capture_status == VCONFKEY_RECORDER_STATE_RECORDING) {
+ result = true;
+ debug_msg ("capture status=%d, result=%d", capture_status, result);
+ }
+ return result;
}
EXPORT_API
-int _mm_sound_get_muteall(int *muteall)
+bool _mm_sound_is_mute_policy (void)
+{
+ int setting_sound_status = true;
+
+ /* If sound is mute mode, force ringtone/notification path to headset */
+ vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &setting_sound_status);
+ debug_log ("[%s] setting_sound_status=%d\n", VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, setting_sound_status);
+
+ return !setting_sound_status;
+}
+#ifdef TIZEN_TV
+EXPORT_API
+int _mm_sound_volume_get_master(unsigned int *value)
{
- int muteall_value = 0;
+ int ret = MM_ERROR_NONE;
+ int vconf_value = 0;
- /* Get muteall value from VCONF */
- if (vconf_get_int(VCONF_KEY_MUTE_ALL, &muteall_value)) {
- debug_error ("vconf_get_int(%s) failed..\n", VCONF_KEY_MUTE_ALL);
+ /* Get volume value from VCONF */
+ if (vconf_get_int(VCONF_KEY_VOLUME_MASTER, &vconf_value)) {
+ debug_error ("vconf_get_int(%s) failed..\n", VCONF_KEY_VOLUME_MASTER);
return MM_ERROR_SOUND_INTERNAL;
}
- *muteall = muteall_value;
- debug_log("muteall get value [%s]=[%d]", VCONF_KEY_MUTE_ALL, *muteall);
+ *value = vconf_value;
+ if (ret == MM_ERROR_NONE)
+ debug_log("volume_get_value %s %d", VCONF_KEY_VOLUME_MASTER, *value);
- return MM_ERROR_NONE;
+ return ret;
}
EXPORT_API
-int __mm_sound_set_stereo_to_mono(int ismono)
+int _mm_sound_volume_set_master(unsigned int value)
{
- /* Set ismono value to VCONF */
- if (vconf_set_int(VCONF_KEY_MONO_AUDIO, ismono)) {
- debug_error ("vconf_set_int(%s) failed..\n", VCONF_KEY_MONO_AUDIO);
- return MM_ERROR_SOUND_INTERNAL;
- }
+ int ret = MM_ERROR_NONE;
+ int vconf_value = 0;
- return MM_ERROR_NONE;
+ vconf_value = value;
+ debug_log("volume_set_value %s %d", VCONF_KEY_VOLUME_MASTER, value);
+
+ if ((ret = vconf_set_int(VCONF_KEY_VOLUME_MASTER, vconf_value)) != 0) {
+ debug_error ("vconf_set_int(%s) failed..ret[%d]\n", VCONF_KEY_VOLUME_MASTER, ret);
+ if (ret == -EPERM || ret == -EACCES)
+ return MM_ERROR_SOUND_PERMISSION_DENIED;
+ else
+ return MM_ERROR_SOUND_INTERNAL;
+ }
+ return ret;
}
EXPORT_API
-int __mm_sound_get_stereo_to_mono(int *ismono)
+int _mm_sound_mute_get_master(bool *value)
{
- int ismono_value = 0;
+ int ret = MM_ERROR_NONE;
+ int vconf_value = 0;
- /* Get ismono value from VCONF */
- if (vconf_get_int(VCONF_KEY_MONO_AUDIO, &ismono_value)) {
- debug_error ("vconf_get_int(%s) failed..\n", VCONF_KEY_MONO_AUDIO);
+ /* Get volume value from VCONF */
+ if (vconf_get_int(VCONF_KEY_MUTE_MASTER, &vconf_value)) {
+ debug_error ("vconf_get_int(%s) failed..\n", VCONF_KEY_MUTE_MASTER);
return MM_ERROR_SOUND_INTERNAL;
}
- *ismono = ismono_value;
- debug_log("ismono get value [%s]=[%d]", VCONF_KEY_MONO_AUDIO, *ismono);
+ *value = vconf_value;
+ if (ret == MM_ERROR_NONE)
+ debug_log("volume_get_value %s %d", VCONF_KEY_MUTE_MASTER, *value);
- return MM_ERROR_NONE;
+ return ret;
}
EXPORT_API
-int _mm_sound_get_earjack_type (int *type)
+int _mm_sound_mute_set_master(bool value)
{
- int earjack_status = 0;
-
- if (type == NULL) {
- debug_error ("invalid parameter!!!");
- return MM_ERROR_INVALID_ARGUMENT;
- }
-
- /* Get actual vconf value */
- vconf_get_int(VCONFKEY_SYSMAN_EARJACK, &earjack_status);
- debug_msg ("[%s] get status=[%d]\n", VCONFKEY_SYSMAN_EARJACK, earjack_status);
+ int ret = MM_ERROR_NONE;
+ bool vconf_value = 0;
- *type = (earjack_status >= 0)? earjack_status : VCONFKEY_SYSMAN_EARJACK_REMOVED;
+ vconf_value = value;
+ debug_log("volume_set_value %s %d", VCONF_KEY_MUTE_MASTER, value);
- return MM_ERROR_NONE;
+ if ((ret = vconf_set_int(VCONF_KEY_MUTE_MASTER, vconf_value)) != 0) {
+ debug_error ("vconf_set_int(%s) failed..ret[%d]\n", VCONF_KEY_MUTE_MASTER, ret);
+ if (ret == -EPERM || ret == -EACCES)
+ return MM_ERROR_SOUND_PERMISSION_DENIED;
+ else
+ return MM_ERROR_SOUND_INTERNAL;
+ }
+ return ret;
}
EXPORT_API
-int _mm_sound_get_dock_type (int *type)
+int _mm_sound_get_output_device(mm_sound_tv_output_device_t *device)
{
- int dock_status = 0;
+ int ret = MM_ERROR_NONE;
+ int vconf_value = 0;
- if (type == NULL) {
- debug_error ("invalid parameter!!!");
- return MM_ERROR_INVALID_ARGUMENT;
+ /* Get volume value from VCONF */
+ if (vconf_get_int(VCONF_KEY_OUTPUT_DEVICE, &vconf_value)) {
+ debug_error ("vconf_get_int(%s) failed..\n", VCONF_KEY_OUTPUT_DEVICE);
+ return MM_ERROR_SOUND_INTERNAL;
}
- /* Get actual vconf value */
- vconf_get_int(VCONFKEY_SYSMAN_CRADLE_STATUS, &dock_status);
- debug_msg ("[%s] get dock status=[%d]\n", VCONFKEY_SYSMAN_CRADLE_STATUS, dock_status);
-
- *type = dock_status;
+ *device = vconf_value;
+ if (ret == MM_ERROR_NONE)
+ debug_log("volume_get_value %s %d", VCONF_KEY_OUTPUT_DEVICE, *device);
- return MM_ERROR_NONE;
+ return ret;
}
EXPORT_API
-bool _mm_sound_is_recording (void)
+int _mm_sound_set_output_device(mm_sound_tv_output_device_t device)
{
- int capture_status = 0;
- bool result = false;
+ int ret = MM_ERROR_NONE;
+ int vconf_value = 0;
- /* Check whether audio is recording */
- vconf_get_int(VCONFKEY_RECORDER_STATE, &capture_status);
- if(capture_status == VCONFKEY_RECORDER_STATE_RECORDING) {
- result = true;
- debug_msg ("capture status=%d, result=%d", capture_status, result);
+ vconf_value = device;
+ debug_log("volume_set_value %s %d", VCONF_KEY_OUTPUT_DEVICE, device);
+
+ if ((ret = vconf_set_int(VCONF_KEY_OUTPUT_DEVICE, vconf_value)) != 0) {
+ debug_error ("vconf_set_int(%s) failed..ret[%d]\n", VCONF_KEY_OUTPUT_DEVICE, ret);
+ if (ret == -EPERM || ret == -EACCES)
+ return MM_ERROR_SOUND_PERMISSION_DENIED;
+ else
+ return MM_ERROR_SOUND_INTERNAL;
}
- return result;
+ return ret;
}
-
+#endif /* end of TIZEN_TV */
EXPORT_API
-bool _mm_sound_is_mute_policy (void)
+bool mm_sound_util_is_process_alive(pid_t pid)
{
- int setting_sound_status = true;
+ gchar *tmp = NULL;
+ int ret = -1;
- /* If sound is mute mode, force ringtone/notification path to headset */
- vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &setting_sound_status);
- debug_log ("[%s] setting_sound_status=%d\n", VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, setting_sound_status);
+ if (pid > 999999 || pid < 2)
+ return false;
- return !setting_sound_status;
+ if ((tmp = g_strdup_printf("/proc/%d", pid))) {
+ ret = access(tmp, F_OK);
+ g_free(tmp);
+ }
+
+ if (ret == -1) {
+ if (errno == ENOENT) {
+ debug_warning ("/proc/%d not exist", pid);
+ return false;
+ } else {
+ debug_error ("/proc/%d access errno[%d]", pid, errno);
+
+ /* FIXME: error occured but file exists */
+ return true;
+ }
+ }
+
+ return true;
}
diff --git a/configure.ac b/configure.ac
index fa9f9d1..f497df0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -7,8 +7,11 @@ AC_CONFIG_HEADERS([config.h:config.hin])
AC_CONFIG_MACRO_DIR([m4])
# Checks for programs.
+m4_pattern_allow([AM_PROG_AR])
+AM_PROG_AR
AC_PROG_CC
AC_C_CONST
+AM_PROG_CC_C_O
dnl AC_FUNC_MALLOC
AC_FUNC_MMAP
AC_FUNC_REALLOC
diff --git a/include/mm_sound.h b/include/mm_sound.h
index 2cdec83..a1e2479 100755..100644
--- a/include/mm_sound.h
+++ b/include/mm_sound.h
@@ -293,9 +293,10 @@ typedef enum {
VOLUME_TYPE_VOICE, /**< VOICE volume type */
VOLUME_TYPE_FIXED, /**< Volume type for fixed acoustic level */
VOLUME_TYPE_MAX, /**< Volume type count */
- VOLUME_TYPE_EXT_ANDROID = VOLUME_TYPE_FIXED, /**< External system volume for Android */
} volume_type_t;
+#define VOLUME_TYPE_VCONF_MAX VOLUME_TYPE_VOICE + 1
+
typedef enum {
VOLUME_GAIN_DEFAULT = 0,
VOLUME_GAIN_DIALER = 1<<8,
@@ -352,17 +353,6 @@ typedef void (*mm_sound_volume_changed_cb) (volume_type_t type, unsigned int vol
/**
- * Muteall state change callback function type.
- *
- * @param user_data [in] Argument passed when callback has called
- *
- * @return No return value
- * @remark None.
- * @see mm_sound_muteall_add_callback mm_sound_muteall_remove_callback
- */
-typedef void (*muteall_callback_fn)(void* user_data);
-
-/**
* This function is to retrieve number of volume level.
*
* @param type [in] volume type to query
@@ -506,86 +496,6 @@ int mm_sound_volume_remove_callback(volume_type_t type);
int mm_sound_remove_volume_changed_callback(void);
/**
- * This function is to add muteall changed callback.
- *
- * @param func [in] callback function pointer
- * @param user_data [in] user data passing to callback function
- *
- * @return This function returns MM_ERROR_NONE on success, or negative value
- * with error code.
- * @see muteall_callback_fn
- * @code
-void _muteall_callback(void *data)
-{
- int muteall;
-
- mm_sound_get_muteall(&muteall);
- g_print("Muteall Callback Runs :::: muteall value = %d\n", muteall);
-}
-
-int muteall_callback()
-{
- int ret = 0;
-
- ret = mm_sound_muteall_add_callback( _muteall_callback);
-
- if ( MM_ERROR_NONE != ret)
- {
- printf("Can not add callback\n");
- }
- else
- {
- printf("Add callback success\n");
- }
-
- return 0;
-}
-
- * @endcode
- */
-int mm_sound_muteall_add_callback(muteall_callback_fn func);
-
-
-/**
- * This function is to remove muteall changed callback.
- *
- * @param func [in] callback function pointer
- *
- * @return This function returns MM_ERROR_NONE on success, or negative value
- * with error code.
- * @remark None.
- * @post Callback function will not be called anymore.
- * @see muteall_callback_fn
- * @code
-void _muteall_callback(void *data)
-{
- printf("Callback function\n");
-}
-
-int muteall_callback()
-{
- int ret = 0;
-
- mm_sound_muteall_add_callback( _muteall_callback);
-
- ret = mm_sound_muteall_remove_callback(_muteall_callback);
- if ( MM_ERROR_NONE == ret)
- {
- printf("Remove callback success\n");
- }
- else
- {
- printf("Remove callback failed\n");
- }
-
- return ret;
-}
-
- * @endcode
- */
-int mm_sound_muteall_remove_callback(muteall_callback_fn func);
-
-/**
* This function is to set volume level of certain volume type.
*
* @param type [in] volume type to set value.
@@ -623,25 +533,6 @@ else
int mm_sound_volume_set_value(volume_type_t type, const unsigned int value);
-
-
-
-
-/**
- * This function is to set all volume type to mute or unmute.
- *
- * @param muteall [in] the switch to control mute or unmute.
- *
- * @return This function returns MM_ERROR_NONE on success, or negative value
- * with error code.
- * @remark None.
- * @pre None.
- * @post None.
- */
-int mm_sound_mute_all(int muteall);
-
-
-
/**
* This function is to get volume level of certain volume type.
*
@@ -826,25 +717,87 @@ default:
*/
int mm_sound_volume_get_current_playing_type(volume_type_t *type);
-int mm_sound_volume_set_balance (float balance);
+int mm_sound_volume_primary_type_get(volume_type_t *type);
-int mm_sound_volume_get_balance (float *balance);
+int mm_sound_set_call_mute(volume_type_t type, int mute);
-int mm_sound_set_muteall (int muteall);
+int mm_sound_get_call_mute(volume_type_t type, int *mute);
-int mm_sound_get_muteall (int *muteall);
+#ifdef TIZEN_TV
+/* Below API is for TV profile */
-int mm_sound_set_stereo_to_mono (int ismono);
+typedef void (*master_volume_callback_fn)(unsigned int value, void* user_data);
-int mm_sound_get_stereo_to_mono (int *ismono);
+typedef void (*master_mute_callback_fn)(unsigned int value, void* user_data);
-int mm_sound_set_call_mute(volume_type_t type, int mute);
+/**
+* This function is to get master volume.
+*
+* @param value [out] volume value
+*
+* @return This function returns MM_ERROR_NONE on success, or negative value
+* with error code.
+* @remark None.
+* @see None
+* @pre None.
+* @post None.
+* @par Example
+* @*/
-int mm_sound_get_call_mute(volume_type_t type, int *mute);
+int mm_sound_volume_get_master(unsigned int *value);
+
+/**
+* This function is to set master volume.
+*
+* @param value [in] volume value
+*
+* @return This function returns MM_ERROR_NONE on success, or negative value
+* with error code.
+* @remark None.
+* @see None
+* @pre None.
+* @post None.
+* @par Example
+* @*/
+
+int mm_sound_volume_set_master(const unsigned int value);
+
+int mm_sound_set_master_volume_changed_callback(master_volume_callback_fn func, void* user_data);
+int mm_sound_unset_master_volume_changed_callback(void);
+
+/**
+* This function is to get master mute.
+*
+* @param value [out] mute value
+*
+* @return This function returns MM_ERROR_NONE on success, or negative value
+* with error code.
+* @remark None.
+* @see None
+* @pre None.
+* @post None.
+* @par Example
+* @*/
+int mm_sound_mute_get_master(bool *value);
-int mm_sound_set_factory_loopback_test(int loopback);
+/**
+* This function is to set master mute.
+*
+* @param value [in] mute value
+*
+* @return This function returns MM_ERROR_NONE on success, or negative value
+* with error code.
+* @remark None.
+* @see None
+* @pre None.
+* @post None.
+* @par Example
+* @*/
+int mm_sound_mute_set_master(const bool value);
-int mm_sound_get_factory_loopback_test(int *loopback);
+int mm_sound_set_master_mute_changed_callback(master_mute_callback_fn func, void* user_data);
+int mm_sound_unset_master_mute_changed_callback(void);
+#endif
typedef enum {
MM_SOUND_FACTORY_MIC_TEST_STATUS_OFF = 0,
@@ -1018,6 +971,34 @@ int mm_sound_pcm_play_start(MMSoundPcmHandle_t handle);
int mm_sound_pcm_play_stop(MMSoundPcmHandle_t handle);
/**
+ * This function flush pcm playback
+ *
+ * @param handle [in] handle to flush playback
+ *
+ * @return This function returns MM_ERROR_NONE on success, or negative value
+ * with error code.
+ * @remark
+ * @see
+ * @pre PCM playback handle should be allocated.
+ * @post PCM playback data will not be buffered.
+ */
+int mm_sound_pcm_play_drain(MMSoundPcmHandle_t handle);
+
+/**
+ * This function flush pcm playback
+ *
+ * @param handle [in] handle to flush playback
+ *
+ * @return This function returns MM_ERROR_NONE on success, or negative value
+ * with error code.
+ * @remark
+ * @see
+ * @pre PCM playback handle should be allocated.
+ * @post PCM playback data will not be buffered.
+ */
+int mm_sound_pcm_play_flush(MMSoundPcmHandle_t handle);
+
+/**
* This function is to play PCM memory buffer.
*
* @param handle [in] handle to play pcm data
@@ -1351,6 +1332,20 @@ int mm_sound_pcm_capture_start(MMSoundPcmHandle_t handle);
int mm_sound_pcm_capture_stop(MMSoundPcmHandle_t handle);
/**
+ * This function flush pcm capture
+ *
+ * @param handle [in] handle to flush capture
+ *
+ * @return This function returns MM_ERROR_NONE on success, or negative value
+ * with error code.
+ * @remark
+ * @see
+ * @pre PCM capture handle should be allocated.
+ * @post PCM capture data will not be buffered.
+ */
+int mm_sound_pcm_capture_flush(MMSoundPcmHandle_t handle);
+
+/**
* This function captures PCM to memory buffer. (Samsung extension)
*
* @param handle [in] handle to play pcm data
@@ -2637,6 +2632,58 @@ int mm_sound_set_sound_path_for_active_device(mm_sound_device_out device_out, mm
int mm_sound_get_audio_path(mm_sound_device_in *device_in, mm_sound_device_out *device_out);
+#ifdef TIZEN_TV
+/* Below API is for TV profile */
+typedef enum
+{
+ MM_SOUND_TV_OUTPUT_SPEAKER,
+ MM_SOUND_TV_OUTPUT_EXTERNAL_SPEAKER,
+ MM_SOUND_TV_OUTPUT_RECEIVER,
+ MM_SOUND_TV_OUTPUT_SOUND_SHARE,
+ MM_SOUND_TV_OUTPUT_MULTIROOM_LINK,
+ MM_SOUND_TV_OUTPUT_BT_HEADSET,
+ MM_SOUND_TV_OUTPUT_DUAL_BT_SPK,
+ MM_SOUND_TV_OUTPUT_MAX,
+} mm_sound_tv_output_device_t;
+
+typedef void (*output_device_callback_fn)(mm_sound_tv_output_device_t device, void* user_data);
+
+/**
+* This function is to get output device.
+*
+* @param device [out] output device
+*
+* @return This function returns MM_ERROR_NONE on success, or negative value
+* with error code.
+* @remark None.
+* @see None
+* @pre None.
+* @post None.
+* @par Example
+* @*/
+
+int mm_sound_get_output_device(mm_sound_tv_output_device_t *device);
+
+/**
+* This function is to set output device.
+*
+* @param device [in] output device
+*
+* @return This function returns MM_ERROR_NONE on success, or negative value
+* with error code.
+* @remark None.
+* @see None
+* @pre None.
+* @post None.
+* @par Example
+* @*/
+
+int mm_sound_set_output_device(mm_sound_tv_output_device_t device);
+
+int mm_sound_set_output_device_changed_callback(output_device_callback_fn func, void* user_data);
+int mm_sound_unset_output_device_changed_callback(void);
+#endif
+
/**
@}
*/
diff --git a/include/mm_sound_common.h b/include/mm_sound_common.h
index 9b18afb..7bf7b0b 100755..100644
--- a/include/mm_sound_common.h
+++ b/include/mm_sound_common.h
@@ -34,28 +34,20 @@
#define VCONF_KEY_VOLUME_TYPE_CALL VCONF_KEY_VOLUME_PREFIX"/call"
#define VCONF_KEY_VOLUME_TYPE_VOIP VCONF_KEY_VOLUME_PREFIX"/voip"
#define VCONF_KEY_VOLUME_TYPE_VOICE VCONF_KEY_VOLUME_PREFIX"/voice"
-#define VCONF_KEY_VOLUME_TYPE_ANDROID VCONF_KEY_VOLUME_PREFIX"/fixed"
-
-#define VCONF_KEY_VOLUME_BALANCE VCONF_KEY_VOLUME_PREFIX"/balance"
-#define VCONF_KEY_MUTE_ALL VCONF_KEY_VOLUME_PREFIX"/muteall"
-#define VCONF_KEY_MONO_AUDIO VCONFKEY_SETAPPL_ACCESSIBILITY_MONO_AUDIO
-
-#define VCONFKEY_SOUND_PRIMARY_VOLUME_TYPE "memory/private/sound/PrimaryVolumetype"
-#define VCONFKEY_SOUND_PRIMARY_VOLUME_TYPE_FORCE "memory/private/sound/PrimaryVolumetypeForce"
+#ifdef TIZEN_TV
+/* TV profile */
+#define VCONF_KEY_VOLUME_MASTER "file/private/sound/volume/master"
+#define VCONF_KEY_MUTE_MASTER "file/private/sound/feature/mute"
+#define VCONF_KEY_OUTPUT_DEVICE "file/private/sound/feature/speaker"
+/* end of TV profile */
+#endif
#ifndef _TIZEN_PUBLIC_
-#define VCONF_KEY_NOISE_REDUCTION VCONFKEY_CALL_NOISE_REDUCTION_STATE_BOOL
-#define VCONF_KEY_EXTRA_VOLUME VCONFKEY_CALL_EXTRA_VOLUME_STATE_BOOL
-#define VCONF_KEY_WBAMR VCONFKEY_CALL_WBAMR_STATE_BOOL
-#define VCONF_KEY_VR_ENABLED VCONFKEY_VOICE_CONTROL_ENABLED
-#define VCONF_KEY_VR_RINGTONE_ENABLED VCONFKEY_VOICE_CONTROL_INCOMING_CALL_ENABLED
#ifdef TIZEN_MICRO
#define VCONF_KEY_VR_LEFTHAND_ENABLED VCONFKEY_SETAPPL_PERFERED_ARM_LEFT_BOOL
#endif
#endif
-#define ASM_READY_KEY "memory/private/Sound/ASMReady"
-#define VCONF_KEY_FMRADIO_RECORDING "memory/private/Sound/FMRadioRecording"
#define PA_READY "/tmp/.pa_ready"
diff --git a/include/mm_sound_pa_client.h b/include/mm_sound_pa_client.h
index 9728c7f..1d4b262 100644
--- a/include/mm_sound_pa_client.h
+++ b/include/mm_sound_pa_client.h
@@ -78,6 +78,7 @@ int mm_sound_pa_write(const int handle, void* buf, const int size);
int mm_sound_pa_close(const int handle);
int mm_sound_pa_cork(const int handle, const int cork);
int mm_sound_pa_drain(const int handle);
+int mm_sound_pa_flush(const int handle);
int mm_sound_pa_set_volume_by_type(const int type, const int value);
int mm_sound_pa_get_latency(const int handle, int* latency);
int mm_sound_pa_set_call_mute(const int type, const int mute, int direction);
@@ -87,5 +88,13 @@ int mm_sound_pa_set_volume_level(const int handle, const int type, int level);
int mm_sound_pa_set_mute(const int handle, const int type, int direction, int mute);
int mm_sound_pa_get_mute(const int handle, const int type, int direction, int* mute);
int mm_sound_pa_corkall(int cork);
+int mm_sound_pa_set_route_info(const char* key, const char* value);
+#ifdef TIZEN_TV
+/* TV profile */
+int mm_sound_pa_set_master_volume(const int value);
+int mm_sound_pa_set_master_mute(const bool value);
+int mm_sound_pa_set_output_device(const int device);
+/* end of TV profile */
+#endif
#endif
diff --git a/include/mm_sound_pcm_async.h b/include/mm_sound_pcm_async.h
index 4f3eff6..74322d8 100644
--- a/include/mm_sound_pcm_async.h
+++ b/include/mm_sound_pcm_async.h
@@ -34,6 +34,7 @@ int mm_sound_pcm_capture_open_async(MMSoundPcmHandle_t *handle, const unsigned i
mm_sound_pcm_stream_cb_t callback, void* userdata);
int mm_sound_pcm_capture_start_async(MMSoundPcmHandle_t handle);
int mm_sound_pcm_capture_stop_async(MMSoundPcmHandle_t handle);
+int mm_sound_pcm_capture_flush_async(MMSoundPcmHandle_t handle);
int mm_sound_pcm_capture_peek(MMSoundPcmHandle_t handle, const void **buffer, const unsigned int *length);
int mm_sound_pcm_capture_drop(MMSoundPcmHandle_t handle);
int mm_sound_pcm_capture_close_async(MMSoundPcmHandle_t handle);
@@ -44,6 +45,8 @@ int mm_sound_pcm_play_open_async (MMSoundPcmHandle_t *handle, const unsigned int
mm_sound_pcm_stream_cb_t callback, void* userdata);
int mm_sound_pcm_play_start_async(MMSoundPcmHandle_t handle);
int mm_sound_pcm_play_stop_async(MMSoundPcmHandle_t handle);
+int mm_sound_pcm_play_drain_async(MMSoundPcmHandle_t handle);
+int mm_sound_pcm_play_flush_async(MMSoundPcmHandle_t handle);
int mm_sound_pcm_play_write_async(MMSoundPcmHandle_t handle, void* ptr, unsigned int length_byte);
int mm_sound_pcm_play_close_async(MMSoundPcmHandle_t handle);
diff --git a/include/mm_sound_utils.h b/include/mm_sound_utils.h
index 9ee2593..409bbae 100755
--- a/include/mm_sound_utils.h
+++ b/include/mm_sound_utils.h
@@ -33,6 +33,7 @@
#include <mm_types.h>
#include <mm_error.h>
+#include <unistd.h>
#include "../include/mm_sound.h"
@@ -48,14 +49,6 @@ int _mm_sound_volume_add_callback(volume_type_t type, void *func, void* user_dat
int _mm_sound_volume_remove_callback(volume_type_t type, void *func);
int _mm_sound_volume_get_value_by_type(volume_type_t type, unsigned int *value);
int _mm_sound_volume_set_value_by_type(volume_type_t type, unsigned int value);
-int _mm_sound_muteall_add_callback(void *func);
-int _mm_sound_muteall_remove_callback(void *func);
-int _mm_sound_volume_set_balance(float balance);
-int _mm_sound_volume_get_balance(float *balance);
-int _mm_sound_set_muteall(int muteall);
-int _mm_sound_get_muteall(int *muteall);
-int _mm_sound_set_stereo_to_mono(int ismono);
-int _mm_sound_get_stereo_to_mono(int *ismono);
int _mm_sound_get_earjack_type (int *type);
int _mm_sound_get_dock_type (int *type);
mm_sound_device_in _mm_sound_get_device_in_from_path (int path);
@@ -64,6 +57,15 @@ mm_sound_device_out _mm_sound_get_device_out_from_path (int path);
bool _mm_sound_is_recording (void);
bool _mm_sound_is_mute_policy (void);
+bool mm_sound_util_is_process_alive(pid_t pid);
+#ifdef TIZEN_TV
+int _mm_sound_volume_get_master(unsigned int *value);
+int _mm_sound_volume_set_master(unsigned int value);
+int _mm_sound_mute_get_master(bool *value);
+int _mm_sound_mute_set_master(bool value);
+int _mm_sound_get_output_device(mm_sound_tv_output_device_t *value);
+int _mm_sound_set_output_device(mm_sound_tv_output_device_t value);
+#endif /* end of TIZEN_TV */
#ifdef __cplusplus
}
#endif
diff --git a/libmm-sound.manifest b/libmm-sound.manifest
index 75a676e..3e14daf 100644
--- a/libmm-sound.manifest
+++ b/libmm-sound.manifest
@@ -1,12 +1,29 @@
<manifest>
<define>
<domain name="sound_server"/>
+ <request>
+ <smack request="tizen::vconf::public::r" type="rw"/>
+ <smack request="tizen::vconf::public::rw" type="rw"/>
+ <smack request="tizen::vconf::platform::r" type="rw"/>
+ <smack request="tizen::vconf::platform::rw" type="rw"/>
+ <smack request="tizen::vconf::volume::set" type="rw"/>
+ <smack request="tizen::vconf::setting::admin" type="rl"/>
+ <smack request="tizen::vconf::setting" type="rl"/>
+ <smack request="tizen::vconf::camcorder" type="rl"/>
+ <smack request="system::share" type="arwxt"/>
+ <smack request="system::homedir" type="arwxt"/>
+ <smack request="system::media" type="arwxt"/>
+ <smack request="device::sys_logging" type="w"/>
+ <smack request="device::app_logging" type="w"/>
+ <smack request="sys-assert::core" type="arwxt"/>
+ <smack request="pulseaudio" type="arwxt"/>
+ </request>
</define>
<request>
<domain name="_"/>
</request>
<assign>
<filesystem path="/usr/bin/sound_server" label="sound_server" exec_label="sound_server"/>
- <filesystem path="/opt/etc/dump.d/module.d/dump_audio.sh" exec_label="none"/>
+ <filesystem path="/opt/etc/dump.d/module.d/dump_audio.sh" label="_" exec_label="none"/>
</assign>
</manifest>
diff --git a/mm_sound.c b/mm_sound.c
index 1bba912..1c14df9 100755..100644
--- a/mm_sound.c
+++ b/mm_sound.c
@@ -59,7 +59,28 @@ typedef struct {
volume_type_t type;
}volume_cb_param;
-volume_cb_param g_volume_param[VOLUME_TYPE_MAX];
+#ifdef TIZEN_TV
+typedef struct {
+ master_volume_callback_fn func;
+ void* data;
+}master_volume_cb_param;
+
+typedef struct {
+ master_mute_callback_fn func;
+ void* data;
+}master_mute_cb_param;
+
+typedef struct {
+ output_device_callback_fn func;
+ void* data;
+}output_device_cb_param;
+
+master_volume_cb_param g_master_volume_param;
+master_mute_cb_param g_master_mute_param;
+output_device_cb_param g_output_device_param;
+#endif /* end of TIZEN_TV */
+
+volume_cb_param g_volume_param[VOLUME_TYPE_VCONF_MAX];
static pthread_mutex_t _volume_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -93,7 +114,7 @@ static int __validate_volume(volume_type_t type, int value)
return -1;
}
break;
- case VOLUME_TYPE_EXT_ANDROID:
+ case VOLUME_TYPE_FIXED:
if (value >= VOLUME_MAX_SINGLE) {
return -1;
}
@@ -127,7 +148,7 @@ int mm_sound_volume_add_callback(volume_type_t type, volume_callback_fn func, vo
debug_msg("type = (%d)%15s, func = %p, user_data = %p", type, __get_volume_str(type), func, user_data);
/* Check input param */
- if (type < 0 || type >= VOLUME_TYPE_MAX) {
+ if (type < 0 || type >= VOLUME_TYPE_VCONF_MAX) {
debug_error("invalid argument\n");
return MM_ERROR_INVALID_ARGUMENT;
}
@@ -152,7 +173,7 @@ int mm_sound_volume_remove_callback(volume_type_t type)
{
debug_msg("type = (%d)%s", type, __get_volume_str(type));
- if(type < 0 || type >=VOLUME_TYPE_MAX) {
+ if(type < 0 || type >=VOLUME_TYPE_VCONF_MAX) {
debug_error("invalid argument\n");
return MM_ERROR_INVALID_ARGUMENT;
}
@@ -200,32 +221,6 @@ int mm_sound_remove_volume_changed_callback(void)
}
EXPORT_API
-int mm_sound_muteall_add_callback(muteall_callback_fn func)
-{
- debug_msg("func = %p", func);
-
- if (!func) {
- debug_warning("callback function is null\n");
- return MM_ERROR_INVALID_ARGUMENT;
- }
-
- return _mm_sound_muteall_add_callback(func);
-}
-
-EXPORT_API
-int mm_sound_muteall_remove_callback(muteall_callback_fn func)
-{
- debug_msg("func = %p", func);
-
- if (!func) {
- debug_warning("callback function is null\n");
- return MM_ERROR_INVALID_ARGUMENT;
- }
-
- return _mm_sound_muteall_remove_callback(func);
-}
-
-EXPORT_API
int mm_sound_get_volume_step(volume_type_t type, int *step)
{
debug_error("\n**********\n\nTHIS FUNCTION HAS DEFPRECATED\n\n \
@@ -243,7 +238,7 @@ int mm_sound_volume_get_step(volume_type_t type, int *step)
debug_error("second parameter is null\n");
return MM_ERROR_INVALID_ARGUMENT;
}
- if (type < 0 || type >= VOLUME_TYPE_MAX) {
+ if (type < 0 || type >= VOLUME_TYPE_VCONF_MAX) {
debug_error("Invalid type value %d\n", (int)type);
return MM_ERROR_INVALID_ARGUMENT;
}
@@ -273,49 +268,51 @@ int mm_sound_volume_set_value(volume_type_t type, const unsigned int value)
ret = _mm_sound_volume_set_value_by_type(type, value);
if (ret == MM_ERROR_NONE) {
/* update shared memory value */
- int muteall;
- _mm_sound_get_muteall(&muteall);
- if(!muteall) {
- if(MM_ERROR_NONE != mm_sound_pa_set_volume_by_type(type, (int)value)) {
- debug_error("Can not set volume to shared memory 0x%x\n", ret);
- }
+ if(MM_ERROR_NONE != mm_sound_pa_set_volume_by_type(type, (int)value)) {
+ debug_error("Can not set volume to shared memory 0x%x\n", ret);
}
}
return ret;
}
+
EXPORT_API
-int mm_sound_mute_all(int muteall)
+int mm_sound_set_call_mute(volume_type_t type, int mute)
{
int ret = MM_ERROR_NONE;
- debug_msg("** deprecated API ** muteall = %d", muteall);
+ debug_error("Unsupported API\n");
return ret;
}
EXPORT_API
-int mm_sound_set_call_mute(volume_type_t type, int mute)
+int mm_sound_get_call_mute(volume_type_t type, int *mute)
{
int ret = MM_ERROR_NONE;
+ if(!mute)
+ return MM_ERROR_INVALID_ARGUMENT;
+
debug_error("Unsupported API\n");
return ret;
}
-
EXPORT_API
-int mm_sound_get_call_mute(volume_type_t type, int *mute)
+int mm_sound_set_route_info(const char* key, const char* value)
{
int ret = MM_ERROR_NONE;
- if(!mute)
+ if(key == NULL || value == NULL)
return MM_ERROR_INVALID_ARGUMENT;
- debug_error("Unsupported API\n");
+ ret = mm_sound_pa_set_route_info(key, value);
+ if(ret != MM_ERROR_NONE) {
+ debug_error("Can not set route info 0x%x\n", ret);
+ }
return ret;
}
@@ -330,7 +327,7 @@ int mm_sound_volume_get_value(volume_type_t type, unsigned int *value)
debug_error("invalid argument\n");
return MM_ERROR_INVALID_ARGUMENT;
}
- if (type < 0 || type >= VOLUME_TYPE_MAX) {
+ if (type < 0 || type >= VOLUME_TYPE_VCONF_MAX) {
debug_error("invalid volume type value %d\n", type);
return MM_ERROR_INVALID_ARGUMENT;
}
@@ -348,7 +345,7 @@ int mm_sound_volume_primary_type_set(volume_type_t type)
int ret = MM_ERROR_NONE;
/* Check input param */
- if(type < 0 || type >= VOLUME_TYPE_MAX) {
+ if(type < 0 || type >= VOLUME_TYPE_VCONF_MAX) {
debug_error("invalid argument\n");
return MM_ERROR_INVALID_ARGUMENT;
}
@@ -427,99 +424,11 @@ int mm_sound_volume_get_current_playing_type(volume_type_t *type)
}
EXPORT_API
-int mm_sound_volume_set_balance (float balance)
-{
- debug_msg("balance = %f", balance);
-
- /* Check input param */
- if (balance < -1.0 || balance > 1.0) {
- debug_error("invalid balance value [%f]\n", balance);
- return MM_ERROR_INVALID_ARGUMENT;
- }
-
- return _mm_sound_volume_set_balance(balance);
-}
-
-EXPORT_API
-int mm_sound_volume_get_balance (float *balance)
-{
- int ret = MM_ERROR_NONE;
-
- /* Check input param */
- if (balance == NULL) {
- debug_error("invalid argument\n");
- return MM_ERROR_INVALID_ARGUMENT;
- }
-
- ret = _mm_sound_volume_get_balance(balance);
- debug_msg("returned balance = %f", *balance);
-
- return ret;
-}
-
-EXPORT_API
-int mm_sound_set_muteall (int muteall)
-{
- debug_msg("muteall = %d", muteall);
-
- /* Check input param */
- if (muteall < 0 || muteall > 1) {
- debug_error("invalid muteall value [%f]\n", muteall);
- return MM_ERROR_INVALID_ARGUMENT;
- }
-
- return _mm_sound_set_muteall(muteall);
-}
-
-EXPORT_API
-int mm_sound_get_muteall (int *muteall)
-{
- int ret = MM_ERROR_NONE;
-
- /* Check input param */
- if (muteall == NULL) {
- debug_error("invalid argument\n");
- return MM_ERROR_INVALID_ARGUMENT;
- }
-
- ret = _mm_sound_get_muteall(muteall);
- debug_msg("returned muteall = %d", *muteall);
-
- return ret;
-}
-
-EXPORT_API
-int mm_sound_set_stereo_to_mono (int ismono)
-{
- debug_msg("ismono = %d", ismono);
-
- /* Check input param */
- if (ismono < 0 || ismono > 1) {
- debug_error("invalid ismono value [%f]\n", ismono);
- return MM_ERROR_INVALID_ARGUMENT;
- }
-
- return __mm_sound_set_stereo_to_mono(ismono);
-}
-
-EXPORT_API
-int mm_sound_get_stereo_to_mono (int *ismono)
+int mm_sound_volume_primary_type_get(volume_type_t *type)
{
- int ret = MM_ERROR_NONE;
-
- /* Check input param */
- if (ismono == NULL) {
- debug_error("invalid argument\n");
- return MM_ERROR_INVALID_ARGUMENT;
- }
-
- ret = __mm_sound_get_stereo_to_mono(ismono);
- debug_msg("returned ismono = %d", *ismono);
-
- return ret;
+ return mm_sound_volume_get_current_playing_type(type);
}
-
///////////////////////////////////
//// MMSOUND PLAY APIs
///////////////////////////////////
@@ -789,28 +698,6 @@ int mm_sound_route_remove_change_callback(void)
#endif /* PULSE_CLIENT */
EXPORT_API
-int mm_sound_system_get_capture_status(system_audio_capture_status_t *status)
-{
- int err = MM_ERROR_NONE;
- int on_capture = 0;
-
- if(!status) {
- debug_error("invalid argument\n");
- return MM_ERROR_INVALID_ARGUMENT;
- }
-
- /* Check whether sound is capturing */
- vconf_get_int(VCONFKEY_SOUND_CAPTURE_STATUS, &on_capture); // need to check where it is set
-
- if(on_capture)
- *status = SYSTEM_AUDIO_CAPTURE_ACTIVE;
- else
- *status = SYSTEM_AUDIO_CAPTURE_NONE;
-
- return MM_ERROR_NONE;
-}
-
-EXPORT_API
int mm_sound_is_route_available(mm_sound_route route, bool *is_available)
{
int ret = MM_ERROR_NONE;
@@ -1027,7 +914,343 @@ int mm_sound_set_sound_path_for_active_device(mm_sound_device_out device_out, mm
return ret;
}
+#ifdef TIZEN_TV
+static void master_volume_changed_cb(keynode_t* node, void* data)
+{
+ master_volume_cb_param* param = (master_volume_cb_param*) data;
+ int new_value = 0;
+ char* node_name = NULL;
+
+
+ node_name = vconf_keynode_get_name(node);
+ new_value = vconf_keynode_get_int(node);
+
+ debug_msg("%s changed callback called, new value(%d)\n", node_name, new_value);
+
+ MMSOUND_ENTER_CRITICAL_SECTION( &_volume_mutex )
+
+ if(param && (param->func != NULL)) {
+ debug_log("function 0x%x\n", param->func);
+ ((master_volume_callback_fn)param->func)(new_value, param->data);
+ }
+
+ MMSOUND_LEAVE_CRITICAL_SECTION( &_volume_mutex )
+}
+
+static void master_mute_changed_cb(keynode_t* node, void* data)
+{
+ master_mute_cb_param* param = (master_mute_cb_param*) data;
+ int new_value = 0;
+ char* node_name = NULL;
+
+
+ node_name = vconf_keynode_get_name(node);
+ new_value = vconf_keynode_get_int(node);
+
+ debug_msg("%s changed callback called, new value(%d)\n", node_name, new_value);
+
+ MMSOUND_ENTER_CRITICAL_SECTION( &_volume_mutex )
+
+ if(param && (param->func != NULL)) {
+ debug_log("function 0x%x\n", param->func);
+ ((master_mute_callback_fn)param->func)(new_value, param->data);
+ }
+
+ MMSOUND_LEAVE_CRITICAL_SECTION( &_volume_mutex )
+}
+
+static void output_device_changed_cb(keynode_t* node, void* data)
+{
+ output_device_cb_param* param = (output_device_cb_param*) data;
+ int new_value = 0;
+ char* node_name = NULL;
+
+
+ node_name = vconf_keynode_get_name(node);
+ new_value = vconf_keynode_get_int(node);
+
+ debug_msg("%s changed callback called, new value(%d)\n", node_name, new_value);
+
+ MMSOUND_ENTER_CRITICAL_SECTION( &_volume_mutex )
+
+ if(param && (param->func != NULL)) {
+ debug_log("function 0x%x\n", param->func);
+ ((output_device_callback_fn)param->func)((mm_sound_tv_output_device_t)new_value, param->data);
+ }
+
+ MMSOUND_LEAVE_CRITICAL_SECTION( &_volume_mutex )
+}
+
+EXPORT_API
+int mm_sound_volume_get_master(unsigned int *value)
+{
+ int ret = MM_ERROR_NONE;
+
+ /* Check input param */
+ if (value == NULL) {
+ debug_error("invalid argument\n");
+ return MM_ERROR_INVALID_ARGUMENT;
+ }
+
+ ret = _mm_sound_volume_get_master(value);
+
+ debug_msg("returned %d", *value);
+ return ret;
+
+ return ret;
+}
+
+EXPORT_API
+int mm_sound_volume_set_master(const unsigned int value)
+{
+ int ret = MM_ERROR_NONE;
+
+ debug_msg("value = %d", value);
+
+ /* Check input param */
+ if ((value < MASTER_VOLUME_MIN) || (value > MASTER_VOLUME_MAX)) {
+ debug_error("invalid volume value %u\n", value);
+ return MM_ERROR_INVALID_ARGUMENT;
+ }
+
+ ret = _mm_sound_volume_set_master(value);
+ if (ret == MM_ERROR_NONE) {
+ if(MM_ERROR_NONE != mm_sound_pa_set_master_volume((int)value)) {
+ debug_error("mm_sound_pa_set_master_volume failed : 0x%x\n", ret);
+ }
+ }
+
+ return ret;
+}
+
+EXPORT_API
+int mm_sound_set_master_volume_changed_callback(master_volume_callback_fn func, void* user_data)
+{
+ debug_msg("func = %p, user_data = %p", func, user_data);
+
+ /* Check input param */
+ if (!func) {
+ debug_warning("callback function is null\n");
+ return MM_ERROR_INVALID_ARGUMENT;
+ }
+
+ MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN( &_volume_mutex, MM_ERROR_SOUND_INTERNAL );
+
+ if (g_master_volume_param.func) {
+ debug_error ("already set callback(%p), user_data(%p). please try it again after unsetting the prior callback\n", g_master_volume_param.func, g_master_volume_param.data);
+ MMSOUND_LEAVE_CRITICAL_SECTION( &_volume_mutex );
+ return MM_ERROR_SOUND_INTERNAL;
+ } else {
+ g_master_volume_param.func = func;
+ g_master_volume_param.data = user_data;
+ }
+
+ MMSOUND_LEAVE_CRITICAL_SECTION( &_volume_mutex );
+
+ if (vconf_notify_key_changed(VCONF_KEY_VOLUME_MASTER, master_volume_changed_cb,(void*)&g_master_volume_param)) {
+ debug_error ("vconf_notify_key_changed failed..\n");
+ return MM_ERROR_SOUND_INTERNAL;
+ }
+ return MM_ERROR_NONE;
+}
+
+EXPORT_API
+int mm_sound_unset_master_volume_changed_callback(void)
+{
+ debug_msg("func = %p, user_data = %p will be removed", g_master_volume_param.func, g_master_volume_param.data);
+
+ MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN( &_volume_mutex, MM_ERROR_SOUND_INTERNAL );
+
+ g_master_volume_param.func = NULL;
+ g_master_volume_param.data = NULL;
+
+ MMSOUND_LEAVE_CRITICAL_SECTION( &_volume_mutex );
+
+ if (vconf_ignore_key_changed(VCONF_KEY_VOLUME_MASTER, master_volume_changed_cb)) {
+ debug_error ("vconf_ignore_key_changed failed..\n");
+ return MM_ERROR_SOUND_INTERNAL;
+ }
+ return MM_ERROR_NONE;
+}
+
+EXPORT_API
+int mm_sound_mute_get_master(bool *value)
+{
+ int ret = MM_ERROR_NONE;
+
+ /* Check input param */
+ if (value == NULL) {
+ debug_error("invalid argument\n");
+ return MM_ERROR_INVALID_ARGUMENT;
+ }
+
+ ret = _mm_sound_mute_get_master(value);
+
+ debug_msg("returned %d", *value);
+ return ret;
+
+ return ret;
+}
+
+EXPORT_API
+int mm_sound_mute_set_master(const bool value)
+{
+ int ret = MM_ERROR_NONE;
+
+ debug_msg("value = %d", value);
+
+ ret = _mm_sound_mute_set_master(value);
+ if (ret == MM_ERROR_NONE) {
+ if(MM_ERROR_NONE != mm_sound_pa_set_master_mute((int)value)) {
+ debug_error("mm_sound_pa_set_master_mute failed : 0x%x\n", ret);
+ }
+ }
+
+ return ret;
+}
+
+EXPORT_API
+int mm_sound_set_master_mute_changed_callback(master_mute_callback_fn func, void* user_data)
+{
+ debug_msg("func = %p, user_data = %p", func, user_data);
+
+ /* Check input param */
+ if (!func) {
+ debug_warning("callback function is null\n");
+ return MM_ERROR_INVALID_ARGUMENT;
+ }
+
+ MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN( &_volume_mutex, MM_ERROR_SOUND_INTERNAL );
+
+ if (g_master_mute_param.func) {
+ debug_error ("already set callback(%p), user_data(%p). please try it again after unsetting the prior callback\n", g_master_mute_param.func, g_master_mute_param.data);
+ MMSOUND_LEAVE_CRITICAL_SECTION( &_volume_mutex );
+ return MM_ERROR_SOUND_INTERNAL;
+ } else {
+ g_master_mute_param.func = func;
+ g_master_mute_param.data = user_data;
+ }
+
+ MMSOUND_LEAVE_CRITICAL_SECTION( &_volume_mutex );
+
+ if (vconf_notify_key_changed(VCONF_KEY_MUTE_MASTER, master_mute_changed_cb,(void*)&g_master_mute_param)) {
+ debug_error ("vconf_notify_key_changed failed..\n");
+ return MM_ERROR_SOUND_INTERNAL;
+ }
+ return MM_ERROR_NONE;
+}
+
+EXPORT_API
+int mm_sound_unset_master_mute_changed_callback(void)
+{
+ debug_msg("func = %p, user_data = %p will be removed", g_master_mute_param.func, g_master_mute_param.data);
+
+ MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN( &_volume_mutex, MM_ERROR_SOUND_INTERNAL );
+
+ g_master_mute_param.func = NULL;
+ g_master_mute_param.data = NULL;
+
+ MMSOUND_LEAVE_CRITICAL_SECTION( &_volume_mutex );
+
+ if (vconf_ignore_key_changed(VCONF_KEY_MUTE_MASTER, master_mute_changed_cb)) {
+ debug_error ("vconf_ignore_key_changed failed..\n");
+ return MM_ERROR_SOUND_INTERNAL;
+ }
+ return MM_ERROR_NONE;
+}
+
+EXPORT_API
+int mm_sound_get_output_device(mm_sound_tv_output_device_t *device)
+{
+ int ret = MM_ERROR_NONE;
+
+ /* Check input param */
+ if (device == NULL) {
+ debug_error("invalid argument\n");
+ return MM_ERROR_INVALID_ARGUMENT;
+ }
+
+ ret = _mm_sound_get_output_device(device);
+
+ debug_msg("returned %d", *device);
+ return ret;
+
+ return ret;
+}
+EXPORT_API
+int mm_sound_set_output_device(mm_sound_tv_output_device_t device)
+{
+ int ret = MM_ERROR_NONE;
+
+ debug_msg("device = %d", device);
+
+ /* Check input param */
+ if ((device < MM_SOUND_TV_OUTPUT_SPEAKER) || (device > MM_SOUND_TV_OUTPUT_MAX)) {
+ debug_error("invalid volume value %u\n", device);
+ return MM_ERROR_INVALID_ARGUMENT;
+ }
+
+ ret = _mm_sound_set_output_device(device);
+ if (ret == MM_ERROR_NONE) {
+ if(MM_ERROR_NONE != mm_sound_pa_set_output_device((int)device)) {
+ debug_error("mm_sound_pa_set_output_device failed : 0x%x\n", ret);
+ }
+ }
+
+ return ret;
+}
+
+EXPORT_API
+int mm_sound_set_output_device_changed_callback(output_device_callback_fn func, void* user_data)
+{
+ debug_msg("func = %p, user_data = %p", func, user_data);
+
+ /* Check input param */
+ if (!func) {
+ debug_warning("callback function is null\n");
+ return MM_ERROR_INVALID_ARGUMENT;
+ }
+
+ MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN( &_volume_mutex, MM_ERROR_SOUND_INTERNAL );
+
+ if (g_output_device_param.func) {
+ debug_error ("already set callback(%p), user_data(%p). please try it again after unsetting the prior callback\n", g_output_device_param.func, g_output_device_param.data);
+ MMSOUND_LEAVE_CRITICAL_SECTION( &_volume_mutex );
+ return MM_ERROR_SOUND_INTERNAL;
+ } else {
+ g_output_device_param.func = func;
+ g_output_device_param.data = user_data;
+ }
+
+ MMSOUND_LEAVE_CRITICAL_SECTION( &_volume_mutex );
+
+ if (vconf_notify_key_changed(VCONF_KEY_OUTPUT_DEVICE, output_device_changed_cb,(void*)&g_output_device_param)) {
+ debug_error ("vconf_notify_key_changed failed..\n");
+ return MM_ERROR_SOUND_INTERNAL;
+ }
+ return MM_ERROR_NONE;
+}
+
+EXPORT_API
+int mm_sound_unset_output_device_changed_callback(void)
+{
+ debug_msg("func = %p, user_data = %p will be removed", g_output_device_param.func, g_output_device_param.data);
+
+ MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN( &_volume_mutex, MM_ERROR_SOUND_INTERNAL );
+
+ g_output_device_param.func = NULL;
+ g_output_device_param.data = NULL;
+
+ MMSOUND_LEAVE_CRITICAL_SECTION( &_volume_mutex );
+
+ if (vconf_ignore_key_changed(VCONF_KEY_OUTPUT_DEVICE, output_device_changed_cb)) {
+ debug_error ("vconf_ignore_key_changed failed..\n");
+ return MM_ERROR_SOUND_INTERNAL;
+ }
+ return MM_ERROR_NONE;
+}
+#endif /* end of TIZEN_TV */
__attribute__ ((destructor))
void __mmfsnd_finalize(void)
{
diff --git a/mm_sound_bootsound.c b/mm_sound_bootsound.c
index 74c7bb6..1a4148d 100644
--- a/mm_sound_bootsound.c
+++ b/mm_sound_bootsound.c
@@ -41,7 +41,6 @@
#include <mm_sound.h>
#include <mm_sound_private.h>
-#define VCONF_BOOTING "memory/private/sound/booting"
#define MAX_RETRY 40
#define RETRY_INTERVAL_USEC 50000
@@ -79,7 +78,7 @@ int mm_sound_boot_play_sound(char* path)
if (path == NULL)
return -1;
- return vconf_set_str(VCONF_BOOTING, path);
+ return vconf_set_str(VCONFKEY_SOUND_BOOT_SOUND, path);
}
diff --git a/mm_sound_client.c b/mm_sound_client.c
index 969e08c..18daf8e 100644
--- a/mm_sound_client.c
+++ b/mm_sound_client.c
@@ -52,6 +52,8 @@
#include <sys/poll.h>
#endif
+#define CLIENT_HANDLE_MAX 256
+
#define MEMTYPE_SUPPORT_MAX (1024 * 1024) /* 1MB */
#define MEMTYPE_TRANS_PER_MAX (128 * 1024) /* 128K */
@@ -60,9 +62,8 @@ int g_msg_scrcv; /* global msg queue id sound client rcv */
int g_msg_sccb; /* global msg queue id sound client callback */
/* 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;
+static __thread GList *g_device_list = NULL;
+static __thread mm_sound_device_list_t g_device_list_t;
/* callback */
struct __callback_param
@@ -758,12 +759,13 @@ int MMSoundClientStopSound(int handle)
instance = getpid();
- if (handle < 0)
+ if (handle < 0 || handle > CLIENT_HANDLE_MAX)
{
ret = MM_ERROR_INVALID_ARGUMENT;
return ret;
}
+
ret = __mm_sound_client_get_msg_queue();
if (ret != MM_ERROR_NONE) {
return ret;
@@ -834,9 +836,9 @@ static int __mm_sound_device_check_flags_to_append (int device_flags, mm_sound_d
}
if (need_to_check_for_io_direction) {
- if ((device_h->io_direction == DEVICE_IO_DIRECTION_IN) && (device_flags & DEVICE_IO_DIRECTION_IN_FLAG)) {
+ if ((device_h->io_direction == DEVICE_IO_DIRECTION_IN || device_h->io_direction == DEVICE_IO_DIRECTION_BOTH) && (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)) {
+ } else if ((device_h->io_direction == DEVICE_IO_DIRECTION_OUT || device_h->io_direction == DEVICE_IO_DIRECTION_BOTH) && (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;
@@ -891,14 +893,12 @@ 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;
}
@@ -911,12 +911,11 @@ int __mm_sound_client_device_list_append_item (mm_sound_device_t *device_h)
return MM_ERROR_SOUND_INTERNAL;
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);
+ debug_log("[Client] g_device_list[0x%x], new device_node[0x%x] is appended, type[%d], direction[0x%x], id[%d]\n",
+ g_device_list, device_node, device_node->type, device_node->io_direction, device_node->id);
- MMSOUND_LEAVE_CRITICAL_SECTION(&g_device_list_mutex);
return ret;
}
@@ -976,7 +975,6 @@ int _mm_sound_client_get_current_connected_device_list(int device_flags, mm_soun
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;
@@ -1014,9 +1012,16 @@ int _mm_sound_client_get_current_connected_device_list(int device_flags, mm_soun
}
}
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);
+ if (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);
+ } else {
+ debug_msg("[Client] device_list null\n");
+ *device_list = NULL;
+ ret = MM_ERROR_SOUND_NO_DATA;
+ }
+
}
break;
case MM_SOUND_MSG_RES_ERROR:
diff --git a/mm_sound_device.c b/mm_sound_device.c
index 9c8c936..a212ae7 100644
--- a/mm_sound_device.c
+++ b/mm_sound_device.c
@@ -29,7 +29,7 @@
#include "include/mm_sound.h"
#include "include/mm_sound_device.h"
-bool is_new_device_list = true;
+__thread bool is_new_device_list = true;
static int check_for_valid_mask (mm_sound_device_flags_e flags)
{
@@ -167,6 +167,7 @@ int mm_sound_get_next_device (MMSoundDeviceList_t device_list, MMSoundDevice_t *
node = g_list_next(device_list_t->list);
}
if (!node) {
+ *device = NULL;
ret = MM_ERROR_SOUND_NO_DATA;
} else {
if (is_new_device_list) {
@@ -193,6 +194,7 @@ int mm_sound_get_prev_device (MMSoundDeviceList_t device_list, MMSoundDevice_t *
device_list_t = (mm_sound_device_list_t*) device_list;
node = g_list_previous(device_list_t->list);
if (!node) {
+ *device = NULL;
ret = MM_ERROR_SOUND_NO_DATA;
debug_error("Could not get previous device, ret = %x\n", ret);
} else {
diff --git a/mm_sound_pa_client.c b/mm_sound_pa_client.c
index 6ca05ef..5e440ff 100644
--- a/mm_sound_pa_client.c
+++ b/mm_sound_pa_client.c
@@ -142,7 +142,6 @@ static const pa_tizen_volume_type_t mm_sound_volume_type_to_pa[VOLUME_TYPE_MAX]
[VOLUME_TYPE_VOIP] = PA_TIZEN_VOLUME_TYPE_VOIP,
[VOLUME_TYPE_VOICE] = PA_TIZEN_VOLUME_TYPE_VOICE,
[VOLUME_TYPE_FIXED] = PA_TIZEN_VOLUME_TYPE_FIXED,
-// [VOLUME_TYPE_EXT_SYSTEM_JAVA] = PA_TIZEN_VOLUME_TYPE_EXT_JAVA,
};
#define PA_SIMPLE_FADE_INTERVAL_USEC 20000
@@ -490,10 +489,10 @@ int mm_sound_pa_open(MMSoundHandleMode mode, mm_sound_handle_route_info *route_i
goto fail;
}
- if((handle = (mm_sound_handle_t*)malloc(sizeof(mm_sound_handle_t))) == NULL) {
- debug_error("Allocate memory for handle failed\n");
- err = MM_ERROR_OUT_OF_MEMORY;
- goto fail;
+ if ((handle = (mm_sound_handle_t*)malloc(sizeof(mm_sound_handle_t))) == NULL) {
+ debug_error("Allocate memory for handle failed\n");
+ err = MM_ERROR_OUT_OF_MEMORY;
+ goto fail;
}
handle->mode = mode;
@@ -694,6 +693,25 @@ int mm_sound_pa_drain(const int handle)
}
EXPORT_API
+int mm_sound_pa_flush(const int handle)
+{
+ mm_sound_handle_t* phandle = NULL;
+ int err = MM_ERROR_NONE;
+
+ CHECK_HANDLE_RANGE(handle);
+ GET_HANDLE_DATA(phandle, mm_sound_handle_mgr.handles, &handle, __mm_sound_handle_comparefunc);
+ if(phandle == NULL)
+ return MM_ERROR_SOUND_INTERNAL;
+
+ if (0 > pa_simple_flush(phandle->s, &err)) {
+ debug_error("pa_simple_flush() failed with %s\n", pa_strerror(err));
+ err = MM_ERROR_SOUND_INTERNAL;
+ }
+
+ return err;
+}
+
+EXPORT_API
int mm_sound_pa_get_latency(const int handle, int* latency)
{
mm_sound_handle_t* phandle = NULL;
@@ -1046,3 +1064,84 @@ int mm_sound_pa_corkall(int cork)
return MM_ERROR_NONE;
}
+EXPORT_API
+int mm_sound_pa_set_route_info(const char* key, const char* value)
+{
+ pa_operation *o = NULL;
+
+ CHECK_CONNECT_TO_PULSEAUDIO();
+
+ pa_threaded_mainloop_lock(mm_sound_handle_mgr.mainloop);
+
+ o = pa_ext_policy_set_route_info(mm_sound_handle_mgr.context, key, value, __mm_sound_pa_success_cb, (void*)mm_sound_handle_mgr.mainloop);
+ WAIT_PULSEAUDIO_OPERATION(mm_sound_handle_mgr, o);
+
+ if(o)
+ pa_operation_unref(o);
+
+ pa_threaded_mainloop_unlock(mm_sound_handle_mgr.mainloop);
+
+ return MM_ERROR_NONE;
+}
+
+#ifdef TIZEN_TV
+EXPORT_API
+int mm_sound_pa_set_master_volume(const int value)
+{
+ pa_operation *o = NULL;
+
+ CHECK_CONNECT_TO_PULSEAUDIO();
+
+ pa_threaded_mainloop_lock(mm_sound_handle_mgr.mainloop);
+
+ o = pa_ext_policy_set_master_volume(mm_sound_handle_mgr.context, value, __mm_sound_pa_success_cb, (void*)mm_sound_handle_mgr.mainloop);
+ WAIT_PULSEAUDIO_OPERATION(mm_sound_handle_mgr, o);
+
+ if(o)
+ pa_operation_unref(o);
+
+ pa_threaded_mainloop_unlock(mm_sound_handle_mgr.mainloop);
+
+ return MM_ERROR_NONE;
+}
+
+EXPORT_API
+int mm_sound_pa_set_master_mute(const bool value)
+{
+ pa_operation *o = NULL;
+
+ CHECK_CONNECT_TO_PULSEAUDIO();
+
+ pa_threaded_mainloop_lock(mm_sound_handle_mgr.mainloop);
+
+ o = pa_ext_policy_set_master_mute(mm_sound_handle_mgr.context, value, __mm_sound_pa_success_cb, (void*)mm_sound_handle_mgr.mainloop);
+ WAIT_PULSEAUDIO_OPERATION(mm_sound_handle_mgr, o);
+
+ if(o)
+ pa_operation_unref(o);
+
+ pa_threaded_mainloop_unlock(mm_sound_handle_mgr.mainloop);
+
+ return MM_ERROR_NONE;
+}
+
+EXPORT_API
+int mm_sound_pa_set_output_device(const int device)
+{
+ pa_operation *o = NULL;
+
+ CHECK_CONNECT_TO_PULSEAUDIO();
+
+ pa_threaded_mainloop_lock(mm_sound_handle_mgr.mainloop);
+
+ o = pa_ext_policy_set_output_device(mm_sound_handle_mgr.context, device, __mm_sound_pa_success_cb, (void*)mm_sound_handle_mgr.mainloop);
+ WAIT_PULSEAUDIO_OPERATION(mm_sound_handle_mgr, o);
+
+ if(o)
+ pa_operation_unref(o);
+
+ pa_threaded_mainloop_unlock(mm_sound_handle_mgr.mainloop);
+
+ return MM_ERROR_NONE;
+}
+#endif /* end of TIZEN_TV */
diff --git a/mm_sound_pcm.c b/mm_sound_pcm.c
index 8e11481..cc41e4f 100644
--- a/mm_sound_pcm.c
+++ b/mm_sound_pcm.c
@@ -761,6 +761,23 @@ int mm_sound_pcm_capture_stop(MMSoundPcmHandle_t handle)
}
EXPORT_API
+int mm_sound_pcm_capture_flush(MMSoundPcmHandle_t handle)
+{
+ int ret = 0;
+ mm_sound_pcm_t *pcmHandle = (mm_sound_pcm_t*)handle;
+
+ /* Check input param */
+ if(pcmHandle == NULL)
+ return MM_ERROR_INVALID_ARGUMENT;
+
+ debug_warning ("enter : handle=[%p]\n", handle);
+ ret = mm_sound_pa_flush(pcmHandle->handle);
+ debug_warning ("leave : handle=[%p], ret=[0x%X]\n", handle, ret);
+
+ return ret;
+}
+
+EXPORT_API
int mm_sound_pcm_capture_read(MMSoundPcmHandle_t handle, void *buffer, const unsigned int length )
{
int ret = 0;
@@ -1083,6 +1100,40 @@ int mm_sound_pcm_play_stop(MMSoundPcmHandle_t handle)
}
EXPORT_API
+int mm_sound_pcm_play_drain(MMSoundPcmHandle_t handle)
+{
+ int ret = 0;
+ mm_sound_pcm_t *pcmHandle = (mm_sound_pcm_t*)handle;
+
+ /* Check input param */
+ if(pcmHandle == NULL)
+ return MM_ERROR_INVALID_ARGUMENT;
+
+ debug_warning ("enter : handle=[%p]\n", handle);
+ ret = mm_sound_pa_drain(pcmHandle->handle);
+ debug_warning ("leave : handle=[%p], ret=[0x%X]\n", handle, ret);
+
+ return ret;
+}
+
+EXPORT_API
+int mm_sound_pcm_play_flush(MMSoundPcmHandle_t handle)
+{
+ int ret = 0;
+ mm_sound_pcm_t *pcmHandle = (mm_sound_pcm_t*)handle;
+
+ /* Check input param */
+ if(pcmHandle == NULL)
+ return MM_ERROR_INVALID_ARGUMENT;
+
+ debug_warning ("enter : handle=[%p]\n", handle);
+ ret = mm_sound_pa_flush(pcmHandle->handle);
+ debug_warning ("leave : handle=[%p], ret=[0x%X]\n", handle, ret);
+
+ return ret;
+}
+
+EXPORT_API
int mm_sound_pcm_play_write(MMSoundPcmHandle_t handle, void* ptr, unsigned int length_byte)
{
int ret = 0;
diff --git a/mm_sound_pcm_async.c b/mm_sound_pcm_async.c
index def8897..91cf700 100644
--- a/mm_sound_pcm_async.c
+++ b/mm_sound_pcm_async.c
@@ -101,6 +101,7 @@ static int mm_sound_pa_open(mm_sound_pcm_async_t* handle, int mode, int policy,
static int _mm_sound_pa_close(mm_sound_pcm_async_t* handle);
static int _mm_sound_pa_cork(mm_sound_pcm_async_t* handle, int cork);
static int _mm_sound_pa_drain(mm_sound_pcm_async_t* handle);
+static int _mm_sound_pa_flush(mm_sound_pcm_async_t* handle);
static int _mm_sound_pa_get_latency(mm_sound_pcm_async_t* handle, int* latency);;
static void __mm_sound_pa_success_cb(pa_context *c, int success, void *userdata);
@@ -559,6 +560,26 @@ int mm_sound_pcm_capture_stop_async(MMSoundPcmHandle_t handle)
}
EXPORT_API
+int mm_sound_pcm_capture_flush_async(MMSoundPcmHandle_t handle)
+{
+ int ret = 0;
+ mm_sound_pcm_async_t *pcmHandle = (mm_sound_pcm_async_t*)handle;
+
+ /* Check input param */
+ if(pcmHandle == NULL) {
+ debug_error ("Handle is null, return Invalid Argument\n");
+ ret = MM_ERROR_INVALID_ARGUMENT;
+ return ret;
+ }
+
+ debug_warning ("enter : handle=[%p]\n", handle);
+ ret = _mm_sound_pa_flush(handle);
+ debug_warning ("leave : handle=[%p], ret=[0x%X]\n", handle, ret);
+
+ return ret;
+}
+
+EXPORT_API
int mm_sound_pcm_capture_peek(MMSoundPcmHandle_t handle, const void **buffer, const unsigned int *length)
{
int ret = 0;
@@ -861,6 +882,46 @@ int mm_sound_pcm_play_stop_async(MMSoundPcmHandle_t handle)
}
EXPORT_API
+int mm_sound_pcm_play_drain_async(MMSoundPcmHandle_t handle)
+{
+ int ret = 0;
+ mm_sound_pcm_async_t *pcmHandle = (mm_sound_pcm_async_t*)handle;
+
+ /* Check input param */
+ if(pcmHandle == NULL) {
+ debug_error ("Handle is null, return Invalid Argument\n");
+ ret = MM_ERROR_INVALID_ARGUMENT;
+ return ret;
+ }
+
+ debug_warning ("enter : handle=[%p]\n", handle);
+ ret = _mm_sound_pa_drain(handle);
+ debug_warning ("leave : handle=[%p], ret=[0x%X]\n", handle, ret);
+
+ return ret;
+}
+
+EXPORT_API
+int mm_sound_pcm_play_flush_async(MMSoundPcmHandle_t handle)
+{
+ int ret = 0;
+ mm_sound_pcm_async_t *pcmHandle = (mm_sound_pcm_async_t*)handle;
+
+ /* Check input param */
+ if(pcmHandle == NULL) {
+ debug_error ("Handle is null, return Invalid Argument\n");
+ ret = MM_ERROR_INVALID_ARGUMENT;
+ return ret;
+ }
+
+ debug_warning ("enter : handle=[%p]\n", handle);
+ ret = _mm_sound_pa_flush(handle);
+ debug_warning ("leave : handle=[%p], ret=[0x%X]\n", handle, ret);
+
+ return ret;
+}
+
+EXPORT_API
int mm_sound_pcm_play_write_async(MMSoundPcmHandle_t handle, void* ptr, unsigned int length_byte)
{
int ret = 0;
@@ -899,18 +960,10 @@ int mm_sound_pcm_play_write_async(MMSoundPcmHandle_t handle, void* ptr, unsigned
#endif
/* Write */
- /* Check whether voicerecorder is running */
- vconf_get_int(VCONFKEY_VOICERECORDER_STATE, &vr_state);
-
- if (vr_state == VCONFKEY_VOICERECORDER_RECORDING) {
- debug_log ("During VoiceRecording....MUTE!!!");
- } else {
- ret = pa_stream_write(pcmHandle->s, ptr, length_byte, NULL, 0LL, PA_SEEK_RELATIVE);
- if (ret == 0) {
- ret = length_byte;
- }
+ ret = pa_stream_write(pcmHandle->s, ptr, length_byte, NULL, 0LL, PA_SEEK_RELATIVE);
+ if (ret == 0) {
+ ret = length_byte;
}
-
EXIT:
// PCM_UNLOCK_INTERNAL(&pcmHandle->pcm_mutex_internal);
NULL_HANDLE:
@@ -1229,8 +1282,8 @@ static const pa_tizen_volume_type_t mm_sound_volume_type_to_pa[VOLUME_TYPE_MAX]
[VOLUME_TYPE_MEDIA] = PA_TIZEN_VOLUME_TYPE_MEDIA,
[VOLUME_TYPE_CALL] = PA_TIZEN_VOLUME_TYPE_CALL,
[VOLUME_TYPE_VOIP] = PA_TIZEN_VOLUME_TYPE_VOIP,
+ [VOLUME_TYPE_VOICE] = PA_TIZEN_VOLUME_TYPE_VOICE,
[VOLUME_TYPE_FIXED] = PA_TIZEN_VOLUME_TYPE_FIXED,
-// [VOLUME_TYPE_EXT_SYSTEM_JAVA] = PA_TIZEN_VOLUME_TYPE_EXT_JAVA,
};
static int mm_sound_pa_open(mm_sound_pcm_async_t* handle, int is_capture, int policy, int priority, int volume_config, pa_sample_spec* ss,
@@ -1409,6 +1462,39 @@ unlock_and_fail:
return -1;
}
+static int _mm_sound_pa_flush(mm_sound_pcm_async_t* handle)
+{
+ pa_operation *o = NULL;
+
+ MAINLOOP_LOCK(handle->mainloop);
+
+ o = pa_stream_flush(handle->s, (pa_stream_success_cb_t)__mm_sound_pa_success_cb, handle);
+ if (!(o)) {
+ goto unlock_and_fail;
+ }
+ handle->operation_success = 0;
+ while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) {
+ pa_threaded_mainloop_wait(handle->mainloop);
+ }
+ if (!(handle->operation_success)) {
+ goto unlock_and_fail;
+ }
+ pa_operation_unref(o);
+
+ MAINLOOP_UNLOCK(handle->mainloop);
+
+ return 0;
+
+unlock_and_fail:
+ debug_error ("error!!!!");
+ if (o) {
+ pa_operation_cancel(o);
+ pa_operation_unref(o);
+ }
+
+ MAINLOOP_UNLOCK(handle->mainloop);
+ return -1;
+}
static int _mm_sound_pa_get_latency(mm_sound_pcm_async_t* handle, int* latency)
{
diff --git a/packaging/libmm-sound.spec b/packaging/libmm-sound.spec
index 5c27929..5badadb 100644
--- a/packaging/libmm-sound.spec
+++ b/packaging/libmm-sound.spec
@@ -1,6 +1,6 @@
Name: libmm-sound
Summary: MMSound Package contains client lib and sound_server binary
-Version: 0.9.189
+Version: 0.9.255
Release: 0
Group: System/Libraries
License: Apache-2.0
@@ -19,14 +19,15 @@ BuildRequires: pkgconfig(gio-2.0)
BuildRequires: pkgconfig(vconf)
BuildRequires: pkgconfig(libpulse)
BuildRequires: pkgconfig(iniparser)
+%if "%{?tizen_profile_name}" != "tv"
BuildRequires: pkgconfig(capi-network-bluetooth)
+%endif
%ifarch %{arm}
%endif
%if "%{?tizen_profile_name}" == "wearable"
BuildRequires: pkgconfig(bluetooth-api)
%endif
BuildRequires: pkgconfig(libtremolo)
-BuildRequires: model-build-features
%description
MMSound Package contains client lib and sound_server binary for sound system
@@ -61,11 +62,16 @@ MMSound utility package - contians mm_sound_testsuite, sound_check for sound sys
%build
%define tizen_audio_feature_ogg_enable 1
+
+%if "%{?tizen_profile_name}" == "tv"
+%define tizen_audio_feature_bluetooth_enable 0
+%else
%define tizen_audio_feature_bluetooth_enable 1
+%endif
%if "%{?tizen_profile_name}" == "wearable"
%define tizen_audio_feature_hfp 1
-%else if
+%else
%define tizen_audio_feature_hfp 0
%endif
@@ -77,9 +83,10 @@ MMSound utility package - contians mm_sound_testsuite, sound_check for sound sys
%if "%{?tizen_profile_name}" == "wearable"
CFLAGS+=" -DTIZEN_MICRO";export CFLAGS
-%else if "%{?tizen_profile_name}" == "mobile"
%endif
-
+%if "%{?tizen_profile_name}" == "tv"
+ CFLAGS+=" -DTIZEN_TV";export CFLAGS
+%endif
%if 0%{?tizen_audio_feature_bluetooth_enable}
CFLAGS+=" -DSUPPORT_BT_SCO";export CFLAGS
%endif
@@ -120,34 +127,13 @@ ln -sf ../sound-server.path %{buildroot}%{_libdir}/systemd/system/multi-user.tar
%post
/sbin/ldconfig
-/usr/bin/vconftool set -t int memory/private/Sound/ASMReady 0 -g 29 -f -i -s system::vconf_multimedia
-/usr/bin/vconftool set -t double file/private/sound/volume/balance 0.0 -g 29 -f -s system::vconf_multimedia
-/usr/bin/vconftool set -t int file/private/sound/volume/muteall 0 -g 29 -f -s system::vconf_multimedia
-/usr/bin/vconftool set -t int memory/private/Sound/VoiceControlOn 0 -g 29 -f -i -s system::vconf_multimedia
-/usr/bin/vconftool set -t string memory/private/sound/booting "/usr/share/keysound/poweron.wav" -g 29 -f -i -s system::vconf_multimedia
-/usr/bin/vconftool set -t int memory/private/sound/PrimaryVolumetypeForce -1 -g 29 -f -i -s system::vconf_multimedia
-/usr/bin/vconftool set -t int memory/private/sound/PrimaryVolumetype -1 -g 29 -f -i -s system::vconf_multimedia
-/usr/bin/vconftool set -t int memory/private/sound/hdmisupport 0 -g 29 -f -i -s system::vconf_multimedia
-/usr/bin/vconftool set -t int memory/factory/loopback 0 -g 29 -f -i -s system::vconf_multimedia
-
-/usr/bin/vconftool set -t int file/private/sound/volume/system 9 -g 29 -f -s system::vconf_multimedia
-/usr/bin/vconftool set -t int file/private/sound/volume/notification 11 -g 29 -f -s system::vconf_multimedia
-/usr/bin/vconftool set -t int file/private/sound/volume/alarm 7 -g 29 -f -s system::vconf_multimedia
-/usr/bin/vconftool set -t int file/private/sound/volume/ringtone 11 -g 29 -f -s system::vconf_multimedia
-/usr/bin/vconftool set -t int file/private/sound/volume/media 7 -g 29 -f -s system::vconf_multimedia
-/usr/bin/vconftool set -t int file/private/sound/volume/call 4 -g 29 -f -s system::vconf_multimedia
-/usr/bin/vconftool set -t int file/private/sound/volume/voip 4 -g 29 -f -s system::vconf_multimedia
-/usr/bin/vconftool set -t int file/private/sound/volume/voice 7 -g 29 -f -s system::vconf_multimedia
-/usr/bin/vconftool set -t int file/private/sound/volume/fixed 0 -g 29 -f -s system::vconf_multimedia
-
-
%postun -p /sbin/ldconfig
%files
%manifest libmm-sound.manifest
%defattr(-,root,root,-)
-%{_bindir}/sound_server
+%caps(cap_chown,cap_dac_override,cap_fowner,cap_lease=eip) %{_bindir}/sound_server
%{_libdir}/libmmfsound.so.*
%{_libdir}/libmmfsoundcommon.so.*
%{_libdir}/libmmfkeysound.so.*
diff --git a/packaging/sound-server.service b/packaging/sound-server.service
index 288cdbf..29a42a3 100644
--- a/packaging/sound-server.service
+++ b/packaging/sound-server.service
@@ -1,7 +1,11 @@
[Unit]
Description=Start the sound profile service
+After=pulseaudio.service
[Service]
+User=system
+Group=system
+SmackProcessLabel=sound_server
ExecStart=/usr/bin/sound_server -S
ExecStop=/usr/bin/sound_server --poweroff
Restart=always
diff --git a/pkgconfig/Makefile.am b/pkgconfig/Makefile.am
index c5bb35c..2654b7d 100644
--- a/pkgconfig/Makefile.am
+++ b/pkgconfig/Makefile.am
@@ -2,7 +2,7 @@ pcfiles = mm-sound.pc mm-keysound.pc mm-bootsound.pc
all-local: $(pcfiles)
-%.pc: %.pc
+.pc: .pc
cp $< $@
pkgconfigdir= $(libdir)/pkgconfig
diff --git a/server/Makefile.am b/server/Makefile.am
index 06d65e0..cbe64a9 100644
--- a/server/Makefile.am
+++ b/server/Makefile.am
@@ -31,7 +31,7 @@ sound_server_CFLAGS = -I$(srcdir)/../include \
$(HEYNOTI_CFLAGS)
sound_server_LDADD = $(MMLOGSVR_LIBS) \
- -ldl \
+ -ldl -lrt \
$(MMCOMMON_LIBS) \
$(MMSESSION_LIBS) \
$(AUDIOSESSIONMGR_LIBS) \
diff --git a/server/include/mm_sound_mgr_pulse.h b/server/include/mm_sound_mgr_pulse.h
index 5a9bf75..1193478 100755
--- a/server/include/mm_sound_mgr_pulse.h
+++ b/server/include/mm_sound_mgr_pulse.h
@@ -34,10 +34,7 @@ void MMSoundMgrPulseSetDefaultSink (char* device_api_name, char* device_bus_name
void MMSoundMgrPulseSetDefaultSinkByName (char* name);
void MMSoundMgrPulseSetSourcemutebyname (char* sourcename, int mute);
-int MMSoundMgrPulseHandleRegisterMonoAudio (void* pinfo);
-int MMSoundMgrPulseHandleRegisterAudioBalance (void* pinfo);
int MMSoundMgrPulseHandleRegisterBluetoothStatus (void* pinfo);
-int MMSoundMgrPulseHandleRegisterSurroundSoundStatus(void *pinfo);
int MMSoundMgrPulseHandleIsBtA2DPOnReq (mm_ipc_msg_t *msg, int (*sendfunc)(mm_ipc_msg_t*));
void MMSoundMgrPulseGetInitialBTStatus (bool *a2dp, bool *sco);
@@ -50,13 +47,11 @@ bool MMSoundMgrPulseBTSCOWBStatus(void);
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 MMSoundMgrPulseUpdateVolume(void);
void MMSoundMgrPulseSetCorkAll (bool cork);
void MMSoundMgrPulseUnLoadHDMI();
void MMSoundMgrPulseGetPathInfo(mm_sound_device_out *device_out, mm_sound_device_in *device_in);
#ifdef TIZEN_MICRO
-void MMSoundMgrPulseSetMuteall(int mute);
void MMSoundMgrPulseSetVolumeLevel(volume_type_t volume_type, unsigned int volume_level);
#endif
void MMSoundMgrPulseSetVoicecontrolState (bool state);
diff --git a/server/mm_sound_mgr_asm.c b/server/mm_sound_mgr_asm.c
index e2057e7..c08860f 100644
--- a/server/mm_sound_mgr_asm.c
+++ b/server/mm_sound_mgr_asm.c
@@ -1,9 +1,9 @@
/*
* libmm-sound
*
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
*
- * Contact: Seungbae Shin <seungbae.shin@samsung.com>
+ * Contact: Sangchul Lee <sc11.lee at samsung.com>, Inhyeok Kim <i_bc.kim at samsung.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -192,9 +192,9 @@ typedef struct asm_compare_result
asm_instance_list_t* incoming_asm_handle[SERVER_HANDLE_MAX_COUNT];
} asm_compare_result_t;
-int asm_snd_msgid;
-int asm_rcv_msgid;
-int asm_cb_msgid;
+int asm_server_snd_msgid = -1;
+int asm_server_rcv_msgid = -1;
+int asm_server_cb_msgid = -1;
bool asm_is_send_msg_to_cb = false;
@@ -315,9 +315,17 @@ static char *subevent_str[] =
"SUB_EVENT_EXCLUSIVE"
};
-#define ASM_SND_MSG_SET_DEFAULT(asm_snd_msg, x_instance_id, x_alloc_handle, x_cmd_handle, x_source_request_id) \
+#define ASM_SND_MSG_SET_REGISTER(asm_snd_msg, x_instance_id, x_alloc_handle, x_cmd_handle, x_source_request_id) \
do { \
- asm_snd_msg.instance_id = x_instance_id; \
+ asm_snd_msg.msg_id = x_instance_id; \
+ asm_snd_msg.data.alloc_handle = x_alloc_handle; \
+ asm_snd_msg.data.cmd_handle = x_cmd_handle; \
+ asm_snd_msg.data.source_request_id = x_source_request_id; \
+} while (0)
+
+#define ASM_SND_MSG_SET_DEFAULT(asm_snd_msg, x_alloc_handle, x_cmd_handle, x_source_request_id) \
+do { \
+ asm_snd_msg.msg_id = x_alloc_handle; \
asm_snd_msg.data.alloc_handle = x_alloc_handle; \
asm_snd_msg.data.cmd_handle = x_cmd_handle; \
asm_snd_msg.data.source_request_id = x_source_request_id; \
@@ -1176,9 +1184,9 @@ void ___update_phone_status()
temp_list = temp_list->next;
}
- if (vconf_set_int(SOUND_STATUS_KEY, g_sound_status_playing)) {
+ if ((error = vconf_set_int(SOUND_STATUS_KEY, g_sound_status_playing))) {
debug_error("[ASM_Server[Error = %d][1st try] phonestatus_set \n", error);
- if (vconf_set_int(SOUND_STATUS_KEY, g_sound_status_playing)) {
+ if ((error = vconf_set_int(SOUND_STATUS_KEY, g_sound_status_playing))) {
debug_error("[Error = %d][2nd try] phonestatus_set \n", error);
}
}
@@ -1261,35 +1269,33 @@ int __asm_unregister_list(int handle)
return instance_id;
}
-/* -------------------------
- * if PID exist return true, else return false
- */
-gboolean ___is_pid_exist(int pid)
-{
- if (pid > 999999 || pid < 2)
- return FALSE;
- gchar *tmp = g_malloc0(25);
- if (!tmp)
- return FALSE;
- g_sprintf(tmp, "/proc/%d", pid);
- if (access(tmp, R_OK)==0) {
- g_free(tmp);
- return TRUE;
- }
- g_free(tmp);
- return FALSE;
-}
-
-/* -------------------------
- *
- */
-void __check_dead_process()
+static void __check_dead_process()
{
asm_instance_list_t *temp_list = head_list_ptr;
asm_instance_list_t *temp_list_prev = head_list_ptr;
while (temp_list != NULL) {
- if (!___is_pid_exist(temp_list->instance_id)) {
+ if (!mm_sound_util_is_process_alive(temp_list->instance_id)) {
debug_warning(" PID(%d) not exist! -> ASM_Server resource of pid(%d) will be cleared \n", temp_list->instance_id, temp_list->instance_id);
+ char str_error[256];
+ char* filename = g_strdup_printf("/tmp/ASM.%d.%d", temp_list->instance_id, temp_list->sound_handle);
+ char* filename2 = g_strdup_printf("/tmp/ASM.%d.%dr", temp_list->instance_id, temp_list->sound_handle);
+ if (!remove(filename)) {
+ debug_log(" remove %s success\n", filename);
+ } else {
+ strerror_r (errno, str_error, sizeof (str_error));
+ debug_error(" remove %s failed with %s\n", filename, str_error);
+ }
+
+ if (!remove(filename2)) {
+ debug_log(" remove %s success\n", filename2);
+ } else {
+ strerror_r (errno, str_error, sizeof (str_error));
+ debug_error(" remove %s failed with %s\n", filename2, str_error);
+ }
+
+ g_free(filename);
+ g_free(filename2);
+
if(temp_list->sound_event == ASM_EVENT_MMCAMCORDER_AUDIO || temp_list->sound_event == ASM_EVENT_MMCAMCORDER_VIDEO) {
debug_warning("dead process was camcorder init vconf");
vconf_set_int(VCONFKEY_RECORDER_STATE, 0);
@@ -1315,7 +1321,7 @@ void __check_dead_process()
}
} else {
if (temp_list->paused_by_id.pid) {
- if (!___is_pid_exist(temp_list->paused_by_id.pid)) {
+ if (!mm_sound_util_is_process_alive(temp_list->paused_by_id.pid)) {
temp_list->need_resume = ASM_NEED_NOT_RESUME;
temp_list->paused_by_id.pid = 0;
temp_list->paused_by_id.sound_handle = ASM_HANDLE_INIT_VAL;
@@ -1557,24 +1563,36 @@ void __asm_change_need_resume_list(int instance_id, int handle, ASM_resume_state
void __asm_create_message_queue()
{
- asm_rcv_msgid = msgget((key_t)2014, 0666 | IPC_CREAT);
- asm_snd_msgid = msgget((key_t)4102, 0666 | IPC_CREAT);
- asm_cb_msgid = msgget((key_t)4103, 0666 | IPC_CREAT);
+ asm_server_rcv_msgid = msgget((key_t)2014, 0666 | IPC_CREAT);
+ asm_server_snd_msgid = msgget((key_t)4102, 0666 | IPC_CREAT);
+ asm_server_cb_msgid = msgget((key_t)4103, 0666 | IPC_CREAT);
- if (asm_snd_msgid == -1 || asm_rcv_msgid == -1 || asm_cb_msgid == -1) {
+ if (asm_server_snd_msgid == -1 || asm_server_rcv_msgid == -1 || asm_server_cb_msgid == -1) {
debug_error(" msgget failed with error(%d,%s) \n", errno, strerror(errno));
exit(EXIT_FAILURE);
}
}
+void __asm_destroy_message_queue()
+{
+ if (asm_server_snd_msgid != -1 || asm_server_rcv_msgid != -1 || asm_server_cb_msgid != -1) {
+ msgctl(asm_server_rcv_msgid, IPC_RMID, NULL);
+ msgctl(asm_server_snd_msgid, IPC_RMID, NULL);
+ msgctl(asm_server_cb_msgid, IPC_RMID, NULL);
+ asm_server_snd_msgid = -1;
+ asm_server_rcv_msgid = -1;
+ asm_server_cb_msgid = -1;
+ }
+}
+
void __asm_snd_message(ASM_msg_asm_to_lib_t *asm_snd_msg)
{
- if (msgsnd(asm_snd_msgid, (void *)asm_snd_msg, sizeof(asm_snd_msg->data), 0) == -1) {
+ if (msgsnd(asm_server_snd_msgid, (void *)asm_snd_msg, sizeof(asm_snd_msg->data), 0) == -1) {
debug_error(" msgsnd failed with error %d\n", errno);
exit(EXIT_FAILURE);
} else {
- debug_warning(" success : handle(%d), pid(%d), result_state(%s), result_command(%s), source_request(%s)",
- asm_snd_msg->data.alloc_handle, asm_snd_msg->instance_id,
+ debug_warning(" success : handle(%d), mag_id(%d), result_state(%s), result_command(%s), source_request(%s)",
+ asm_snd_msg->data.alloc_handle, asm_snd_msg->msg_id,
ASM_sound_state_str[asm_snd_msg->data.result_sound_state],
ASM_sound_command_str[asm_snd_msg->data.result_sound_command],
ASM_sound_request_str[asm_snd_msg->data.source_request_id]);
@@ -1585,7 +1603,7 @@ void __asm_snd_message(ASM_msg_asm_to_lib_t *asm_snd_msg)
void __asm_rcv_message(ASM_msg_lib_to_asm_t *asm_rcv_msg)
{
- if (msgrcv(asm_rcv_msgid, (void *)asm_rcv_msg, sizeof(asm_rcv_msg->data), 0, 0) == -1) {
+ if (msgrcv(asm_server_rcv_msgid, (void *)asm_rcv_msg, sizeof(asm_rcv_msg->data), 0, 0) == -1) {
debug_error(" msgrcv failed with error %d\n", errno);
exit(EXIT_FAILURE);
} else {
@@ -2313,6 +2331,7 @@ CONFLICT_AGAIN:
debug_log(" Conflict policy[0x%x][0x%x]: %s\n", current_playing_sound_event, sound_event, ASM_sound_case_str[sound_case]);
switch (sound_case) {
+ case ASM_CASE_1PLAY_2PLAY_MIX:
case ASM_CASE_1PAUSE_2PLAY:
case ASM_CASE_1STOP_2PLAY:
{
@@ -2520,9 +2539,6 @@ int __asm_change_session (ASM_requests_t rcv_request, ASM_sound_events_t rcv_sou
case ASM_EVENT_EXCLUSIVE_RESOURCE:
if ( rcv_resource & ASM_RESOURCE_VOICECONTROL ) {
debug_warning (" ****** ASM_RESOURCE_VOICECONTROL START ******\n");
- if (vconf_set_int(VCONFKEY_SOUND_VOICE_CONTROL_STATUS, 1)) {
- debug_error(" vconf_set_int(SOUND_VOICE_CONTROL_KEY, 1) fail\n");
- }
MMSoundMgrSessionSetVoiceControlState(true);
}
break;
@@ -2749,9 +2765,6 @@ int __asm_change_session (ASM_requests_t rcv_request, ASM_sound_events_t rcv_sou
if ( rcv_resource & ASM_RESOURCE_VOICECONTROL ) {
debug_warning (" ****** ASM_RESOURCE_VOICECONTROL END ******\n");
MMSoundMgrSessionSetVoiceControlState(false);
- if (vconf_set_int(VCONFKEY_SOUND_VOICE_CONTROL_STATUS, 0)) {
- debug_error(" vconf_set_int(SOUND_VOICE_CONTROL_KEY, 0) fail\n");
- }
}
break;
default:
@@ -2923,7 +2936,7 @@ int __asm_process_message (void *rcv_msg, void *ret_msg)
pthread_mutex_lock(&g_mutex_asm);
debug_log (" ===================================================================== Started!!! (LOCKED) ");
- rcv_instance_id = asm_rcv_msg->instance_id;
+ rcv_instance_id = asm_rcv_msg->msg_id;
rcv_sound_handle = asm_rcv_msg->data.handle;
rcv_request_id = asm_rcv_msg->data.request_id;
rcv_sound_event = asm_rcv_msg->data.sound_event;
@@ -2941,7 +2954,7 @@ int __asm_process_message (void *rcv_msg, void *ret_msg)
debug_warning(" sub-event : %s\n", subevent_str[rcv_sound_event]);
} else if (rcv_request_id == ASM_REQUEST_SET_SESSION_OPTIONS) {
debug_warning(" session-options : %x\n", rcv_sound_event);
- } else if (rcv_request_id == ASM_REQUEST_GET_SUBSESSION || rcv_request_id == ASM_REQUEST_GET_SUBEVENT || ASM_REQUEST_GET_SESSION_OPTIONS) {
+ } else if (rcv_request_id == ASM_REQUEST_GET_SUBSESSION || rcv_request_id == ASM_REQUEST_GET_SUBEVENT || rcv_request_id == ASM_REQUEST_GET_SESSION_OPTIONS) {
/* no log */
} else {
debug_warning(" sound_event : %s\n", ASM_sound_event_str[rcv_sound_event]);
@@ -2959,7 +2972,7 @@ int __asm_process_message (void *rcv_msg, void *ret_msg)
__asm_get_empty_handle(rcv_instance_id, &rcv_sound_handle);
if (rcv_sound_handle == ASM_HANDLE_INIT_VAL) {
- ASM_SND_MSG_SET_DEFAULT(asm_snd_msg, rcv_instance_id, ASM_HANDLE_INIT_VAL, ASM_HANDLE_INIT_VAL, rcv_request_id);
+ ASM_SND_MSG_SET_REGISTER(asm_snd_msg, rcv_instance_id, ASM_HANDLE_INIT_VAL, ASM_HANDLE_INIT_VAL, rcv_request_id);
if (asm_ret_msg == NULL) {
__asm_snd_message(&asm_snd_msg);
}
@@ -2974,7 +2987,7 @@ int __asm_process_message (void *rcv_msg, void *ret_msg)
debug_error (" failed to __asm_change_session(), error(0x%x)", ret);
}
}
- ASM_SND_MSG_SET_DEFAULT(asm_snd_msg, rcv_instance_id, rcv_sound_handle, rcv_sound_handle, rcv_request_id);
+ ASM_SND_MSG_SET_REGISTER(asm_snd_msg, rcv_instance_id, rcv_sound_handle, rcv_sound_handle, rcv_request_id);
if (asm_ret_msg == NULL) {
__asm_snd_message(&asm_snd_msg);
}
@@ -2987,10 +3000,20 @@ int __asm_process_message (void *rcv_msg, void *ret_msg)
asm_instance_h = __asm_find_list(rcv_sound_handle);
bool need_to_resume = false;
+ volume_type_t type;
ret = __asm_change_session (rcv_request_id, rcv_sound_event, rcv_sound_state,
(asm_instance_h)? asm_instance_h->mm_resource : rcv_resource,
true, &need_to_resume);
+ if(rcv_sound_event == ASM_EVENT_CALL || rcv_sound_event == ASM_EVENT_VIDEOCALL || rcv_sound_event == ASM_EVENT_VOIP) {
+ mm_sound_volume_get_current_playing_type(&type);
+ if (type == VOLUME_TYPE_CALL) {
+ ret = mm_sound_volume_primary_type_clear();
+ if (ret)
+ debug_error("mm_sound_volume_primary_type_clear failed, ret = 0x%x", ret);
+ }
+ }
+
/* enforce calling watch callback when current state of rcv_instance_id is still ASM_STATE_PLAYING */
/* need to call the watch callback of Call event(STOP) because Call session is changed in ASM_REQUEST_UNREGISTER */
if (__asm_find_state_of_handle(rcv_sound_handle) == ASM_STATE_PLAYING ||
@@ -3013,7 +3036,7 @@ int __asm_process_message (void *rcv_msg, void *ret_msg)
case ASM_REQUEST_SETSTATE:
__check_dead_process();
- ASM_SND_MSG_SET_DEFAULT(asm_snd_msg, rcv_instance_id, rcv_sound_handle, rcv_sound_handle, rcv_request_id);
+ ASM_SND_MSG_SET_DEFAULT(asm_snd_msg, rcv_sound_handle, rcv_sound_handle, rcv_request_id);
if (rcv_sound_state == ASM_STATE_PLAYING || rcv_sound_state == ASM_STATE_WAITING) {
if ( __is_it_playing_now(rcv_instance_id, rcv_sound_handle)) {
__asm_change_state_list(rcv_instance_id, rcv_sound_handle, rcv_sound_state, rcv_resource);
@@ -3107,7 +3130,7 @@ int __asm_process_message (void *rcv_msg, void *ret_msg)
asm_snd_msg.data.result_sound_state = asm_instance_h->sound_state;
asm_snd_msg.data.source_request_id = rcv_request_id;
}
- ASM_SND_MSG_SET_DEFAULT(asm_snd_msg, rcv_instance_id, rcv_sound_handle, rcv_sound_handle, rcv_request_id);
+ ASM_SND_MSG_SET_DEFAULT(asm_snd_msg, rcv_sound_handle, rcv_sound_handle, rcv_request_id);
if (asm_ret_msg == NULL) {
__asm_snd_message(&asm_snd_msg);
}
@@ -3116,7 +3139,7 @@ int __asm_process_message (void *rcv_msg, void *ret_msg)
case ASM_REQUEST_GETMYSTATE:
__check_dead_process();
- ASM_SND_MSG_SET_DEFAULT(asm_snd_msg, rcv_instance_id, rcv_sound_handle, rcv_sound_handle, rcv_request_id);
+ ASM_SND_MSG_SET_DEFAULT(asm_snd_msg, rcv_sound_handle, rcv_sound_handle, rcv_request_id);
asm_snd_msg.data.result_sound_state = __asm_find_process_status(rcv_instance_id);
if (asm_ret_msg == NULL) {
__asm_snd_message(&asm_snd_msg);
@@ -3146,6 +3169,10 @@ int __asm_process_message (void *rcv_msg, void *ret_msg)
case ASM_EVENT_VOIP:
{
if (rcv_subsession == SUBSESSION_VOICE) {
+ ret = mm_sound_volume_primary_type_set(VOLUME_TYPE_CALL);
+ if (ret)
+ debug_error("failed to mm_sound_volume_primary_type_set, ret = 0x%x", ret);
+
/*check camcoder status
special case check :
call & camcorder EX session can be mixed in Call Ringtone subsession
@@ -3279,7 +3306,7 @@ int __asm_process_message (void *rcv_msg, void *ret_msg)
}
/* Return result msg */
- ASM_SND_MSG_SET_DEFAULT(asm_snd_msg, rcv_instance_id, rcv_sound_handle, rcv_sound_handle, rcv_request_id);
+ ASM_SND_MSG_SET_DEFAULT(asm_snd_msg, rcv_sound_handle, rcv_sound_handle, rcv_request_id);
if (asm_ret_msg == NULL) {
__asm_snd_message(&asm_snd_msg);
}
@@ -3300,7 +3327,7 @@ int __asm_process_message (void *rcv_msg, void *ret_msg)
/* Return result msg */
asm_snd_msg.data.result_sound_command = subsession;
- ASM_SND_MSG_SET_DEFAULT(asm_snd_msg, rcv_instance_id, rcv_sound_handle, rcv_sound_handle, rcv_request_id);
+ ASM_SND_MSG_SET_DEFAULT(asm_snd_msg, rcv_sound_handle, rcv_sound_handle, rcv_request_id);
if (asm_ret_msg == NULL) {
__asm_snd_message(&asm_snd_msg);
}
@@ -3335,7 +3362,7 @@ int __asm_process_message (void *rcv_msg, void *ret_msg)
debug_warning (" ****** SUB-EVENT [%s] ******\n", ASM_sound_sub_event_str[rcv_subevent]);
__asm_change_sub_event_list(rcv_instance_id, rcv_sound_handle, rcv_subevent);
- ASM_SND_MSG_SET_DEFAULT(asm_snd_msg, rcv_instance_id, rcv_sound_handle, rcv_sound_handle, rcv_request_id);
+ ASM_SND_MSG_SET_DEFAULT(asm_snd_msg, rcv_sound_handle, rcv_sound_handle, rcv_request_id);
if (rcv_subevent == ASM_SUB_EVENT_NONE) {
/* NOTE: special case, resume paused list here */
@@ -3368,7 +3395,7 @@ int __asm_process_message (void *rcv_msg, void *ret_msg)
}
case ASM_REQUEST_GET_SUBEVENT:
- ASM_SND_MSG_SET_DEFAULT(asm_snd_msg, rcv_instance_id, rcv_sound_handle, rcv_sound_handle, rcv_request_id);
+ ASM_SND_MSG_SET_DEFAULT(asm_snd_msg, rcv_sound_handle, rcv_sound_handle, rcv_request_id);
/* Return result msg */
asm_instance_h = __asm_find_list(rcv_sound_handle);
asm_snd_msg.data.result_sound_command = (asm_instance_h ? asm_instance_h->sound_sub_event : ASM_SUB_EVENT_NONE);
@@ -3402,7 +3429,7 @@ int __asm_process_message (void *rcv_msg, void *ret_msg)
asm_snd_msg.data.error_code = ERR_ASM_SERVER_HANDLE_IS_INVALID;
}
- ASM_SND_MSG_SET_DEFAULT(asm_snd_msg, rcv_instance_id, rcv_sound_handle, rcv_sound_handle, rcv_request_id);
+ ASM_SND_MSG_SET_DEFAULT(asm_snd_msg, rcv_sound_handle, rcv_sound_handle, rcv_request_id);
if (asm_ret_msg == NULL) {
__asm_snd_message(&asm_snd_msg);
}
@@ -3410,7 +3437,7 @@ int __asm_process_message (void *rcv_msg, void *ret_msg)
}
case ASM_REQUEST_GET_SESSION_OPTIONS:
- ASM_SND_MSG_SET_DEFAULT(asm_snd_msg, rcv_instance_id, rcv_sound_handle, rcv_sound_handle, rcv_request_id);
+ ASM_SND_MSG_SET_DEFAULT(asm_snd_msg, rcv_sound_handle, rcv_sound_handle, rcv_request_id);
/* Return result msg */
asm_instance_h = __asm_find_list(rcv_sound_handle);
asm_snd_msg.data.option_flags = (asm_instance_h ? asm_instance_h->option_flags : 0);
@@ -3472,12 +3499,12 @@ int __asm_process_message (void *rcv_msg, void *ret_msg)
__asm_get_empty_handle(rcv_instance_id, &rcv_sound_handle);
if (rcv_sound_handle == ASM_HANDLE_INIT_VAL) {
- ASM_SND_MSG_SET_DEFAULT(asm_snd_msg, rcv_instance_id, ASM_HANDLE_INIT_VAL, ASM_HANDLE_INIT_VAL, rcv_request_id);
+ ASM_SND_MSG_SET_REGISTER(asm_snd_msg, rcv_instance_id, ASM_HANDLE_INIT_VAL, ASM_HANDLE_INIT_VAL, rcv_request_id);
if (asm_ret_msg == NULL) {
__asm_snd_message(&asm_snd_msg);
}
} else {
- ASM_SND_MSG_SET_DEFAULT(asm_snd_msg, rcv_instance_id, rcv_sound_handle, rcv_sound_handle, rcv_request_id);
+ ASM_SND_MSG_SET_REGISTER(asm_snd_msg, rcv_instance_id, rcv_sound_handle, rcv_sound_handle, rcv_request_id);
asm_snd_msg.data.result_sound_command = ASM_COMMAND_PLAY;
asm_snd_msg.data.result_sound_state = rcv_sound_state;
if (asm_ret_msg == NULL) {
@@ -3502,7 +3529,7 @@ int __asm_process_message (void *rcv_msg, void *ret_msg)
} else {
__reset_resume_check(found_pid, rcv_sound_handle);
}
- ASM_SND_MSG_SET_DEFAULT(asm_snd_msg, rcv_instance_id, rcv_sound_handle, rcv_sound_handle, rcv_request_id);
+ ASM_SND_MSG_SET_DEFAULT(asm_snd_msg, rcv_sound_handle, rcv_sound_handle, rcv_request_id);
asm_snd_msg.data.result_sound_command = ASM_COMMAND_PLAY;
asm_snd_msg.data.result_sound_state = rcv_sound_state;
if (asm_ret_msg == NULL) {
@@ -3534,21 +3561,6 @@ void __asm_main_run (void* param)
/* Init Msg Queue */
__asm_create_message_queue();
- int temp_msgctl_id1 = msgctl(asm_snd_msgid, IPC_RMID, 0);
- int temp_msgctl_id2 = msgctl(asm_rcv_msgid, IPC_RMID, 0);
- int temp_msgctl_id3 = msgctl(asm_cb_msgid, IPC_RMID, 0);
-
- if (temp_msgctl_id1 == -1 || temp_msgctl_id2 == -1 || temp_msgctl_id3 == -1) {
- debug_error(" msgctl failed with error(%d,%s) \n", errno, strerror(errno));
- exit(EXIT_FAILURE);
- }
- //-------------------------------------------------------------------
- /*
- This is unnessasry finaly, but nessasary during implement.
- */
- /* FIXME: Do we need to do this again ? */
- __asm_create_message_queue();
-
/*
* Init Vconf
*/
@@ -3559,11 +3571,6 @@ void __asm_main_run (void* param)
}
}
- /* Set READY flag */
- if (vconf_set_int(ASM_READY_KEY, 1)) {
- debug_error(" vconf_set_int fail\n");
- }
-
/* Msg Loop */
while (true) {
debug_log(" asm_Server is waiting message(%d)!!!\n", asm_is_send_msg_to_cb);
@@ -3600,6 +3607,8 @@ int MMSoundMgrASMFini(void)
{
debug_fenter();
+ __asm_destroy_message_queue();
+
debug_fleave();
return MM_ERROR_NONE;
}
diff --git a/server/mm_sound_mgr_device.c b/server/mm_sound_mgr_device.c
index c6158b2..7a230bf 100755
--- a/server/mm_sound_mgr_device.c
+++ b/server/mm_sound_mgr_device.c
@@ -54,6 +54,7 @@
#define MAX_SUPPORT_DEVICE_NUM 256
static char g_device_id_array[MAX_SUPPORT_DEVICE_NUM];
+static pthread_mutex_t g_device_id_array_mutex = PTHREAD_MUTEX_INITIALIZER;
void _mm_sound_get_devices_from_route(mm_sound_route route, mm_sound_device_in *device_in, mm_sound_device_out *device_out);
@@ -77,7 +78,7 @@ 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] = {
+static char *g_volume_vconf[VOLUME_TYPE_VCONF_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 */
@@ -86,7 +87,6 @@ static char *g_volume_vconf[VOLUME_TYPE_MAX] = {
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)
@@ -95,7 +95,7 @@ int _mm_sound_mgr_device_init(void)
int ret = MM_ERROR_NONE;
debug_fenter();
- for(i = 0 ; i < VOLUME_TYPE_MAX; i++) {
+ for (i = 0; i < VOLUME_TYPE_VCONF_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;
@@ -649,13 +649,17 @@ int _mm_sound_mgr_device_remove_info_changed_callback(const _mm_sound_mgr_device
return ret;
}
-/* debug_warning ("cb_list = %p, cb_param = %p, pid=[%d]", x, cb_param, (cb_param)? cb_param->pid : -1); \ remove logs*/
#define CLEAR_DEAD_CB_LIST(x) do { \
- debug_warning ("cb_list = %p, cb_param = %p, pid=[%d]", x, cb_param, (cb_param)? cb_param->pid : -1); \
- if (x && cb_param && __mm_sound_mgr_device_check_process (cb_param->pid) != 0) { \
- 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); \
+ 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); \
+ x = g_list_remove (x, cb_param); \
+ g_free (cb_param); \
+ } \
+ } else { \
+ debug_error ("Invalid list or param"); \
} \
}while(0)
@@ -938,62 +942,55 @@ FINISH:
return ret;
}
-int _mm_sound_mgr_device_update_volume()
+int _get_new_device_id(int *new_id)
{
- int i=0;
- char* str = NULL;
+ int device_id = -1;
+ int cnt = 0;
int ret = MM_ERROR_NONE;
- for (i=0; i<VOLUME_TYPE_MAX; i++) {
- /* Update vconf */
- str = vconf_get_str(g_volume_vconf[i]);
- /* FIXME : Need to check history */
- /*
- if (vconf_set_str_no_fdatasync(g_volume_vconf[i], str) != 0) {
- debug_error("vconf_set_str_no_fdatasync(%s) failed", g_volume_vconf[i]);
- ret = MM_ERROR_SOUND_INTERNAL;
- continue;
- }
- */
- if(str != NULL) {
- free(str);
- str = NULL;
+ if (!new_id) {
+ debug_error("device_h is null, could not set device id");
+ return MM_ERROR_SOUND_INTERNAL;
+ }
+
+ MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_device_id_array_mutex, MM_ERROR_SOUND_INTERNAL);
+ for (cnt = 0; cnt < MAX_SUPPORT_DEVICE_NUM; cnt++) {
+ if (g_device_id_array[cnt] == 0) {
+ break;
}
}
+ if (cnt == MAX_SUPPORT_DEVICE_NUM) {
+ debug_error("could not get a new id, device array is full\n");
+ ret = MM_ERROR_SOUND_INTERNAL;
+ } else {
+ device_id = cnt;
+ g_device_id_array[cnt] = 1;
+ }
+
+ MMSOUND_LEAVE_CRITICAL_SECTION(&g_device_id_array_mutex);
+ *new_id = device_id;
return ret;
}
#define RELEASE_DEVICE_INFO_ID(x_id) \
do { \
+ MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_device_id_array_mutex, MM_ERROR_SOUND_INTERNAL); \
if (g_device_id_array[x_id] == 1) { \
g_device_id_array[x_id] = 0; \
} else { \
debug_error("could not release the id[%d]\n", x_id); \
} \
+ MMSOUND_LEAVE_CRITICAL_SECTION(&g_device_id_array_mutex); \
} while(0)
-#define SET_DEVICE_INFO_ID_AUTO(x_device_h) \
+#define SET_DEVICE_INFO_ID(x_device_h, x_id) \
do { \
- int device_id = 0; \
- int cnt = 0; \
if (!x_device_h) { \
- debug_error("device_h is null, could not set device id"); \
+ debug_error("device_h is null, could not set device type"); \
break; \
} \
- for (cnt = 0; cnt < MAX_SUPPORT_DEVICE_NUM; cnt++) { \
- if (g_device_id_array[cnt] == 0) { \
- break; \
- } \
- } \
- if (cnt == MAX_SUPPORT_DEVICE_NUM) { \
- 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; \
- } \
- x_device_h->id = device_id; \
+ x_device_h->id = x_id; \
} while(0)
#define GET_DEVICE_INFO_ID(x_device_h, x_id) \
@@ -1115,9 +1112,9 @@ static int __mm_sound_mgr_device_check_flags_to_trigger (int device_flags, mm_so
}
if (need_to_check_for_io_direction) {
- if ((device_h->io_direction == DEVICE_IO_DIRECTION_IN) && (device_flags & DEVICE_IO_DIRECTION_IN_FLAG)) {
+ if ((device_h->io_direction == DEVICE_IO_DIRECTION_IN || device_h->io_direction == DEVICE_IO_DIRECTION_BOTH) && (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)) {
+ } else if ((device_h->io_direction == DEVICE_IO_DIRECTION_OUT || device_h->io_direction == DEVICE_IO_DIRECTION_BOTH) && (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;
@@ -1387,22 +1384,28 @@ int MMSoundMgrDeviceGetIoDirectionById (int id, device_io_direction_e *io_direct
/* 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",
+ int ret = MM_ERROR_NONE;
+ debug_log ("[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;
+ int new_id = -1;
/* 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);
+ ret = _mm_sound_mgr_device_connected_dev_list_find_item(&device_h, device_type, id);
if(ret == MM_ERROR_SOUND_NO_DATA && !device_h) {
+ if ((ret = _get_new_device_id(&new_id)) != MM_ERROR_NONE) {
+ debug_error("failed to get new device id");
+ break;
+ }
/* 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);
+ RELEASE_DEVICE_INFO_ID(new_id);
} else {
- debug_error("update info for this device_h[0x%x]\n", device_h);
+ debug_log("update info for this device_h[0x%x]\n", device_h);
/* update device information */
/* 1. type */
SET_DEVICE_INFO_TYPE(device_h, device_type);
@@ -1413,7 +1416,7 @@ int MMSoundMgrDeviceUpdateStatus (device_update_status_e update_status, device_t
/* 4. state */
SET_DEVICE_INFO_STATE(device_h, DEVICE_STATE_DEACTIVATED);
/* 4. id */
- SET_DEVICE_INFO_ID_AUTO(device_h);
+ SET_DEVICE_INFO_ID(device_h, new_id);
GET_DEVICE_INFO_ID(device_h, alloc_id);
_mm_sound_mgr_device_connected_dev_list_dump();
@@ -1437,7 +1440,6 @@ int MMSoundMgrDeviceUpdateStatus (device_update_status_e update_status, device_t
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();
@@ -1486,7 +1488,6 @@ int MMSoundMgrDeviceUpdateStatus (device_update_status_e update_status, device_t
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);
@@ -1514,7 +1515,6 @@ int MMSoundMgrDeviceUpdateStatus (device_update_status_e update_status, device_t
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);
@@ -1541,26 +1541,32 @@ int MMSoundMgrDeviceUpdateStatus (device_update_status_e update_status, device_t
break;
}
- return MM_ERROR_NONE;
+ return ret;
}
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)
{
+ int ret = MM_ERROR_NONE;
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;
+ int new_id = -1;
/* 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);
+ if ((ret = _get_new_device_id(&new_id)) != MM_ERROR_NONE) {
+ debug_error("failed to get new device id");
+ break;
+ }
/* 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);
+ RELEASE_DEVICE_INFO_ID(new_id);
} else {
debug_error("update info for this device_h[0x%x]\n", device_h);
/* update device information */
@@ -1573,7 +1579,7 @@ int MMSoundMgrDeviceUpdateStatusWithoutNotification (device_update_status_e upda
/* 4. state */
SET_DEVICE_INFO_STATE(device_h, DEVICE_STATE_DEACTIVATED);
/* 4. id */
- SET_DEVICE_INFO_ID_AUTO(device_h);
+ SET_DEVICE_INFO_ID(device_h, new_id);
GET_DEVICE_INFO_ID(device_h, alloc_id);
_mm_sound_mgr_device_connected_dev_list_dump();
@@ -1592,7 +1598,6 @@ int MMSoundMgrDeviceUpdateStatusWithoutNotification (device_update_status_e upda
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();
@@ -1625,7 +1630,6 @@ int MMSoundMgrDeviceUpdateStatusWithoutNotification (device_update_status_e upda
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);
@@ -1649,7 +1653,6 @@ int MMSoundMgrDeviceUpdateStatusWithoutNotification (device_update_status_e upda
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);
@@ -1672,5 +1675,5 @@ int MMSoundMgrDeviceUpdateStatusWithoutNotification (device_update_status_e upda
break;
}
- return MM_ERROR_NONE;
+ return ret;
}
diff --git a/server/mm_sound_mgr_device_hdmi.c b/server/mm_sound_mgr_device_hdmi.c
index 54ad42e..ea2d193 100755
--- a/server/mm_sound_mgr_device_hdmi.c
+++ b/server/mm_sound_mgr_device_hdmi.c
@@ -179,8 +179,10 @@ int _init_hdmi_audio_dbus(void)
return 0;
sig_error:
- g_dbus_connection_signal_unsubscribe(conn_hdmiaudio, sig_id_hdmiaudio);
- g_object_unref(conn_hdmiaudio);
+ if (conn_hdmiaudio) {
+ g_dbus_connection_signal_unsubscribe(conn_hdmiaudio, sig_id_hdmiaudio);
+ g_object_unref(conn_hdmiaudio);
+ }
error:
return -1;
diff --git a/server/mm_sound_mgr_device_wfd.c b/server/mm_sound_mgr_device_wfd.c
index c36aa4f..be1ffdb 100644
--- a/server/mm_sound_mgr_device_wfd.c
+++ b/server/mm_sound_mgr_device_wfd.c
@@ -32,6 +32,8 @@
#include <errno.h>
+#include <gio/gio.h>
+
#include "include/mm_sound_mgr_common.h"
#include "../include/mm_sound_common.h"
@@ -46,37 +48,87 @@
#include "mm_sound.h"
-#include <vconf.h>
-#include <vconf-keys.h>
+#define DBUS_INTERFACE_MIRRORING_SERVER "org.tizen.scmirroring.server"
+#define DBUS_OBJECT_MIRRORING_SERVER "/org/tizen/scmirroring/server"
+#define DBUS_SIGNAL_MIRRORING_CHANGED "miracast_wfd_source_status_changed"
+GDBusConnection *conn_wfd;
+guint sig_id_wfd;
-/* WFD status value */
-static void _miracast_wfd_status_changed_cb(keynode_t* node, void* data)
+static void _wfd_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 miracast_wfd_status = 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)", &miracast_wfd_status);
+ debug_msg("singal[%s] = %X\n", DBUS_SIGNAL_MIRRORING_CHANGED, 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);
+
+ } else {
+ value_type = g_variant_get_type(parameters);
+ debug_warning("signal type is %s", value_type);
+ }
+}
- /* 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);
+void _deinit_wfd_dbus(void)
+{
+ debug_fenter ();
+ g_dbus_connection_signal_unsubscribe(conn_wfd, sig_id_wfd);
+ g_object_unref(conn_wfd);
+ debug_fleave ();
}
-static int _register_wfd_status(void)
+int _init_wfd_dbus(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;
+ GError *err = NULL;
+ debug_fenter ();
+
+ g_type_init();
+
+ conn_wfd = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
+ if (!conn_wfd && err) {
+ debug_error ("g_bus_get_sync() error (%s) ", err->message);
+ g_error_free (err);
+ goto error;
+ }
+
+ sig_id_wfd = g_dbus_connection_signal_subscribe(conn_wfd,
+ NULL, DBUS_INTERFACE_MIRRORING_SERVER, DBUS_SIGNAL_MIRRORING_CHANGED, DBUS_OBJECT_MIRRORING_SERVER, NULL, 0,
+ _wfd_status_changed, NULL, NULL);
+ if (sig_id_wfd == 0) {
+ debug_error ("g_dbus_connection_signal_subscribe() error (%d)", sig_id_wfd);
+ goto sig_error;
+ }
+
+ debug_fleave ();
+ return 0;
+
+sig_error:
+ g_dbus_connection_signal_unsubscribe(conn_wfd, sig_id_wfd);
+ if (conn_wfd)
+ g_object_unref(conn_wfd);
+
+error:
+ return -1;
+
}
int MMSoundMgrWfdInit(void)
{
debug_enter("\n");
- if (_register_wfd_status() != 0) {
- debug_error ("Registering WFD status failed\n");
+ if (_init_wfd_dbus() != 0) {
+ debug_error ("Registering WFD signal handler failed\n");
return MM_ERROR_SOUND_INTERNAL;
}
@@ -88,6 +140,8 @@ int MMSoundMgrWfdFini(void)
{
debug_enter("\n");
+ _deinit_wfd_dbus();
+
debug_leave("\n");
return MM_ERROR_NONE;
}
diff --git a/server/mm_sound_mgr_ipc.c b/server/mm_sound_mgr_ipc.c
index 70876fb..28e706c 100644
--- a/server/mm_sound_mgr_ipc.c
+++ b/server/mm_sound_mgr_ipc.c
@@ -462,8 +462,8 @@ static void _MMSoundMgrRun(void *data)
respmsg.sound_msg.total_device_num = total_num_of_device;
for (list = device_list; list != NULL; list = list->next) {
memcpy(&(respmsg.sound_msg.device_handle), (mm_sound_device_t*)list->data, sizeof(mm_sound_device_t));
- debug_msg("[Server] memory copied to msg device handle(handle[0x%x], type[%d], id[%d]), before sending device info, total [%d] msg remains\n",
- &(respmsg.sound_msg.device_handle), ((mm_sound_device_t*)list->data)->type, ((mm_sound_device_t*)list->data)->id, total_num_of_device);
+ debug_msg("[Server] memory copied to msg device handle(handle[0x%x], type[%d], direction[0x%x], id[%d]), before sending device info, total [%d] msg remains\n",
+ &(respmsg.sound_msg.device_handle), ((mm_sound_device_t*)list->data)->type, ((mm_sound_device_t*)list->data)->io_direction,((mm_sound_device_t*)list->data)->id, total_num_of_device);
if (total_num_of_device-- > 1) {
ret = _MMIpcSndMsg(&respmsg);
if (ret != MM_ERROR_NONE) {
@@ -1100,7 +1100,8 @@ int __mm_sound_mgr_ipc_freeze_send (char* command, int pid)
{
GError *err = NULL;
GDBusConnection *conn = NULL;
- gboolean ret;
+ gboolean dbus_ret;
+ int ret = MM_ERROR_NONE;
if (command == NULL || pid <= 0) {
debug_error ("invalid arguments [%s][%d]", command, pid);
@@ -1110,34 +1111,36 @@ int __mm_sound_mgr_ipc_freeze_send (char* command, int pid)
conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
if (!conn && err) {
debug_error ("g_bus_get_sync() error (%s) ", err->message);
- g_error_free (err);
- return -1;
+ ret = MM_ERROR_SOUND_INTERNAL;
+ goto end;
}
- ret = g_dbus_connection_emit_signal (conn,
+ dbus_ret = g_dbus_connection_emit_signal (conn,
NULL, PROC_DBUS_OBJECT, PROC_DBUS_INTERFACE, PROC_DBUS_METHOD,
g_variant_new ("(si)", command, pid),
&err);
- if (!ret && err) {
+ if (!dbus_ret && err) {
debug_error ("g_dbus_connection_emit_signal() error (%s) ", err->message);
- goto error;
+ ret = MM_ERROR_SOUND_INTERNAL;
+ goto end;
}
- ret = g_dbus_connection_flush_sync(conn, NULL, &err);
- if (!ret && err) {
+ dbus_ret = g_dbus_connection_flush_sync(conn, NULL, &err);
+ if (!dbus_ret && err) {
debug_error ("g_dbus_connection_flush_sync() error (%s) ", err->message);
- goto error;
+ ret = MM_ERROR_SOUND_INTERNAL;
+ goto end;
}
- g_object_unref(conn);
- debug_msg ("sending [%s] for pid (%d) success", command, pid);
+end:
+ if (err)
+ g_error_free (err);
+ if (conn)
+ g_object_unref(conn);
- return 0;
+ debug_msg ("sending [%s] for pid (%d) %s", command, pid, ret == MM_ERROR_NONE ? "success" : "failed");
-error:
- g_error_free (err);
- g_object_unref(conn);
- return -1;
+ return ret;
}
static int _MMIpcRecvMsg(int msgtype, mm_ipc_msg_t *msg)
diff --git a/server/mm_sound_mgr_pulse.c b/server/mm_sound_mgr_pulse.c
index 8f966a9..0a3408d 100755
--- a/server/mm_sound_mgr_pulse.c
+++ b/server/mm_sound_mgr_pulse.c
@@ -47,12 +47,9 @@
#include <pulse/ext-policy.h>
#include <pulse/ext-echo-cancel.h>
-#define SUPPORT_MONO_AUDIO
-#define SUPPORT_AUDIO_BALANCE
#ifdef SUPPORT_BT_SCO
#define SUPPORT_BT_SCO_DETECT
#endif
-#define SUPPORT_AUDIO_MUTEALL
#include "include/mm_sound_mgr_pulse.h"
#include "include/mm_sound_mgr_session.h"
@@ -66,6 +63,8 @@
#ifdef SUPPORT_BT_SCO_DETECT
#include "bluetooth.h"
+#include <bluetooth_internal.h>
+#include <bluetooth_extension.h>
#ifdef TIZEN_MICRO
#include "bluetooth-api.h"
#include "bluetooth-audio-api.h"
@@ -148,6 +147,13 @@ pthread_mutex_t g_mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t g_bt_info_mutex = PTHREAD_MUTEX_INITIALIZER;
int g_alloc_device_id = -1;
+enum {
+ BT_FLAG_SCO_AVAIL = 0x1,
+ BT_FLAG_A2DP_AVAIL = 0x2,
+ BT_FLAG_SCO_OPENED = 0x4,
+};
+static int g_bt_flag = 0;
+
path_info_t g_path_info;
pulse_info_t* pulse_info = NULL;
#ifdef TIZEN_MICRO
@@ -300,18 +306,21 @@ static void new_card_info_cb (pa_context *c, const pa_card_info *i, int eol, voi
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 (!(g_bt_flag & BT_FLAG_SCO_AVAIL)) {
+ ret = MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CONNECTED, DEVICE_TYPE_BLUETOOTH, DEVICE_IO_DIRECTION_OUT, 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);
+ } else {
+ g_bt_flag |= BT_FLAG_A2DP_AVAIL;
}
-
}
- 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);
+ if (!(g_bt_flag & BT_FLAG_SCO_OPENED)) {
+ 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 */
@@ -427,15 +436,13 @@ void *pulse_client_thread_run (void *args)
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);
+
+ if ((g_bt_flag & BT_FLAG_A2DP_AVAIL) && !(g_bt_flag & BT_FLAG_SCO_AVAIL)) {
+ MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_DISCONNECTED, DEVICE_TYPE_BLUETOOTH, MM_SOUND_DEVICE_IO_DIRECTION_OUT, g_alloc_device_id, NULL, 0, 0);
g_alloc_device_id = -1;
}
+ g_bt_flag &= ~BT_FLAG_A2DP_AVAIL;
+
pinfo->bt_idx = PA_INVALID_INDEX;
pinfo->device_type = PA_INVALID_INDEX;
} else if(pinfo->device_type == DEVICE_USB_AUDIO) {
@@ -672,292 +679,6 @@ static void unload_hdmi_cb(pa_context *c, int success, void *userdata)
pa_threaded_mainloop_signal(pinfo->m, 0);
}
-/* -------------------------------- MONO AUDIO --------------------------------------------*/
-#ifdef SUPPORT_MONO_AUDIO
-#define TOUCH_SOUND_PLAY_COMLETE_TIME 50000
-
-static void set_mono_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 mono success", pinfo->m, c);
- } else {
- debug_error("[PA_CB] m[%p] c[%p] set mono fail:%s", pinfo->m, c, pa_strerror(pa_context_errno(c)));
- }
- pa_threaded_mainloop_signal(pinfo->m, 0);
-}
-
-static void mono_changed_cb(keynode_t* node, void* data)
-{
- int key_value;
- pa_operation *o = NULL;
- pulse_info_t* pinfo = (pulse_info_t*)data;
-
- if (pinfo == NULL) {
- debug_error ("pinfo is null");
- return;
- }
-
- vconf_get_bool(VCONF_KEY_MONO_AUDIO, &key_value);
- debug_msg ("%s changed callback called, key value = %d\n",vconf_keynode_get_name(node), key_value);
- /*for make sure touch sound play complete*/
- usleep(TOUCH_SOUND_PLAY_COMLETE_TIME);
-
- pa_threaded_mainloop_lock(pinfo->m);
- CHECK_CONTEXT_DEAD_GOTO(pinfo->context, unlock_and_fail);
-
- debug_msg("[PA] pa_ext_policy_set_mono m[%p] c[%p] mono:%d", pinfo->m, pinfo->context, key_value);
- o = pa_ext_policy_set_mono (pinfo->context, key_value, set_mono_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);
-
- pa_threaded_mainloop_unlock(pinfo->m);
- return;
-
-unlock_and_fail:
- if (o) {
- pa_operation_cancel(o);
- pa_operation_unref(o);
- }
- pa_threaded_mainloop_unlock(pinfo->m);
-}
-
-int MMSoundMgrPulseHandleRegisterMonoAudio (void* pinfo)
-{
- int ret = vconf_notify_key_changed(VCONF_KEY_MONO_AUDIO, mono_changed_cb, pinfo);
- debug_msg ("vconf [%s] set ret = %d\n", VCONF_KEY_MONO_AUDIO, ret);
- return ret;
-}
-#endif /* SUPPORT_MONO_AUDIO */
-
-/* -------------------------------- Audio Balance --------------------------------------------*/
-#ifdef SUPPORT_AUDIO_BALANCE
-static void set_balance_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 balance success", pinfo->m, c);
- } else {
- debug_error("[PA_CB] m[%p] c[%p] set balance fail:%s", pinfo->m, c, pa_strerror(pa_context_errno(c)));
- }
- pa_threaded_mainloop_signal(pinfo->m, 0);
-}
-
-static void _balance_changed_cb(keynode_t* node, void* data)
-{
- double balance_value;
- pulse_info_t* pinfo = (pulse_info_t*)data;
- pa_operation *o = NULL;
-
- if (pinfo == NULL) {
- debug_error ("pinfo is null");
- return;
- }
-
- vconf_get_dbl(VCONF_KEY_VOLUME_BALANCE, &balance_value);
- debug_msg ("%s changed callback called, balance value = %f\n",vconf_keynode_get_name(node), balance_value);
-
- pa_threaded_mainloop_lock(pinfo->m);
- CHECK_CONTEXT_DEAD_GOTO(pinfo->context, unlock_and_fail);
-
- debug_msg("[PA] pa_ext_policy_set_balance m[%p] c[%p] balance:%.2f", pinfo->m, pinfo->context, balance_value);
- o = pa_ext_policy_set_balance (pinfo->context, &balance_value, set_balance_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);
-
- pa_threaded_mainloop_unlock(pinfo->m);
- return;
-
-unlock_and_fail:
- if (o) {
- pa_operation_cancel(o);
- pa_operation_unref(o);
- }
- pa_threaded_mainloop_unlock(pinfo->m);
-}
-
-int MMSoundMgrPulseHandleRegisterAudioBalance (void* pinfo)
-{
- int ret = vconf_notify_key_changed(VCONF_KEY_VOLUME_BALANCE, _balance_changed_cb, pinfo);
- debug_msg ("vconf [%s] set ret = %d\n", VCONF_KEY_VOLUME_BALANCE, ret);
- return ret;
-}
-
-void MMSoundMgrPulseHandleResetAudioBalanceOnBoot(void* data)
-{
- double balance_value;
- pulse_info_t* pinfo = (pulse_info_t*)data;
- pa_operation *o = NULL;
-
- if (pinfo == NULL) {
- debug_error ("pinfo is null");
- return;
- }
-
- if (vconf_get_dbl(VCONF_KEY_VOLUME_BALANCE, &balance_value)) {
- debug_error ("vconf_get_dbl(VCONF_KEY_VOLUME_BALANCE) failed..\n");
- balance_value = 0;
- vconf_set_dbl(VCONF_KEY_VOLUME_BALANCE, balance_value);
- } else {
- pa_threaded_mainloop_lock(pinfo->m);
- CHECK_CONTEXT_DEAD_GOTO(pinfo->context, unlock_and_fail);
-
- debug_msg("[PA] pa_ext_policy_set_balance m[%p] c[%p] balance:%.2f", pinfo->m, pinfo->context, balance_value);
- o = pa_ext_policy_set_balance (pinfo->context, &balance_value, set_balance_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);
-
- pa_threaded_mainloop_unlock(pinfo->m);
- }
- return;
-
-unlock_and_fail:
- if (o) {
- pa_operation_cancel(o);
- pa_operation_unref(o);
- }
- pa_threaded_mainloop_unlock(pinfo->m);
-}
-#endif /* SUPPORT_AUDIO_BALANCE */
-
-
-#ifdef SUPPORT_AUDIO_MUTEALL
-static void set_muteall_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 muteall success", pinfo->m, c);
- } else {
- debug_error("[PA_CB] m[%p] c[%p] set muteall fail:%s", pinfo->m, c, pa_strerror(pa_context_errno(c)));
- }
- pa_threaded_mainloop_signal(pinfo->m, 0);
-}
-
-static void _muteall_changed_cb(keynode_t* node, void* data)
-{
- int key_value;
- int i;
- pulse_info_t* pinfo = (pulse_info_t*)data;
- pa_operation *o = NULL;
-
- if (pinfo == NULL) {
- debug_error ("pinfo is null\n");
- return;
- }
-
- vconf_get_int(VCONF_KEY_MUTE_ALL, &key_value);
- debug_msg ("%s changed callback called, muteall value = %d\n", vconf_keynode_get_name(node), key_value);
-
- mm_sound_mute_all(key_value);
-
- pa_threaded_mainloop_lock(pinfo->m);
- CHECK_CONTEXT_DEAD_GOTO(pinfo->context, unlock_and_fail);
-
- debug_msg("[PA] pa_ext_policy_set_muteall m[%p] c[%p] muteall:%d", pinfo->m, pinfo->context, key_value);
- o = pa_ext_policy_set_muteall (pinfo->context, key_value, set_muteall_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);
-
- pa_threaded_mainloop_unlock(pinfo->m);
-
- if (!key_value) {
- for (i =0;i<VOLUME_TYPE_MAX;i++) {
- unsigned int vconf_value;
- mm_sound_volume_get_value(i,&vconf_value);
- mm_sound_volume_set_value(i,vconf_value);
- }
- }
- return;
-
-unlock_and_fail:
- if (o) {
- pa_operation_cancel(o);
- pa_operation_unref(o);
- }
- pa_threaded_mainloop_unlock(pinfo->m);
-}
-
-int MMSoundMgrPulseHandleRegisterAudioMuteall (void* pinfo)
-{
- int ret = vconf_notify_key_changed(VCONF_KEY_MUTE_ALL, _muteall_changed_cb, pinfo);
- debug_msg ("vconf [%s] set ret = %d\n", VCONF_KEY_MUTE_ALL, ret);
- return ret;
-}
-
-void MMSoundMgrPulseHandleResetAudioMuteallOnBoot(void* data)
-{
- int key_value;
- pulse_info_t* pinfo = (pulse_info_t*)data;
- pa_operation *o = NULL;
-
- if (pinfo == NULL) {
- debug_error ("pinfo is null\n");
- return;
- }
-
- if (vconf_get_int(VCONF_KEY_MUTE_ALL, &key_value)) {
- debug_error ("vconf_get_int(VCONF_KEY_MUTE_ALL) failed..\n");
- key_value = 0;
- vconf_set_int(VCONF_KEY_MUTE_ALL, key_value);
- } else {
- mm_sound_mute_all(key_value);
-
- pa_threaded_mainloop_lock(pinfo->m);
- CHECK_CONTEXT_DEAD_GOTO(pinfo->context, unlock_and_fail);
-
- debug_msg("[PA] pa_ext_policy_set_muteall m[%p] c[%p] muteall:%d", pinfo->m, pinfo->context, key_value);
- o = pa_ext_policy_set_muteall (pinfo->context, key_value, set_muteall_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);
-
- pa_threaded_mainloop_unlock(pinfo->m);
- }
- return;
-
-unlock_and_fail:
- if (o) {
- pa_operation_cancel(o);
- pa_operation_unref(o);
- }
- pa_threaded_mainloop_unlock(pinfo->m);
-}
-#endif /* SUPPORT_AUDIO_MUTEALL */
-
/* -------------------------------- BT SCO --------------------------------------------*/
#ifdef SUPPORT_BT_SCO_DETECT
@@ -1056,28 +777,28 @@ static void __bt_audio_connection_state_changed_cb(int result,
return;
}
- debug_msg("connection state changed. connected(%s), type(%s), address(%s), result(%d)\n",
+ debug_msg("connection state changed. connected(%s), type(%s), address(%s), result(%d), g_bt_flag(0x%x)\n",
connected == true ? "connected" : "disconnected",
(type >= 0 && type < length) ? type_str[type] : "unknown type",
- remote_address != NULL ? remote_address : "NULL", result);
+ remote_address != NULL ? remote_address : "NULL", result, g_bt_flag);
- /* Set SCO Device available */
+ /* Set SCO Device available, only manage SCO here. */
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);
+ if (connected) {
+ if (!(g_bt_flag & BT_FLAG_SCO_AVAIL) && !(g_bt_flag & BT_FLAG_A2DP_AVAIL)) {
+ MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CONNECTED, DEVICE_TYPE_BLUETOOTH, io_direction, DEVICE_ID_AUTO, NULL, 0, &g_alloc_device_id);
+ }
+ g_bt_flag |= BT_FLAG_SCO_AVAIL;
}
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);
+ if (!connected) {
+ if ((g_bt_flag & BT_FLAG_SCO_AVAIL) && !(g_bt_flag & BT_FLAG_A2DP_AVAIL)) {
+ 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;
}
- 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;
+ g_bt_flag &= ~BT_FLAG_SCO_AVAIL;
}
}
debug_msg("connection state changed end\n");
@@ -1094,9 +815,18 @@ static void __bt_ag_sco_state_changed_cb(int result, bool opened, void *user_dat
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);
+ g_bt_flag |= BT_FLAG_SCO_OPENED;
+ } else {
+ MMSoundMgrDeviceUpdateStatus (DEVICE_UPDATE_STATUS_CHANGED_INFO_IO_DIRECTION, DEVICE_TYPE_BLUETOOTH, DEVICE_IO_DIRECTION_OUT, DEVICE_ID_AUTO, NULL, DEVICE_STATE_DEACTIVATED, NULL);
+ g_bt_flag &= ~BT_FLAG_SCO_OPENED;
+ }
MMSoundMgrSessionGetSession(&session);
- if (session == SESSION_VOICECALL) {
- debug_warning("SESSION(SESSION_VOICECALL), we don't handle sco stat in call session. sound-path should be routed in active device function by call app\n");
+ 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;
}
@@ -1925,40 +1655,6 @@ unlock_and_fail:
debug_leave("\n");
}
-void MMSoundMgrPulseSetMuteall(int mute)
-{
- pa_operation *o = NULL;
-
- debug_msg("all streams are %s. pulse_info(0x%x)", mute ? "muted" : "unmuted", pulse_info);
-
- if (pa_threaded_mainloop_in_thread(pulse_info->m)) {
- o = pa_ext_policy_set_muteall (pulse_info->context, mute, set_muteall_cb, pulse_info);
- pa_operation_unref(o);
- } else {
- pa_threaded_mainloop_lock(pulse_info->m);
- CHECK_CONTEXT_DEAD_GOTO(pulse_info->context, muteall_and_fail);
- o = pa_ext_policy_set_muteall (pulse_info->context, mute, set_muteall_cb, pulse_info);
- CHECK_CONTEXT_SUCCESS_GOTO(pulse_info->context, o, muteall_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, muteall_and_fail);
- }
- pa_operation_unref(o);
-
- pa_threaded_mainloop_unlock(pulse_info->m);
- }
- debug_leave("\n");
- return;
-
-muteall_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;
@@ -2010,45 +1706,6 @@ static void _recorder_changed_cb(keynode_t* node, void* data)
debug_msg ("%s changed callback called, recorder state value = %d\n", vconf_keynode_get_name(node), key_value);
MMSoundMgrSessionGetSession(&session);
-
- if ((key_value == VCONFKEY_RECORDER_STATE_RECORDING || key_value == VCONFKEY_RECORDER_STATE_RECORDING_PAUSE) && session == SESSION_FMRADIO) {
- vconf_set_int(VCONF_KEY_FMRADIO_RECORDING, 1);
- } else {
- vconf_set_int(VCONF_KEY_FMRADIO_RECORDING, 0);
- }
-}
-
-int MMSoundMgrPulseHandleRegisterFMRadioRecording(void* pinfo)
-{
- int ret = vconf_notify_key_changed(VCONFKEY_RECORDER_STATE, _recorder_changed_cb, pinfo);
- debug_msg ("vconf [%s] set ret = %d\n", VCONFKEY_RECORDER_STATE, ret);
-
- return ret;
-}
-
-static void _poweroff_changed_cb(keynode_t* node, void* data)
-{
- int key_value;
- pulse_info_t* pinfo = (pulse_info_t*)data;
-
- if (pinfo == NULL) {
- debug_error ("pinfo is null\n");
- return;
- }
-
- vconf_get_int(VCONFKEY_SYSMAN_POWER_OFF_STATUS, &key_value);
- debug_msg ("%s changed callback called, poweroff value = %d\n", vconf_keynode_get_name(node), key_value);
-
- if (key_value >= VCONFKEY_SYSMAN_POWER_OFF_DIRECT) {
- MMSoundMgrPulseSetMuteall(1);
- }
-}
-
-int MMSoundMgrPulseHandleRegisterPowerOffMuteall(void* pinfo)
-{
- int ret = vconf_notify_key_changed(VCONFKEY_SYSMAN_POWER_OFF_STATUS, _poweroff_changed_cb, pinfo);
- debug_msg ("vconf [%s] set ret = %d\n", VCONFKEY_SYSMAN_POWER_OFF_STATUS, ret);
- return ret;
}
void MMSoundMgrPulseUnLoadHDMI()
@@ -2355,14 +2012,6 @@ static void set_active_device_cb(pa_context *c, int success, int need_update, vo
}
pa_threaded_mainloop_signal(pinfo->m, 0);
-
- if (need_update) {
- debug_msg("[PA] pa_ext_policy_set_active_device need to update volume.");
- if(MM_ERROR_NONE != _mm_sound_mgr_device_update_volume()) {
- debug_error ("_mm_sound_mgr_device_update_volume failed.");
- }
- }
-
}
static void set_active_device_nosignal_cb(pa_context *c, int success, int need_update, void *userdata)
@@ -2378,13 +2027,6 @@ static void set_active_device_nosignal_cb(pa_context *c, int success, int need_u
} else {
debug_error("[PA_CB] c[%p] set active device fail:%s", c, pa_strerror(pa_context_errno(c)));
}
-
- if (need_update) {
- debug_msg("[PA] pa_ext_policy_set_active_device need to update volume.");
- if(MM_ERROR_NONE != _mm_sound_mgr_device_update_volume()) {
- debug_error ("_mm_sound_mgr_device_update_volume failed.");
- }
- }
}
void MMSoundMgrPulseGetPathInfo(mm_sound_device_out *device_out, mm_sound_device_in *device_in)
@@ -2562,41 +2204,9 @@ static void set_update_volume_nosignal_cb(pa_context *c, int success, void *user
}
}
-void MMSoundMgrPulseUpdateVolume(void)
-{
- pa_operation *o = NULL;
-
- if (pa_threaded_mainloop_in_thread(pulse_info->m)) {
- o = pa_ext_policy_update_volume(pulse_info->context, set_update_volume_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_update_volume m[%p] c[%p]", pulse_info->m, pulse_info->context);
- o = pa_ext_policy_update_volume(pulse_info->context, set_update_volume_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);
-}
/* -------------------------------- booting sound --------------------------------------------*/
-#define VCONF_BOOTING "memory/private/sound/booting"
-
static void __pa_context_success_cb (pa_context *c, int success, void *userdata)
{
pulse_info_t *pinfo = (pulse_info_t *)userdata;
@@ -2625,7 +2235,7 @@ static void _booting_changed_cb(keynode_t* node, void* data)
return;
}
- booting = vconf_get_str(VCONF_BOOTING);
+ booting = vconf_get_str(VCONFKEY_SOUND_BOOT_SOUND);
debug_msg ("%s changed callback called, booting value = %s\n",vconf_keynode_get_name(node), booting);
if (booting) {
free(booting);
@@ -2657,8 +2267,8 @@ unlock_and_fail:
int MMSoundMgrPulseHandleRegisterBooting (void* pinfo)
{
- int ret = vconf_notify_key_changed(VCONF_BOOTING, _booting_changed_cb, pinfo);
- debug_msg ("vconf [%s] set ret = %d\n", VCONF_BOOTING, ret);
+ int ret = vconf_notify_key_changed(VCONFKEY_SOUND_BOOT_SOUND, _booting_changed_cb, pinfo);
+ debug_msg ("vconf [%s] set ret = %d\n", VCONFKEY_SOUND_BOOT_SOUND, ret);
return ret;
}
@@ -2678,18 +2288,6 @@ void* MMSoundMgrPulseInit(void)
pulse_info->usb_idx = PA_INVALID_INDEX;
pulse_info->dock_idx = PA_INVALID_INDEX;
pulse_info->device_type = PA_INVALID_INDEX;
-#ifdef SUPPORT_MONO_AUDIO
- MMSoundMgrPulseHandleRegisterMonoAudio(pulse_info);
-#endif
-#ifdef SUPPORT_AUDIO_BALANCE
- MMSoundMgrPulseHandleRegisterAudioBalance(pulse_info);
- MMSoundMgrPulseHandleResetAudioBalanceOnBoot(pulse_info);
-#endif
-
-#ifdef SUPPORT_AUDIO_MUTEALL
- MMSoundMgrPulseHandleRegisterAudioMuteall(pulse_info);
- MMSoundMgrPulseHandleResetAudioMuteallOnBoot(pulse_info);
-#endif
#ifdef SUPPORT_BT_SCO
MMSoundMgrPulseHandleRegisterBluetoothStatus(pulse_info);
#endif
diff --git a/server/mm_sound_mgr_session.c b/server/mm_sound_mgr_session.c
index 73aa33e..57dc948 100755..100644
--- a/server/mm_sound_mgr_session.c
+++ b/server/mm_sound_mgr_session.c
@@ -53,8 +53,6 @@
#define MAX_STRING_LEN 256
-#define VCONF_SOUND_BURSTSHOT "memory/private/sound/burstshot"
-
#define DEVICE_API_BLUETOOTH "bluez"
#define DEVICE_API_ALSA "alsa"
#define DEVICE_BUS_BLUETOOTH "bluetooth"
@@ -146,6 +144,7 @@ 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 void __set_deactivate_all_device_auto (mm_sound_device_in exception_in, mm_sound_device_out exception_out);
static const char* __get_session_string(session_t session);
static const char* __get_subsession_string(subsession_t session);
@@ -196,10 +195,6 @@ typedef struct _session_info_struct
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];
@@ -338,31 +333,6 @@ static bool _asm_unregister_for_headset (int *handle)
}
/* ------------------------- 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;
@@ -426,9 +396,6 @@ static int __set_playback_route_voip (session_state_t state)
/* 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;
@@ -458,8 +425,13 @@ static int __set_playback_route_voip (session_state_t state)
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 ("Reset ACTIVE, set based on priority");
+ RESET_ACTIVE(0);
+ /* Changes happens */
+ __select_playback_active_device();
+ __select_capture_active_device();
+ /* DEACTIVATE OTHERS */
+ __set_deactivate_all_device_auto (GET_ACTIVE_CAPTURE(), GET_ACTIVE_PLAYBACK());
debug_log ("voip call session stopped...set path based on current active device");
__set_route(true, false);
@@ -479,9 +451,6 @@ static int __set_playback_route_call (session_state_t state)
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
@@ -503,8 +472,13 @@ static int __set_playback_route_call (session_state_t state)
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 ("Reset ACTIVE, set based on priority");
+ RESET_ACTIVE(0);
+ /* Changes happens */
+ __select_playback_active_device();
+ __select_capture_active_device();
+ /* DEACTIVATE OTHERS */
+ __set_deactivate_all_device_auto (GET_ACTIVE_CAPTURE(), GET_ACTIVE_PLAYBACK());
debug_log ("voicecall session stopped...set path based on current active device");
__set_route(true, false);
@@ -699,25 +673,6 @@ static bool __is_recording_subsession ()
return is_recording;
}
-static void _wait_if_burstshot_exists(void)
-{
- int retry = 0;
- int is_burstshot = 0;
-
- do {
- if (retry > 0)
- usleep (BURST_CHECK_INTERVAL);
- if (vconf_get_int(VCONF_SOUND_BURSTSHOT, &is_burstshot) != 0) {
- debug_warning ("Faided to get [%s], assume no burstshot....", VCONF_SOUND_BURSTSHOT);
- is_burstshot = 0;
- } else {
- debug_warning ("Is Burstshot [%d], retry...[%d/%d], interval usec = %d",
- is_burstshot, retry, MAX_BURST_CHECK_RETRY, BURST_CHECK_INTERVAL);
- }
- } while (is_burstshot && retry++ < MAX_BURST_CHECK_RETRY);
-}
-
-
static int __set_sound_path_for_current_active (bool need_broadcast, bool need_cork)
{
int ret = MM_ERROR_NONE;
@@ -733,9 +688,6 @@ static int __set_sound_path_for_current_active (bool need_broadcast, bool need_c
return MM_ERROR_SOUND_INVALID_STATE;
}
- /* Wait if BurstShot is ongoing */
- _wait_if_burstshot_exists();
-
if (need_cork)
MMSoundMgrPulseSetCorkAll (true);
@@ -810,40 +762,12 @@ static int __set_sound_path_for_current_active (bool need_broadcast, bool need_c
case SESSION_VOICECALL:
case SESSION_VIDEOCALL:
if (g_info.subsession == SUBSESSION_RINGTONE) {
-#ifndef _TIZEN_PUBLIC_
-#ifndef TIZEN_MICRO
- int vr_enabled = 0;
-#endif
- int vr_ringtone_enabled = 0;
-#endif
in = MM_SOUND_DEVICE_IN_NONE;
/* If active device was WFD(mirroring), set option */
if (out == MM_SOUND_DEVICE_OUT_MIRRORING) {
/* mirroring option */
}
-#ifndef _TIZEN_PUBLIC_
-#ifdef TIZEN_MICRO
- if (vconf_get_bool(VCONF_KEY_VR_RINGTONE_ENABLED, &vr_ringtone_enabled)) {
- debug_warning("vconf_get_bool for %s failed\n", VCONF_KEY_VR_RINGTONE_ENABLED);
- }
-
- if (vr_ringtone_enabled) {
- /* bargin option */
- }
-#else
- /* If voice control for incoming call is enabled, set capture path here for avoiding ringtone breaks */
- if (vconf_get_bool(VCONF_KEY_VR_ENABLED, &vr_enabled)) {
- debug_warning("vconf_get_bool for %s failed\n", VCONF_KEY_VR_ENABLED);
- } else if (vconf_get_bool(VCONF_KEY_VR_RINGTONE_ENABLED, &vr_ringtone_enabled)) {
- debug_warning("vconf_get_bool for %s failed\n", VCONF_KEY_VR_RINGTONE_ENABLED);
- }
-
- if (vr_enabled && vr_ringtone_enabled) {
- /* bargin option */
- }
-#endif /* TIZEN_MICRO */
-#endif /* #ifndef _TIZEN_PUBLIC_ */
if (_mm_sound_is_mute_policy ()) {
/* Mute Ringtone */
#ifdef TIZEN_MICRO
@@ -950,7 +874,6 @@ static int __set_sound_path_for_current_active (bool need_broadcast, bool need_c
}
MMSoundMgrPulseSetCorkAll (false);
}
- MMSoundMgrPulseUpdateVolume();
/* clean up */
debug_fleave();
@@ -1096,6 +1019,18 @@ int MMSoundMgrSessionSetSoundPathForActiveDevice (mm_sound_device_out playback,
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:
@@ -1127,6 +1062,18 @@ static int __set_sound_path_for_active_device_nolock (mm_sound_device_out playba
}
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;
@@ -1150,7 +1097,7 @@ static int __set_sound_path_to_speaker (void)
static void __select_playback_active_device (void)
{
if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_ANY)) {
- debug_log ("Active device exists. Nothing needed...\n");
+ debug_msg ("Active device exists. Nothing needed...\n");
return;
}
@@ -1194,7 +1141,7 @@ static void __select_playback_active_device (void)
static void __select_capture_active_device (void)
{
if (IS_ACTIVE(MM_SOUND_DEVICE_IN_ANY)) {
- debug_log ("Active device exists. Nothing needed...\n");
+ debug_msg ("Active device exists. Nothing needed...\n");
return;
}
@@ -2584,18 +2531,14 @@ int MMSoundMgrSessionSetSubSession(subsession_t subsession, int subsession_opt)
need_update = true;
}
break;
- } if (g_info.subsession == SUBSESSION_VOICE) {
- if (IS_ACTIVE(MM_SOUND_DEVICE_OUT_BT_SCO) && IS_ACTIVE(MM_SOUND_DEVICE_IN_BT_SCO)) {
- /* Update BT info */
- MMSoundMgrPulseUpdateBluetoothAGCodec();
- }
}
-
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 */
MMSoundMgrPulseUpdateBluetoothAGCodec();
}
+#endif
}
if (need_update) {
@@ -2668,11 +2611,7 @@ bool MMSoundMgrSessionGetVoiceControlState ()
/* -------------------------------- NOISE REDUCTION --------------------------------------------*/
static bool __is_noise_reduction_on (void)
{
- int noise_reduction_on = 1;
-
- if (vconf_get_bool(VCONF_KEY_NOISE_REDUCTION, &noise_reduction_on)) {
- debug_warning("vconf_get_bool for VCONF_KEY_NOISE_REDUCTION failed\n");
- }
+ int noise_reduction_on = 0;
return (noise_reduction_on == 1) ? true : false;
}
@@ -2680,11 +2619,7 @@ static bool __is_noise_reduction_on (void)
/* -------------------------------- EXTRA VOLUME --------------------------------------------*/
static bool __is_extra_volume_on (void)
{
- int extra_volume_on = 1;
-
- if (vconf_get_bool(VCONF_KEY_EXTRA_VOLUME, &extra_volume_on )) {
- debug_warning("vconf_get_bool for VCONF_KEY_EXTRA_VOLUME failed\n");
- }
+ int extra_volume_on = 0;
return (extra_volume_on == 1) ? true : false;
}
@@ -2693,11 +2628,7 @@ static bool __is_extra_volume_on (void)
/* -------------------------------- UPSCALING --------------------------------------------*/
static bool __is_upscaling_needed (void)
{
- int is_wbamr = 1;
-
- if (vconf_get_bool(VCONF_KEY_WBAMR, &is_wbamr)) {
- debug_warning("vconf_get_bool for VCONF_KEY_WBAMR failed\n");
- }
+ int is_wbamr = 0;
return (is_wbamr == 0) ? true : false;
}
diff --git a/server/mm_sound_server.c b/server/mm_sound_server.c
index 40a3e3c..5c9c68f 100644
--- a/server/mm_sound_server.c
+++ b/server/mm_sound_server.c
@@ -106,6 +106,10 @@ GMainLoop *g_mainloop;
void* pulse_handle;
+extern int asm_server_snd_msgid;
+extern int asm_server_rcv_msgid;
+extern int asm_server_cb_msgid;
+
gpointer event_loop_thread(gpointer data)
{
g_mainloop = g_main_loop_new(NULL, TRUE);
@@ -119,16 +123,16 @@ gpointer event_loop_thread(gpointer data)
static void __wait_for_asm_ready ()
{
int retry_count = 0;
- int asm_ready = 0;
- while (!asm_ready) {
+ while (1) {
debug_msg("Checking ASM ready....[%d]\n", retry_count++);
- if (vconf_get_int(ASM_READY_KEY, &asm_ready)) {
- debug_warning("vconf_get_int for ASM_READY_KEY (%s) failed\n", ASM_READY_KEY);
+ if (asm_server_snd_msgid != -1 && asm_server_rcv_msgid != -1 && asm_server_cb_msgid != -1) {
+ break;
+ } else {
+ debug_warning("asm msg queues are not created yet..\n");
}
usleep (ASM_CHECK_INTERVAL);
}
- debug_msg("ASM is now ready...clear the key!!!\n");
- vconf_set_int(ASM_READY_KEY, 0);
+ debug_msg("ASM is now ready...\n");
}
static int _handle_power_off ()
@@ -194,7 +198,7 @@ int main(int argc, char **argv)
if (serveropt.startserver) {
if ((sem = sem_create_n_wait()) == NULL) {
- debug_log("sem_create_n_wait failed..\n");
+ debug_error("sem_create_n_wait failed..\n");
return 0;
}
}
@@ -293,10 +297,12 @@ int main(int argc, char **argv)
#endif
unlink(PA_READY); // remove pa_ready file after sound-server init.
- if (sem_post(sem) == -1) {
- debug_error ("error sem post : %d", errno);
- } else {
- debug_msg ("Ready to play booting sound!!!!");
+ if (sem) {
+ if (sem_post(sem) == -1) {
+ debug_error ("error sem post : %d", errno);
+ } else {
+ debug_msg ("Ready to play booting sound!!!!");
+ }
}
/* Start Ipc mgr */
MMSoundMgrIpcReady();
diff --git a/server/plugin/keytone/mm_sound_plugin_run_key_tone.c b/server/plugin/keytone/mm_sound_plugin_run_key_tone.c
index 5721af0..3871679 100644
--- a/server/plugin/keytone/mm_sound_plugin_run_key_tone.c
+++ b/server/plugin/keytone/mm_sound_plugin_run_key_tone.c
@@ -45,7 +45,7 @@
#include "../../include/mm_sound_plugin_codec.h"
#include "../../../include/mm_sound_utils.h"
#include "../../../include/mm_sound_common.h"
-#include "../../include/mm_sound_pa_client.h"
+#include "../../../include/mm_sound_pa_client.h"
#ifdef OGG_SUPPORT
#include <tremolo_vorbisdec_api.h>
@@ -273,7 +273,9 @@ static int _init_dbus_keytone ()
sig_error:
g_dbus_connection_signal_unsubscribe(conn, sig_id);
- g_object_unref(conn);
+ if (conn) {
+ g_object_unref(conn);
+ }
error:
return -1;
diff --git a/server/plugin/wav/mm_sound_plugin_codec_wave.c b/server/plugin/wav/mm_sound_plugin_codec_wave.c
index 93175d8..1c46673 100644
--- a/server/plugin/wav/mm_sound_plugin_codec_wave.c
+++ b/server/plugin/wav/mm_sound_plugin_codec_wave.c
@@ -242,7 +242,8 @@ int MMSoundPlugCodecWaveCreate(mmsound_codec_param_t *param, mmsound_codec_info_
#ifdef DEBUG_DETAIL
debug_enter("\n");
#endif
- debug_msg("period[%d] type[%s] ch[%d] format[%d] rate[%d] doffset[%d] priority[%d] repeat[%d] volume[%d] callback[%p] keytone[%08x] route[%d]\n",
+
+ debug_msg("period[%d] type[%s] ch[%d] format[%d] rate[%d] doffset[%d] priority[%d] repeat[%d] volume[%f] callback[%p] keytone[%08x] route[%d]\n",
keytone_period, (info->codec == MM_SOUND_SUPPORTED_CODEC_WAVE) ? "Wave" : "Unknown",
info->channels, info->format, info->samplerate, info->doffset, param->priority, param->repeat_count,
param->volume, param->stop_cb, param->keytone, param->handle_route);
@@ -291,10 +292,7 @@ int MMSoundPlugCodecWaveCreate(mmsound_codec_param_t *param, mmsound_codec_info_
p->channels = info->channels;
p->samplerate = info->samplerate;
- if(param->handle_route == MM_SOUND_HANDLE_ROUTE_USING_CURRENT) /* normal, solo */
- p->handle_route = HANDLE_ROUTE_POLICY_OUT_AUTO;
- else /* loud solo */
- p->handle_route = HANDLE_ROUTE_POLICY_OUT_HANDSET;
+ p->handle_route = param->handle_route;
switch(info->format)
{
@@ -401,6 +399,8 @@ static void _runing(void *param)
/* MMSoundMgrPulseSetActiveDevice(route_info_device_in, route_info.device_out); */
break;
case MM_SOUND_HANDLE_ROUTE_USING_CURRENT:
+ route_info.policy = HANDLE_ROUTE_POLICY_OUT_AUTO;
+ break;
default:
break;
}
diff --git a/testsuite/mm_sound_testsuite_simple.c b/testsuite/mm_sound_testsuite_simple.c
index 3cd81ec..126af10 100644..100755
--- a/testsuite/mm_sound_testsuite_simple.c
+++ b/testsuite/mm_sound_testsuite_simple.c
@@ -55,6 +55,11 @@ enum {
CURRENT_STATUS_FILENAME = 1,
CURRENT_STATUS_POSITION = 2,
CURRENT_STATUS_DIRNAME = 3,
+#ifdef TIZEN_TV
+ CURRENT_STATUS_MASTERVOLUME = 4,
+ CURRENT_STATUS_MASTERMUTE = 5,
+ CURRENT_STATUS_OUTPUTDEVICE = 6,
+#endif
};
int g_menu_state = CURRENT_STATUS_MAINMENU;
@@ -187,7 +192,8 @@ static void displaymenu()
g_print("c : play sound ex \t");
g_print("F : Play DTMF \t");
g_print("b : Play directory\n");
- g_print("s : Stop play \n");
+ g_print("s : Stop play \t");
+ g_print("m : stereo to mono\n");
g_print("==================================================================\n");
g_print(" Volume APIs\n");
g_print("==================================================================\n");
@@ -200,8 +206,6 @@ static void displaymenu()
g_print("g : Get voice \t");
g_print("h : Inc. voice \t");
g_print("j : Dec. voice \n");
- g_print("B : Set audio balance\n");
- g_print("M : Set mute all\n");
g_print("==================================================================\n");
g_print(" Audio route APIs\n");
g_print("==================================================================\n");
@@ -231,6 +235,19 @@ static void displaymenu()
g_print("Q : Add device info. changed callback \t");
g_print("W : Remove device info. changed callback \n");
g_print("==================================================================\n");
+#ifdef TIZEN_TV
+ g_print(" TV profile APIs\n");
+ g_print("==================================================================\n");
+ g_print("sm : Set master mute \t");
+ g_print("gm : Get master mute \n");
+ g_print("sv : Set master volume \t");
+ g_print("gv : Get master volume \n");
+ g_print("sd : Set output device \t");
+ g_print("gd : Get output device \n");
+ g_print("sc : Set master volume/mute, output device changed cb \n");
+ g_print("uc : Unset master volume/mute, output device changed cb \n");
+ g_print("==================================================================\n");
+#endif
g_print("d : Input Directory \t");
g_print("f : Input File name \t");
g_print("x : Exit Program \n");
@@ -241,7 +258,7 @@ static void displaymenu()
g_print(">>>>Input file name to play : ");
}
else if (g_menu_state == CURRENT_STATUS_DIRNAME) {
- g_print(">>>>Input directory which contain audio files : ");
+ g_print(">>>>Input directory which contain audio files : ");
}
else {
g_print("**** Unknown status.\n");
@@ -353,13 +370,36 @@ static void __mm_sound_active_device_changed_cb (mm_sound_device_in device_in, m
g_print ("[%s] in[0x%08x][%s], out[0x%08x][%s]\n", __func__,
device_in, __get_capture_device_str(device_in), device_out, __get_playback_device_str(device_out));
}
+#ifdef TIZEN_TV
+int g_user_data_tv = 0;
+void master_volume_changed_callback (unsigned int value, void* user_data)
+{
+ g_print("master_volume_changed_callback is called, value(%d), user_data(%p)\n", value, user_data);
+ return;
+}
+void master_mute_changed_callback (unsigned int value, void* user_data)
+{
+ g_print("master_mute_changed_callback is called, value(%d), user_data(%p)\n", value, user_data);
+ return;
+}
+
+void output_device_changed_callback (mm_sound_tv_output_device_t route, void* user_data)
+{
+ g_print("output_device_changed_callback is called, route(%d), user_data(%p)\n", route, user_data);
+ return;
+}
+#endif
static void interpret (char *cmd)
{
int ret=0;
static int handle = -1;
MMSoundPlayParam soundparam = {0,};
-
+#ifdef TIZEN_TV
+ unsigned int mastervolume = 0;
+ int mastermute = 0;
+ int outputdevice = 0;
+#endif
switch (g_menu_state)
{
case CURRENT_STATUS_MAINMENU:
@@ -369,6 +409,100 @@ static void interpret (char *cmd)
if(ret < 0)
debug_log("keysound play failed with 0x%x\n", ret);
}
+#ifdef TIZEN_TV
+ else if(strncmp(cmd, "sv", 2) == 0)
+ {//set master volume
+ g_menu_state = CURRENT_STATUS_MASTERVOLUME;
+ g_print(">>>>Input volume level : ");
+ }
+ else if(strncmp(cmd, "gv", 2) == 0)
+ {//get master volume
+ unsigned int value = 100;
+ ret = mm_sound_volume_get_master(&value);
+ if(ret < 0) {
+ debug_log("mm_sound_volume_get_master 0x%x\n", ret);
+ }
+ else{
+ g_print("*** MASTER VOLUME : %u ***\n", value);
+ }
+ }
+ else if(strncmp(cmd, "sm", 2) == 0)
+ {//set master mute
+ g_menu_state = CURRENT_STATUS_MASTERMUTE;
+ g_print(">>>>Input mute state (0 : unmute, 1 : mute) : ");
+ }
+ else if(strncmp(cmd, "gm", 2) == 0)
+ {//get master mute
+ bool value = 0;
+ ret = mm_sound_mute_get_master(&value);
+ if(ret < 0) {
+ debug_log("mm_sound_mute_get_master 0x%x\n", ret);
+ }
+ else{
+ g_print("*** MASTER MUTE : %d ***\n", value);
+ }
+ }
+ else if(strncmp(cmd, "sd", 2) == 0)
+ {//set output device
+ g_menu_state = CURRENT_STATUS_OUTPUTDEVICE;
+ g_print(">>>>Input output device : ");
+ }
+ else if(strncmp(cmd, "gd", 2) == 0)
+ {//get output device
+ mm_sound_tv_output_device_t value = 0;
+ ret = mm_sound_get_output_device(&value);
+ if(ret < 0) {
+ debug_log("mm_sound_get_output_device 0x%x\n", ret);
+ }
+ else{
+ g_print("*** OUTPUT DEVICE : %d ***\n", value);
+ }
+ }
+ else if(strncmp(cmd, "sc", 2) == 0)
+ {//set callback functions
+ ret = 0;
+ ret = mm_sound_set_master_volume_changed_callback(master_volume_changed_callback, &g_user_data_tv);
+ if (ret == MM_ERROR_NONE) {
+ g_print ("### mm_sound_set_master_volume_changed_callback(), func(%p), user_data(%p) Success\n", master_volume_changed_callback, &g_user_data_tv);
+ } else {
+ g_print ("### mm_sound_set_master_volume_changed_callback() Error = %x\n", ret);
+ }
+ ret = mm_sound_set_master_mute_changed_callback(master_mute_changed_callback, &g_user_data_tv);
+ if (ret == MM_ERROR_NONE) {
+ g_print ("### mm_sound_set_master_mute_changed_callback(), func(%p), user_data(%p) Success\n", master_mute_changed_callback, &g_user_data_tv);
+ } else {
+ g_print ("### mm_sound_set_master_mute_changed_callback() Error = %x\n", ret);
+ }
+ ret = mm_sound_set_output_device_changed_callback(output_device_changed_callback, &g_user_data_tv);
+ if (ret == MM_ERROR_NONE) {
+ g_print ("### mm_sound_set_output_device_changed_callback(), func(%p), user_data(%p) Success\n", output_device_changed_callback, &g_user_data_tv);
+ } else {
+ g_print ("### mm_sound_set_output_device_changed_callback() Error = %x\n", ret);
+ }
+ }
+ else if(strncmp(cmd, "uc", 2) == 0)
+ {//unset callback functions
+ ret = 0;
+ ret = mm_sound_unset_master_volume_changed_callback();
+ if (ret == MM_ERROR_NONE) {
+ g_print ("### mm_sound_unset_master_volume_changed_callback()\n");
+ } else {
+ g_print ("### mm_sound_unset_master_volume_changed_callback() Error = %x\n", ret);
+ }
+ ret = mm_sound_unset_master_mute_changed_callback();
+ if (ret == MM_ERROR_NONE) {
+ g_print ("### mm_sound_unset_master_mute_changed_callback()\n");
+ } else {
+ g_print ("### mm_sound_unset_master_mute_changed_callback() Error = %x\n", ret);
+ }
+ ret = mm_sound_unset_output_device_changed_callback();
+ if (ret == MM_ERROR_NONE) {
+ g_print ("### mm_sound_unset_output_device_changed_callback()\n");
+ } else {
+ g_print ("### mm_sound_unset_output_device_changed_callback() Error = %x\n", ret);
+ }
+ }
+#endif
else if(strncmp(cmd, "q", 1) == 0)
{//get media volume
unsigned int value = 100;
@@ -530,61 +664,6 @@ static void interpret (char *cmd)
}
}
}
-
- else if(strncmp(cmd, "B", 1) == 0)
- {
- int ret = 0;
- char input_string[128];
- float balance;
-
- fflush(stdin);
- ret = mm_sound_volume_get_balance(&balance);
- if (ret == MM_ERROR_NONE) {
- g_print ("### mm_sound_volume_get_balance Success, balance=%f\n", balance);
- } else {
- g_print ("### mm_sound_volume_get_balance Error = %x\n", ret);
- }
- g_print("> Enter new audio balance (current is %f) : ", balance);
- if (fgets(input_string, sizeof(input_string)-1, stdin) == NULL) {
- g_print ("### fgets return NULL\n");
- }
-
- balance = atof (input_string);
- ret = mm_sound_volume_set_balance(balance);
- if (ret == MM_ERROR_NONE) {
- g_print ("### mm_sound_volume_set_balance(%f) Success\n", balance);
- } else {
- g_print ("### mm_sound_volume_set_balance(%f) Error = %x\n", balance, ret);
- }
- }
-
- else if(strncmp(cmd, "M", 1) == 0)
- {
- int ret = 0;
- char input_string[128];
- int muteall;
-
- fflush(stdin);
- ret = mm_sound_get_muteall(&muteall);
- if (ret == MM_ERROR_NONE) {
- g_print ("### mm_sound_get_muteall Success, muteall=%d\n", muteall);
- } else {
- g_print ("### mm_sound_get_muteall Error = %x\n", ret);
- }
- g_print("> Enter new muteall state (current is %d) : ", muteall);
- if (fgets(input_string, sizeof(input_string)-1, stdin) == NULL) {
- g_print ("### fgets return NULL\n");
- }
-
- muteall = atoi (input_string);
- ret = mm_sound_set_muteall(muteall);
- if (ret == MM_ERROR_NONE) {
- g_print ("### mm_sound_set_muteall(%d) Success\n", muteall);
- } else {
- g_print ("### mm_sound_set_muteall(%d) Error = %x\n", muteall, ret);
- }
- }
-
else if(strncmp(cmd, "a", 1) == 0)
{
debug_log("volume is %d type, %d\n", g_volume_type, g_volume_value);
@@ -1307,6 +1386,43 @@ static void interpret (char *cmd)
break;
case CURRENT_STATUS_POSITION:
break;
+#ifdef TIZEN_TV
+ case CURRENT_STATUS_MASTERVOLUME:
+ mastervolume = atoi(cmd);
+ ret = mm_sound_volume_set_master(mastervolume);
+ if(ret < 0) {
+ debug_log("mm_sound_volume_set_master 0x%x\n", ret);
+ }
+ else{
+ g_print("*** MASTER VOLUME : %u ***\n", mastervolume);
+ }
+ g_menu_state=CURRENT_STATUS_MAINMENU;
+ break;
+
+ case CURRENT_STATUS_MASTERMUTE:
+ mastermute = atoi(cmd);
+ ret = mm_sound_mute_set_master((bool)mastermute);
+ if(ret < 0) {
+ debug_log("mm_sound_mute_set_master 0x%x\n", ret);
+ }
+ else{
+ g_print("*** MASTER MUTE : %u ***\n", mastermute);
+ }
+ g_menu_state=CURRENT_STATUS_MAINMENU;
+ break;
+
+ case CURRENT_STATUS_OUTPUTDEVICE:
+ outputdevice = atoi(cmd);
+ ret = mm_sound_set_output_device((mm_sound_tv_output_device_t)outputdevice);
+ if(ret < 0) {
+ debug_log("mm_sound_set_output_device 0x%x\n", ret);
+ }
+ else{
+ g_print("*** OUTPUT DEVICE : %u ***\n", outputdevice);
+ }
+ g_menu_state=CURRENT_STATUS_MAINMENU;
+ break;
+#endif
}
//g_timeout_add(100, timeout_menu_display, 0);
}
@@ -1317,14 +1433,6 @@ void volume_change_callback(volume_type_t type, unsigned int volume, void *user_
g_print("Volume Callback Runs :::: MEDIA VALUME %d\n", volume);
}
-void muteall_change_callback(void* data)
-{
- int muteall;
-
- mm_sound_get_muteall(&muteall);
- g_print("Muteall Callback Runs :::: muteall value = %d\n", muteall);
-}
-
void audio_route_policy_changed_callback(void* data, system_audio_route_t policy)
{
int dummy = (int) data;
@@ -1360,7 +1468,6 @@ int main(int argc, char *argv[])
g_print("\nThe input filename is '%s' \n\n",g_file_name);
mm_sound_add_volume_changed_callback(volume_change_callback, (void*) &g_volume_type);
- mm_sound_muteall_add_callback(muteall_change_callback);
displaymenu();
g_main_loop_run (g_loop);