[AUDIO_METHOD_TEST] = {
.name = "MethodTest1",
},
- [AUDIO_METHOD_PLAY_FILE_START] = {
- .name = "PlayFileStart",
- },
[AUDIO_METHOD_PLAY_FILE_START_WITH_STREAM_INFO] = {
.name = "PlayFileStartWithStreamInfo",
},
[AUDIO_METHOD_PLAY_FILE_STOP] = {
.name = "PlayFileStop",
},
- [AUDIO_METHOD_PLAY_DTMF] = {
- .name = "PlayDTMF",
- },
[AUDIO_METHOD_PLAY_DTMF_WITH_STREAM_INFO] = {
.name = "PlayDTMFWithStreamInfo",
},
- [AUDIO_METHOD_CLEAR_FOCUS] = {
- .name = "ClearFocus",
- },
[AUDIO_METHOD_SET_VOLUME_LEVEL] = {
.name = "SetVolumeLevel",
},
AC_SUBST(MMCOMMON_CFLAGS)
AC_SUBST(MMCOMMON_LIBS)
-PKG_CHECK_MODULES(MMSESSION, mm-session)
-AC_SUBST(MMSESSION_CFLAGS)
-AC_SUBST(MMSESSION_LIBS)
-
PKG_CHECK_MODULES(GLIB2, glib-2.0 gthread-2.0)
AC_SUBST(GLIB2_CFLAGS)
AC_SUBST(GLIB2_LIBS)
bool reacquisition;
bool is_in_thread;
int handle_id_dst;
-
- /* It will be removed when the session concept is completely left out*/
- bool is_for_session;
- bool is_for_monitor;
} _mm_sound_mgr_focus_param_t;
typedef struct _taken_by_id {
int pid;
int handle_id;
- bool by_session;
} _focus_taken_by_id_t;
typedef struct {
void *cbdata;
bool during_cb;
bool reacquisition;
-
- /* These will be removed when the session concept is completely left out*/
- bool is_for_session;
- bool is_for_monitor;
- bool reacquisition_with_released_state;
} focus_node_t;
int MMSoundMgrFocusInit(void);
#include <stdbool.h>
-int __mm_sound_mgr_focus_ipc_register_focus(int client_pid, int handle_id, const char* stream_type, bool is_for_session);
-int __mm_sound_mgr_focus_ipc_unregister_focus(int pid, int handle_id, bool is_for_session);
-int __mm_sound_mgr_focus_ipc_set_focus_reacquisition(int pid, int handle_id, bool reacquisition, bool is_for_session);
+int __mm_sound_mgr_focus_ipc_register_focus(int client_pid, int handle_id, const char* stream_type);
+int __mm_sound_mgr_focus_ipc_unregister_focus(int pid, int handle_id);
+int __mm_sound_mgr_focus_ipc_set_focus_reacquisition(int pid, int handle_id, bool reacquisition);
int __mm_sound_mgr_focus_ipc_get_acquired_focus_stream_type(int focus_type, char **stream_type, int *option, char **ext_info);
-int __mm_sound_mgr_focus_ipc_acquire_focus(int pid, int handle_id, int focus_type, int option, const char *ext_info, bool is_in_thread, bool is_for_session);
-int __mm_sound_mgr_focus_ipc_release_focus(int pid, int handle_id, int focus_type, int option, const char *ext_info, bool is_in_thread, bool is_for_session);
-int __mm_sound_mgr_focus_ipc_watch_focus(int pid, int handle_id, int focus_type, bool is_for_session, bool is_for_monitor);
+int __mm_sound_mgr_focus_ipc_acquire_focus(int pid, int handle_id, int focus_type, int option, const char *ext_info, bool is_in_thread);
+int __mm_sound_mgr_focus_ipc_release_focus(int pid, int handle_id, int focus_type, int option, const char *ext_info, bool is_in_thread);
+int __mm_sound_mgr_focus_ipc_watch_focus(int pid, int handle_id, int focus_type);
int __mm_sound_mgr_focus_ipc_unwatch_focus(int pid, int handle_id);
int __mm_sound_mgr_focus_ipc_deliver_focus(int pid, int src_handle_id, int dst_handle_id, int focus_type);
int __mm_sound_mgr_focus_ipc_emergent_exit(int pid);
} \
} while (0)
-#define UPDATE_FOCUS_TAKEN_INFO(x_postfix, x_node, x_pid, x_hid, x_by_session) do { \
- debug_msg("updating node[%p], taken_"#x_postfix"[%d] : pid = [%d], handle_id = [%d], is_for_session = [%d]", x_node, i, x_pid, x_hid, x_by_session); \
+#define UPDATE_FOCUS_TAKEN_INFO(x_postfix, x_node, x_pid, x_hid) do { \
+ debug_msg("updating node[%p], taken_"#x_postfix"[%d] : pid = [%d], handle_id = [%d]", x_node, i, x_pid, x_hid); \
x_node->taken_##x_postfix[i].pid = x_pid; \
x_node->taken_##x_postfix[i].handle_id = x_hid; \
- x_node->taken_##x_postfix[i].by_session = x_by_session; \
} while (0)
#define CONTINUE_IF_LIST_DATA_IS_NULL(x_node, x_list) \
continue; \
#define CONTINUE_IF_NOT_MY_FOCUS_NODE(x_node, x_param) \
- if ((x_node)->is_for_watch || ((x_node)->pid != (x_param)->pid) || ((x_node)->handle_id != (x_param)->handle_id) || \
- ((x_node)->is_for_session != (x_param)->is_for_session)) \
+ if ((x_node)->is_for_watch || ((x_node)->pid != (x_param)->pid) || ((x_node)->handle_id != (x_param)->handle_id)) \
continue; \
static char* __get_focus_pipe_path(int instance_id, int handle, const char *postfix, bool is_watch)
return ret;
}
-static bool _check_session_node_exist(int pid)
-{
- GList *list = NULL;
- focus_node_t *node = NULL;
-
- for (list = g_focus_node_list; list != NULL; list = list->next) {
- node = (focus_node_t *)list->data;
- if (node->pid != pid)
- continue;
- if (node->is_for_monitor)
- continue;
- if (node->is_for_session)
- return true;
- }
-
- debug_msg("session node for pid[%d] does not exist", pid);
-
- return false;
-}
-
-static bool _check_session_monitor_node_exist(int pid)
-{
- GList *list = NULL;
- focus_node_t *node = NULL;
-
- for (list = g_focus_node_list; list != NULL; list = list->next) {
- node = (focus_node_t *)list->data;
- if (node->pid != pid)
- continue;
- if (node->is_for_watch && node->is_for_session && node->is_for_monitor)
- return true;
- }
-
- debug_msg("session monitor node for pid[%d] does not exist", pid);
-
- return false;
-}
-
static void _invoke_watch_callback(focus_node_t *node, const char *stream_type, focus_type_e focus_type, focus_command_e command, const _mm_sound_mgr_focus_param_t *param)
{
int ret = -1;
}
}
-/* session backward compatibility for monitor handle, it is for monitor callback of other nodes */
-static int _mm_sound_mgr_focus_do_monitor_callback_outer(focus_type_e focus_type, focus_command_e command, focus_node_t *my_node, const _mm_sound_mgr_focus_param_t *param)
-{
- GList *list = NULL;
- focus_node_t *node = NULL;
-
- debug_fenter();
-
- if (!my_node) {
- debug_error("[CB] my_node is null");
- return MM_ERROR_INVALID_ARGUMENT;
- }
-
- for (list = g_focus_node_list; list != NULL; list = list->next) {
- CONTINUE_IF_LIST_DATA_IS_NULL(node, list);
- if (node == my_node)
- continue;
- /* do not invoke monitor callback of mine */
- if (node->pid == my_node->pid)
- continue;
- if (!node->is_for_watch || !node->is_for_monitor || !node->is_for_session)
- continue;
- if (!(node->status & focus_type))
- continue;
- /* check if it meets the condition to trigger monitor callback */
- if (!_check_session_monitor_node_exist(node->pid))
- continue;
-
- _invoke_watch_callback(node, my_node->stream_type, focus_type, command, param);
- }
-
- debug_fleave();
-
- return MM_ERROR_NONE;
-}
-
-static int _mm_sound_mgr_focus_do_monitor_callback(focus_type_e focus_type, focus_command_e command, focus_node_t *my_node, const _mm_sound_mgr_focus_param_t *param)
-{
- GList *list = NULL;
- focus_node_t *node = NULL;
-
- debug_fenter();
-
- if (!my_node) {
- debug_error("[CB] my_node is null");
- return MM_ERROR_INVALID_ARGUMENT;
- }
-
- for (list = g_focus_node_list; list != NULL; list = list->next) {
- CONTINUE_IF_LIST_DATA_IS_NULL(node, list);
- if (!node->is_for_watch || !node->is_for_monitor || !node->is_for_session)
- continue;
- if (node == my_node || !(node->pid == my_node->pid && my_node->is_for_session))
- continue;
- if (!(node->status & focus_type))
- continue;
- /* check if it meets the condition to trigger monitor callback */
- if (!_check_session_node_exist(node->pid))
- continue;
-
- _invoke_watch_callback(node, param->stream_type, focus_type, command, param);
- }
-
- debug_fleave();
-
- return MM_ERROR_NONE;
-}
-
static int _mm_sound_mgr_focus_do_watch_callback(focus_type_e focus_type, focus_command_e command, focus_node_t *my_node, const _mm_sound_mgr_focus_param_t *param)
{
GList *list = NULL;
for (list = g_focus_node_list; list != NULL; list = list->next) {
CONTINUE_IF_LIST_DATA_IS_NULL(node, list);
- if (node == my_node || (node->pid == my_node->pid && node->is_for_session && my_node->is_for_session))
+ if (node == my_node)
continue;
if (!node->is_for_watch || !(node->status & focus_type))
continue;
- if (node->is_for_monitor)
- continue;
if (node->during_cb) {
debug_msg("it is about to invoke watch callback again during processing it, skip it");
continue;
int taken_pid = 0;
int taken_hid = 0;
int ret_handle = -1;
- bool taken_by_session = false;
bool reacquisition_changed = false;
focus_cb_data cb_data;
/* client will gain the lost focus */
for (i = 0; i < NUM_OF_STREAM_IO_TYPE; i++) {
if ((victim_node->taken_by_id[i].pid == assaulter_param->pid) &&
- ((victim_node->taken_by_id[i].handle_id == assaulter_param->handle_id) || victim_node->taken_by_id[i].by_session)) {
+ ((victim_node->taken_by_id[i].handle_id == assaulter_param->handle_id))) {
flag_for_focus_type |= i + 1; /* playback:1, capture:2 */
}
}
if (command == FOCUS_COMMAND_RELEASE) {
taken_pid = assaulter_param->pid;
taken_hid = assaulter_param->handle_id;
- taken_by_session = assaulter_param->is_for_session;
flag_for_taken_index = assaulter_param->request_type & victim_node->status;
} else {
taken_pid = 0;
taken_hid = 0;
- taken_by_session = false;
flag_for_taken_index = assaulter_param->request_type;
}
GList *list = NULL;
focus_node_t *node = NULL;
- if (command == FOCUS_COMMAND_ACQUIRE && (victim_node->taken_by_id[i].pid != assaulter_param->pid || (victim_node->taken_by_id[i].handle_id != assaulter_param->handle_id && !(victim_node->taken_by_id[i].by_session & assaulter_param->is_for_session)))) {
+ if (command == FOCUS_COMMAND_ACQUIRE && (victim_node->taken_by_id[i].pid != assaulter_param->pid || (victim_node->taken_by_id[i].handle_id != assaulter_param->handle_id))) {
/* skip */
debug_error("skip updating victim node");
continue;
for (list = g_focus_node_list; list != NULL; list = list->next) {
CONTINUE_IF_LIST_DATA_IS_NULL(node, list);
if (node->taken_by_id[i].pid == victim_node->pid) {
- UPDATE_FOCUS_TAKEN_INFO(backup, node, node->taken_by_id[i].pid, node->taken_by_id[i].handle_id, node->taken_by_id[i].by_session);
- UPDATE_FOCUS_TAKEN_INFO(by_id, node, taken_pid, taken_hid, taken_by_session);
+ UPDATE_FOCUS_TAKEN_INFO(backup, node, node->taken_by_id[i].pid, node->taken_by_id[i].handle_id);
+ UPDATE_FOCUS_TAKEN_INFO(by_id, node, taken_pid, taken_hid);
} else if (!list->next) {
- UPDATE_FOCUS_TAKEN_INFO(backup, victim_node, taken_pid, taken_hid, taken_by_session);
- UPDATE_FOCUS_TAKEN_INFO(by_id, victim_node, 0, 0, false);
+ UPDATE_FOCUS_TAKEN_INFO(backup, victim_node, taken_pid, taken_hid);
+ UPDATE_FOCUS_TAKEN_INFO(by_id, victim_node, 0, 0);
}
}
} else {
- UPDATE_FOCUS_TAKEN_INFO(by_id, victim_node, taken_pid, taken_hid, taken_by_session);
- UPDATE_FOCUS_TAKEN_INFO(backup, victim_node, 0, 0, false);
+ UPDATE_FOCUS_TAKEN_INFO(by_id, victim_node, taken_pid, taken_hid);
+ UPDATE_FOCUS_TAKEN_INFO(backup, victim_node, 0, 0);
}
} else {
if (victim_node->reacquisition)
- UPDATE_FOCUS_TAKEN_INFO(by_id, victim_node, taken_pid, taken_hid, taken_by_session);
+ UPDATE_FOCUS_TAKEN_INFO(by_id, victim_node, taken_pid, taken_hid);
else
- UPDATE_FOCUS_TAKEN_INFO(backup, victim_node, taken_pid, taken_hid, taken_by_session);
+ UPDATE_FOCUS_TAKEN_INFO(backup, victim_node, taken_pid, taken_hid);
}
}
}
- if (command == FOCUS_COMMAND_RELEASE || victim_node->reacquisition_with_released_state)
+ if (command == FOCUS_COMMAND_RELEASE)
victim_node->status = victim_node->status & ~(cb_data.type);
else if (command == FOCUS_COMMAND_ACQUIRE)
victim_node->status = victim_node->status | cb_data.type;
if (strncmp(assaulter_param->stream_type, victim_node->stream_type, MAX_STREAM_TYPE_LEN))
_mm_sound_mgr_focus_do_watch_callback((focus_type_e)assaulter_param->request_type, command, victim_node, assaulter_param);
- _mm_sound_mgr_focus_do_monitor_callback((focus_type_e)assaulter_param->request_type, command, victim_node, assaulter_param);
RELEASE:
g_free(filename);
debug_msg("================================================ focus node list : start ===================================================");
for (list = g_focus_node_list; list != NULL; list = list->next) {
if ((node = (focus_node_t *)list->data) && !node->is_for_watch) {
- debug_msg("*** pid[%5d]/handle_id[%2d]/[%14s]:priority[%2d],status[%s],taken_by[P(%5d/%2d/%2d)C(%5d/%2d/%2d)],session[%d],option[0x%x/0x%x],ext_info[%s/%s]",
+ debug_msg("*** pid[%5d]/handle_id[%2d]/[%14s]:priority[%2d],status[%s],taken_by[P(%5d/%2d)C(%5d/%2d)],option[0x%x/0x%x],ext_info[%s/%s]",
node->pid, node->handle_id, node->stream_type, node->priority, focus_status_str[node->status],
- node->taken_by_id[0].pid, node->taken_by_id[0].handle_id, node->taken_by_id[0].by_session,
- node->taken_by_id[1].pid, node->taken_by_id[1].handle_id, node->taken_by_id[1].by_session,
- node->is_for_session,
+ node->taken_by_id[0].pid, node->taken_by_id[0].handle_id,
+ node->taken_by_id[1].pid, node->taken_by_id[1].handle_id,
node->option[0], node->option[1],
node->ext_info[0], node->ext_info[1]);
}
debug_msg("============================================= focus watch node list : start =================================================");
for (list = g_focus_node_list; list != NULL; list = list->next) {
if ((node = (focus_node_t *)list->data) && node->is_for_watch)
- debug_msg("*** pid[%5d]/handle_id[%d]/watch on focus status[%s]/for_session[%d]/for_monitor[%d]",
- node->pid, node->handle_id, focus_status_str[node->status], node->is_for_session, node->is_for_monitor);
+ debug_msg("*** pid[%5d]/handle_id[%d]/watch on focus status[%s]",
+ node->pid, node->handle_id, focus_status_str[node->status]);
}
debug_msg("============================================= focus watch node list : end ===================================================");
node->handle_id = msg->handle_id;
node->callback = msg->callback;
node->cbdata = msg->cbdata;
- node->is_for_session = msg->is_for_session;
debug_fleave();
return;
break;
}
if (my_node == NULL) {
- debug_error("could not find any node of pid[%d]/handle_id[%d]/is_for_session[%d]", param->pid, param->handle_id, param->is_for_session);
+ debug_error("could not find any node of pid[%d]/handle_id[%d]", param->pid, param->handle_id);
ret = MM_ERROR_INVALID_ARGUMENT;
goto FINISH;
}
- /* Check if there's remaining focus for session for the same PID of incomming param */
- if (my_node->is_for_session) {
- for (list = g_focus_node_list; list != NULL; list = list->next) {
- CONTINUE_IF_LIST_DATA_IS_NULL(node, list);
- if (my_node == node || node->is_for_watch)
- continue;
- if (node->pid == my_node->pid && node->is_for_session && node->status) {
- debug_warning("another focus node for session of this pid exists, skip invoking callback");
- need_to_trigger = false;
- break;
- }
- }
- }
-
if (need_to_trigger) {
bool need_to_trigger_watch_cb = true;
_mm_sound_mgr_focus_param_t *new_param = NULL;
}
new_param->pid = param->pid;
new_param->handle_id = param->handle_id;
- new_param->is_for_session = my_node->is_for_session;
new_param->request_type = my_node->status;
new_param->option = my_node->option[i];
MMSOUND_STRNCPY(new_param->stream_type, my_node->stream_type, MAX_STREAM_TYPE_LEN);
continue;
if (my_node->taken_by_id[i].pid) {
- /* If exists update the taken focus info to my victim node */
- if (node->taken_by_id[i].by_session && !node->status)
- UPDATE_FOCUS_TAKEN_INFO(by_id, node, my_node->taken_by_id[i].pid, my_node->taken_by_id[i].handle_id, my_node->taken_by_id[i].by_session);
- else if (node->taken_by_id[i].handle_id == param->handle_id)
- UPDATE_FOCUS_TAKEN_INFO(by_id, node, my_node->taken_by_id[i].pid, my_node->taken_by_id[i].handle_id, false);
+ /* If exists update the taken focus info to my victim node */
+ if (node->taken_by_id[i].handle_id == param->handle_id)
+ UPDATE_FOCUS_TAKEN_INFO(by_id, node, my_node->taken_by_id[i].pid, my_node->taken_by_id[i].handle_id);
} else if (my_node->status & (i+1)) {
- if (node->is_for_session)
- continue;
- if (node->taken_by_id[i].handle_id == new_param->handle_id || node->taken_by_id[i].by_session) {
+ if (node->taken_by_id[i].handle_id == new_param->handle_id) {
/* do callback for resumption */
if ((ret = _mm_sound_mgr_focus_do_callback(FOCUS_COMMAND_ACQUIRE, node, new_param)))
debug_error("Fail to _focus_do_callback for COMMAND ACQUIRE to node[%p], ret[0x%x]", node, ret);
if (node->taken_by_id[i].pid == param->pid) {
/* victim node : append my node's taken info to my victim node */
if (my_node->taken_by_id[i].pid != 0) {
- UPDATE_FOCUS_TAKEN_INFO(backup, node, node->taken_by_id[i].pid, node->taken_by_id[i].handle_id, node->taken_by_id[i].by_session);
- UPDATE_FOCUS_TAKEN_INFO(by_id, node, my_node->taken_by_id[i].pid, my_node->taken_by_id[i].handle_id, my_node->taken_by_id[i].by_session);
+ UPDATE_FOCUS_TAKEN_INFO(backup, node, node->taken_by_id[i].pid, node->taken_by_id[i].handle_id);
+ UPDATE_FOCUS_TAKEN_INFO(by_id, node, my_node->taken_by_id[i].pid, my_node->taken_by_id[i].handle_id);
}
} else if (!list->next) {
/* my node : backup and reset */
- UPDATE_FOCUS_TAKEN_INFO(backup, my_node, my_node->taken_by_id[i].pid, my_node->taken_by_id[i].handle_id, my_node->taken_by_id[i].by_session);
- UPDATE_FOCUS_TAKEN_INFO(by_id, my_node, 0, 0, false);
+ UPDATE_FOCUS_TAKEN_INFO(backup, my_node, my_node->taken_by_id[i].pid, my_node->taken_by_id[i].handle_id);
+ UPDATE_FOCUS_TAKEN_INFO(by_id, my_node, 0, 0);
}
}
}
for (i = 0; i < NUM_OF_STREAM_IO_TYPE; i++) {
/* rollback and reset backup info. */
if (node->taken_by_id[i].pid && (node->taken_by_id[i].pid == my_node->taken_backup[i].pid)) {
- UPDATE_FOCUS_TAKEN_INFO(by_id, node, node->taken_backup[i].pid, node->taken_backup[i].handle_id, node->taken_backup[i].by_session);
- UPDATE_FOCUS_TAKEN_INFO(backup, node, 0, 0, false);
+ UPDATE_FOCUS_TAKEN_INFO(by_id, node, node->taken_backup[i].pid, node->taken_backup[i].handle_id);
+ UPDATE_FOCUS_TAKEN_INFO(backup, node, 0, 0);
} else if (!list->next) {
- UPDATE_FOCUS_TAKEN_INFO(by_id, my_node, my_node->taken_backup[i].pid, my_node->taken_backup[i].handle_id, my_node->taken_backup[i].by_session);
- UPDATE_FOCUS_TAKEN_INFO(backup, my_node, 0, 0, false);
+ UPDATE_FOCUS_TAKEN_INFO(by_id, my_node, my_node->taken_backup[i].pid, my_node->taken_backup[i].handle_id);
+ UPDATE_FOCUS_TAKEN_INFO(backup, my_node, 0, 0);
}
}
}
for (list = g_focus_node_list; list != NULL; list = list->next) {
CONTINUE_IF_LIST_DATA_IS_NULL(node, list);
if (!node->is_for_watch && (node->status & focus_type)) {
- /* In case of FOCUS_TYPE_BOTH, we use index for FOCUS_TYPE_PLAYBACK's forcedly.
- * It is because this function can not return both index of option, ext_info results
- * via out-parameter. This case is only used in framework internally for session
- * backward compatibilty. */
- int index = (focus_type == FOCUS_TYPE_BOTH) ? FOCUS_TYPE_PLAYBACK - 1 : focus_type - 1;
+ int index = focus_type - 1;
debug_msg("found a node : request_focus_type(%d), stream_type(%s)/ext info(%s) of acquired focus",
focus_type, node->stream_type, node->ext_info[index]);
*stream_type = node->stream_type;
*option = node->option[index];
- if (ext_info) {
- if (focus_type != FOCUS_TYPE_BOTH) {
- *ext_info = node->ext_info[index];
- } else {
- /* In case of FOCUS_TYPE_BOTH, it should be used only for
- * session backward compatibility. ext_info will contain pid of the node */
- gchar *buf = g_strdup_printf("%d", node->pid);
- if (buf) {
- *ext_info = buf;
- debug_msg("copied node->pid to ext_info [%s]", *ext_info);
- }
- }
- }
+ if (ext_info)
+ *ext_info = node->ext_info[index];
ret = MM_ERROR_NONE;
break;
}
debug_error("invalid direction(%d)", direction);
return;
}
-
- /* In case of session backward compatibility for audio-io, mm-player, mm-camcorder, we mark a specific flag here.
- When invoking focus state changed callback for acquiring, state of the node will not be updated rather updated
- when the next request to acquire. */
- if (!strncmp("audio-io acquire focus", node->ext_info[direction], MM_SOUND_NAME_NUM) ||
- !strncmp("mm-player acquire focus", node->ext_info[direction], MM_SOUND_NAME_NUM) ||
- !strncmp("mm-camcorder acquire focus", node->ext_info[direction], MM_SOUND_NAME_NUM)) {
- debug_msg("this node[pid:%d, handle_id:%d] needs reacquisition with focus released state", node->pid, node->handle_id);
- node->reacquisition_with_released_state = true;
- }
}
int mm_sound_mgr_focus_request_acquire(const _mm_sound_mgr_focus_param_t *param)
focus_node_t *my_node = NULL;
bool need_to_trigger_cb = false;
bool need_to_trigger_watch_cb = true;
- bool need_to_trigger_monitor_cb = true;
int i;
debug_fenter();
if (need_to_trigger_cb) {
_mm_sound_mgr_focus_param_t *param_s = (_mm_sound_mgr_focus_param_t *)param;
- param_s->is_for_session = my_node->is_for_session;
MMSOUND_STRNCPY(param_s->stream_type, my_node->stream_type, MAX_STREAM_TYPE_LEN);
for (list = g_focus_node_list; list != NULL; list = list->next) {
CONTINUE_IF_LIST_DATA_IS_NULL(node, list);
if (node == my_node || node->is_for_watch)
continue;
- if (node->pid == my_node->pid && node->is_for_session && my_node->is_for_session)
- continue;
if (param_s->request_type == FOCUS_TYPE_BOTH || node->status == FOCUS_STATUS_ACTIVATED_BOTH ||
(node->status & param_s->request_type)) {
if (node->status <= FOCUS_STATUS_DEACTIVATED)
}
if (!strncmp(my_node->stream_type, node->stream_type, MAX_STREAM_TYPE_LEN))
need_to_trigger_watch_cb = false;
-
- need_to_trigger_monitor_cb = false;
}
}
}
/* do watch callback due to the status of mine */
if (need_to_trigger_watch_cb)
_mm_sound_mgr_focus_do_watch_callback((focus_type_e)param->request_type, FOCUS_COMMAND_ACQUIRE, my_node, param);
- if (need_to_trigger_monitor_cb)
- _mm_sound_mgr_focus_do_monitor_callback_outer((focus_type_e)param->request_type, FOCUS_COMMAND_RELEASE, my_node, param);
/* update taken information */
for (i = 0; i < NUM_OF_STREAM_IO_TYPE; i++) {
if (param->request_type & (i+1)) {
- UPDATE_FOCUS_TAKEN_INFO(by_id, my_node, 0, 0, false);
- UPDATE_FOCUS_TAKEN_INFO(backup, my_node, 0, 0, false);
+ UPDATE_FOCUS_TAKEN_INFO(by_id, my_node, 0, 0);
+ UPDATE_FOCUS_TAKEN_INFO(backup, my_node, 0, 0);
}
}
}
focus_node_t *node = NULL;
focus_node_t *my_node = NULL;
bool need_to_trigger_watch_cb = true;
- bool need_to_trigger_monitor_cb = true;
bool need_to_trigger_cb = true;
int i = 0;
goto FINISH;
}
- /* Check if there's activating focus for session for the same PID of incomming param*/
- if (my_node->is_for_session) {
- for (list = g_focus_node_list; list != NULL; list = list->next) {
- CONTINUE_IF_LIST_DATA_IS_NULL(node, list);
- if (node == my_node || node->is_for_watch)
- continue;
- if (node->pid == my_node->pid && node->is_for_session && node->status) {
- debug_warning("another focus node for session of this pid exists, skip invoking callback");
- need_to_trigger_watch_cb = false;
- need_to_trigger_cb = false;
- break;
- }
- }
- }
-
if (need_to_trigger_cb) {
_mm_sound_mgr_focus_param_t *param_s = (_mm_sound_mgr_focus_param_t *)param;
- param_s->is_for_session = my_node->is_for_session;
MMSOUND_STRNCPY(param_s->stream_type, my_node->stream_type, MAX_STREAM_TYPE_LEN);
for (list = g_focus_node_list; list != NULL; list = list->next) {
CONTINUE_IF_LIST_DATA_IS_NULL(node, list);
for (i = 0; i < NUM_OF_STREAM_IO_TYPE; i++) {
if (param_s->request_type & (i+1)) {
if (node->taken_by_id[i].pid == param_s->pid &&
- (node->taken_by_id[i].handle_id == param_s->handle_id || node->taken_by_id[i].by_session)) {
- /* exception case as per the previous session policy,
- * "session resumption" is only available for "media session" */
- if (my_node->is_for_session && node->is_for_session) {
- if (strncmp(node->stream_type, "media", MAX_STREAM_TYPE_LEN))
- continue;
- }
+ node->taken_by_id[i].handle_id == param_s->handle_id) {
/* do callback for resumption */
if ((ret = _mm_sound_mgr_focus_do_callback(FOCUS_COMMAND_ACQUIRE, node, param_s)))
debug_error("Fail to _focus_do_callback for COMMAND ACQUIRE to node[%p], ret[0x%x]", node, ret);
if (!strncmp(my_node->stream_type, node->stream_type, MAX_STREAM_TYPE_LEN))
need_to_trigger_watch_cb = false;
-
- need_to_trigger_monitor_cb = false;
}
}
}
/* do watch callback due to the status of mine */
if (need_to_trigger_watch_cb)
_mm_sound_mgr_focus_do_watch_callback((focus_type_e)param->request_type, FOCUS_COMMAND_RELEASE, my_node, param);
- if (need_to_trigger_monitor_cb)
- _mm_sound_mgr_focus_do_monitor_callback_outer((focus_type_e)param->request_type, FOCUS_COMMAND_ACQUIRE, my_node, param);
_mm_sound_mgr_focus_list_dump();
_mm_sound_mgr_focus_watch_list_dump();
/* fill up information to the node */
_mm_sound_mgr_focus_fill_info_from_msg(node, param);
node->is_for_watch = true;
- node->is_for_monitor = param->is_for_monitor;
node->status = param->request_type;
g_focus_node_list = g_list_append(g_focus_node_list, node);
for (list = g_focus_node_list; list != NULL; list = list->next) {
CONTINUE_IF_LIST_DATA_IS_NULL(node, list);
if ((node->taken_by_id[i].pid == src_node->pid) &&
- (node->taken_by_id[i].handle_id == src_node->handle_id) &&
- (node->taken_by_id[i].by_session == false)) {
+ (node->taken_by_id[i].handle_id == src_node->handle_id)) {
debug_log("found the node pid[%d]/handle_id[%d] that focus was taken by this src node, update it",
node->pid, node->handle_id);
- UPDATE_FOCUS_TAKEN_INFO(by_id, node, dst_node->pid, dst_node->handle_id, false);
+ UPDATE_FOCUS_TAKEN_INFO(by_id, node, dst_node->pid, dst_node->handle_id);
}
if ((node->taken_backup[i].pid == src_node->pid) &&
- (node->taken_backup[i].handle_id == src_node->handle_id) &&
- (node->taken_backup[i].by_session == false)) {
+ (node->taken_backup[i].handle_id == src_node->handle_id)) {
debug_log("found the node pid[%d]/handle_id[%d] that focus was taken by this src node and set reacquisition to false, update it",
node->pid, node->handle_id);
- UPDATE_FOCUS_TAKEN_INFO(backup, node, dst_node->pid, dst_node->handle_id, false);
+ UPDATE_FOCUS_TAKEN_INFO(backup, node, dst_node->pid, dst_node->handle_id);
}
}
dst_node->status |= (i+1);
- UPDATE_FOCUS_TAKEN_INFO(by_id, dst_node, 0, 0, false);
- UPDATE_FOCUS_TAKEN_INFO(backup, dst_node, 0, 0, false);
+ UPDATE_FOCUS_TAKEN_INFO(by_id, dst_node, 0, 0);
+ UPDATE_FOCUS_TAKEN_INFO(backup, dst_node, 0, 0);
MMSOUND_STRNCPY(dst_node->ext_info[i], src_node->ext_info[i], MM_SOUND_NAME_NUM);
dst_node->option[i] = src_node->option[i];
for (i = 0; i < NUM_OF_STREAM_IO_TYPE; i++) {
if (node->taken_by_id[i].pid == param->pid) {
if (my_node->taken_by_id[i].pid)
- UPDATE_FOCUS_TAKEN_INFO(by_id, node, my_node->taken_by_id[i].pid, my_node->taken_by_id[i].handle_id, my_node->taken_by_id[i].by_session);
+ UPDATE_FOCUS_TAKEN_INFO(by_id, node, my_node->taken_by_id[i].pid, my_node->taken_by_id[i].handle_id);
else
- UPDATE_FOCUS_TAKEN_INFO(by_id, node, 0, 0, false);
+ UPDATE_FOCUS_TAKEN_INFO(by_id, node, 0, 0);
}
}
}
" <arg name='pid' type='i' direction='in'/>"
" <arg name='handle_id' type='i' direction='in'/>"
" <arg name='stream_type' type='s' direction='in'/>"
- " <arg name='is_for_session' type='b' direction='in'/>"
" </method>"
" <method name='UnregisterFocus'>"
" <arg name='pid' type='i' direction='in'/>"
" <arg name='handle_id' type='i' direction='in'/>"
- " <arg name='is_for_session' type='b' direction='in'/>"
" </method>"
" <method name='SetFocusReacquisition'>"
" <arg name='pid' type='i' direction='in'/>"
" <arg name='handle_id' type='i' direction='in'/>"
" <arg name='reacquisition' type='b' direction='in'/>"
- " <arg name='is_for_session' type='b' direction='in'/>"
" </method>"
" <method name='GetAcquiredFocusStreamType'>"
" <arg name='focus_type' type='i' direction='in'/>"
" <arg name='focus_type' type='i' direction='in'/>"
" <arg name='option' type='i' direction='in'/>"
" <arg name='ext_info' type='s' direction='in'/>"
- " <arg name='is_for_session' type='b' direction='in'/>"
" </method>"
" <method name='ReleaseFocus'>"
" <arg name='pid' type='i' direction='in'/>"
" <arg name='focus_type' type='i' direction='in'/>"
" <arg name='option' type='i' direction='in'/>"
" <arg name='ext_info' type='s' direction='in'/>"
- " <arg name='is_for_session' type='b' direction='in'/>"
" </method>"
" <method name='WatchFocus'>"
" <arg name='pid' type='i' direction='in'/>"
" <arg name='handle_id' type='i' direction='in'/>"
" <arg name='focus_type' type='i' direction='in'/>"
- " <arg name='is_for_session' type='b' direction='in'/>"
- " <arg name='is_for_monitor' type='b' direction='in'/>"
" </method>"
" <method name='UnwatchFocus'>"
" <arg name='pid' type='i' direction='in'/>"
" <arg name='handle_id' type='i' direction='in'/>"
- " <arg name='is_for_session' type='b' direction='in'/>"
" </method>"
" <method name='DeliverFocus'>"
" <arg name='pid' type='i' direction='in'/>"
int ret = MM_ERROR_NONE;
int handle_id = 0;
const char* stream_type = NULL;
- gboolean is_for_session;
GVariant *params = NULL;
int pid = 0;
goto send_reply;
}
- g_variant_get(params, "(ii&sb)", &pid, &handle_id, &stream_type, &is_for_session);
- ret = __mm_sound_mgr_focus_ipc_register_focus((is_for_session) ? pid : _get_sender_pid(invocation), handle_id, stream_type, is_for_session);
+ g_variant_get(params, "(ii&s)", &pid, &handle_id, &stream_type);
+ ret = __mm_sound_mgr_focus_ipc_register_focus(_get_sender_pid(invocation), handle_id, stream_type);
send_reply:
if (ret == MM_ERROR_NONE)
{
int ret = MM_ERROR_NONE;
int pid = 0, handle_id = 0;
- gboolean is_for_session;
GVariant *params = NULL;
debug_fenter();
goto send_reply;
}
- g_variant_get(params, "(iib)", &pid, &handle_id, &is_for_session);
- ret = __mm_sound_mgr_focus_ipc_unregister_focus((is_for_session) ? pid : _get_sender_pid(invocation), handle_id, is_for_session);
+ g_variant_get(params, "(ii)", &pid, &handle_id);
+ ret = __mm_sound_mgr_focus_ipc_unregister_focus(_get_sender_pid(invocation), handle_id);
send_reply:
if (ret == MM_ERROR_NONE)
int ret = MM_ERROR_NONE;
int pid = 0, handle_id = 0;
gboolean reacquisition;
- gboolean is_for_session;
GVariant *params = NULL;
debug_fenter();
goto send_reply;
}
- g_variant_get(params, "(iibb)", &pid, &handle_id, &reacquisition, &is_for_session);
- ret = __mm_sound_mgr_focus_ipc_set_focus_reacquisition(_get_sender_pid(invocation), handle_id, reacquisition, is_for_session);
+ g_variant_get(params, "(iib)", &pid, &handle_id, &reacquisition);
+ ret = __mm_sound_mgr_focus_ipc_set_focus_reacquisition(_get_sender_pid(invocation), handle_id, reacquisition);
send_reply:
if (ret == MM_ERROR_NONE)
else
_method_call_return_error(invocation, ret);
- /* In case of FOCUS_TYPE_BOTH, it should be used only for
- * session backward compatibility. ext_info contains pid of the node,
- * and should be freed here. */
- if (focus_type == FOCUS_TYPE_BOTH && ext_info)
- g_free(ext_info);
-
debug_fleave();
}
int ret = MM_ERROR_NONE;
int pid = 0, handle_id = 0, focus_type = 0, option = 0;
const char* ext_info = NULL;
- gboolean is_for_session;
GVariant *params = NULL;
debug_fenter();
goto send_reply;
}
- g_variant_get(params, "(iiiisb)", &pid, &handle_id, &focus_type, &option, &ext_info, &is_for_session);
- ret = __mm_sound_mgr_focus_ipc_acquire_focus((is_for_session) ? pid : _get_sender_pid(invocation),
- handle_id, focus_type, option, ext_info, false, is_for_session);
+ g_variant_get(params, "(iiiis)", &pid, &handle_id, &focus_type, &option, &ext_info);
+ ret = __mm_sound_mgr_focus_ipc_acquire_focus(_get_sender_pid(invocation),
+ handle_id, focus_type, option, ext_info, false);
send_reply:
if (ret == MM_ERROR_NONE)
int ret = MM_ERROR_NONE;
int pid = 0, handle_id = 0, focus_type = 0, option = 0;
const char* ext_info = NULL;
- gboolean is_for_session;
GVariant *params = NULL;
debug_fenter();
goto send_reply;
}
- g_variant_get(params, "(iiiisb)", &pid, &handle_id, &focus_type, &option, &ext_info, &is_for_session);
- ret = __mm_sound_mgr_focus_ipc_release_focus((is_for_session) ? pid : _get_sender_pid(invocation),
- handle_id, focus_type, option, ext_info, false, is_for_session);
+ g_variant_get(params, "(iiiis)", &pid, &handle_id, &focus_type, &option, &ext_info);
+ ret = __mm_sound_mgr_focus_ipc_release_focus(_get_sender_pid(invocation),
+ handle_id, focus_type, option, ext_info, false);
send_reply:
if (ret == MM_ERROR_NONE)
{
int ret = MM_ERROR_NONE;
int handle_id = 0, focus_type = 0;
- gboolean is_for_session;
- gboolean is_for_monitor;
GVariant *params = NULL;
int pid = 0;
goto send_reply;
}
- g_variant_get(params, "(iiibb)", &pid, &handle_id, &focus_type, &is_for_session, &is_for_monitor);
- ret = __mm_sound_mgr_focus_ipc_watch_focus((is_for_session) ? pid : _get_sender_pid(invocation), handle_id, focus_type, is_for_session, is_for_monitor);
+ g_variant_get(params, "(iii)", &pid, &handle_id, &focus_type);
+ ret = __mm_sound_mgr_focus_ipc_watch_focus(_get_sender_pid(invocation), handle_id, focus_type);
send_reply:
if (ret == MM_ERROR_NONE)
int ret = MM_ERROR_NONE;
int pid = 0;
int handle_id = 0;
- gboolean is_for_session;
GVariant *params = NULL;
debug_fenter();
goto send_reply;
}
- g_variant_get(params, "(iib)", &pid, &handle_id, &is_for_session);
- ret = __mm_sound_mgr_focus_ipc_unwatch_focus((is_for_session) ? pid : _get_sender_pid(invocation), handle_id);
+ g_variant_get(params, "(ii)", &pid, &handle_id);
+ ret = __mm_sound_mgr_focus_ipc_unwatch_focus(_get_sender_pid(invocation), handle_id);
send_reply:
if (ret == MM_ERROR_NONE)
#include "include/mm_sound_mgr_focus.h"
#include <mm_debug.h>
-int __mm_sound_mgr_focus_ipc_register_focus(int client_pid, int handle_id, const char* stream_type, bool is_for_session)
+int __mm_sound_mgr_focus_ipc_register_focus(int client_pid, int handle_id, const char* stream_type)
{
_mm_sound_mgr_focus_param_t param;
int ret = MM_ERROR_NONE;
memset(¶m, 0x00, sizeof(_mm_sound_mgr_focus_param_t));
param.pid = client_pid;
param.handle_id = handle_id;
- param.is_for_session = is_for_session;
MMSOUND_STRNCPY(param.stream_type, stream_type, MAX_STREAM_TYPE_LEN);
ret = mm_sound_mgr_focus_create_node(¶m);
}
// method + remove callback
-int __mm_sound_mgr_focus_ipc_unregister_focus(int pid, int handle_id, bool is_for_session)
+int __mm_sound_mgr_focus_ipc_unregister_focus(int pid, int handle_id)
{
_mm_sound_mgr_focus_param_t param;
int ret = MM_ERROR_NONE;
memset(¶m, 0x00, sizeof(_mm_sound_mgr_focus_param_t));
param.pid = pid;
param.handle_id = handle_id;
- param.is_for_session = is_for_session;
ret = mm_sound_mgr_focus_destroy_node(¶m);
}
// method -> callback
-int __mm_sound_mgr_focus_ipc_set_focus_reacquisition(int pid, int handle_id, bool reacquisition, bool is_for_session)
+int __mm_sound_mgr_focus_ipc_set_focus_reacquisition(int pid, int handle_id, bool reacquisition)
{
_mm_sound_mgr_focus_param_t param;
int ret = MM_ERROR_NONE;
param.pid = pid;
param.handle_id = handle_id;
param.reacquisition = reacquisition;
- param.is_for_session = is_for_session;
ret = mm_sound_mgr_focus_set_reacquisition(¶m);
}
// method -> callback
-int __mm_sound_mgr_focus_ipc_acquire_focus(int pid, int handle_id, int focus_type, int option, const char *ext_info, bool is_in_thread, bool is_for_session)
+int __mm_sound_mgr_focus_ipc_acquire_focus(int pid, int handle_id, int focus_type, int option, const char *ext_info, bool is_in_thread)
{
_mm_sound_mgr_focus_param_t param;
int ret = MM_ERROR_NONE;
param.request_type = focus_type;
param.option = option;
param.is_in_thread = is_in_thread;
- param.is_for_session = is_for_session;
MMSOUND_STRNCPY(param.ext_info, ext_info, MM_SOUND_NAME_NUM);
ret = mm_sound_mgr_focus_request_acquire(¶m);
}
// method -> callback
-int __mm_sound_mgr_focus_ipc_release_focus(int pid, int handle_id, int focus_type, int option, const char *ext_info, bool is_in_thread, bool is_for_session)
+int __mm_sound_mgr_focus_ipc_release_focus(int pid, int handle_id, int focus_type, int option, const char *ext_info, bool is_in_thread)
{
_mm_sound_mgr_focus_param_t param;
int ret = MM_ERROR_NONE;
param.request_type = focus_type;
param.option = option;
param.is_in_thread = is_in_thread;
- param.is_for_session = is_for_session;
MMSOUND_STRNCPY(param.ext_info, ext_info, MM_SOUND_NAME_NUM);
ret = mm_sound_mgr_focus_request_release(¶m);
return ret;
}
-int __mm_sound_mgr_focus_ipc_watch_focus(int pid, int handle_id, int focus_type, bool is_for_session, bool is_for_monitor)
+int __mm_sound_mgr_focus_ipc_watch_focus(int pid, int handle_id, int focus_type)
{
_mm_sound_mgr_focus_param_t param;
int ret = MM_ERROR_NONE;
param.pid = pid;
param.handle_id = handle_id;
param.request_type = focus_type;
- param.is_for_session = is_for_session;
- param.is_for_monitor = is_for_monitor;
ret = mm_sound_mgr_focus_set_watch_cb(¶m);
debug_fenter();
ret = __mm_sound_mgr_focus_ipc_acquire_focus(param->pid, param->handle_id, param->focus_type,
- param->option, param->ext_info, true, param->is_for_session);
+ param->option, param->ext_info, true);
debug_fleave();
debug_fenter();
ret = __mm_sound_mgr_focus_ipc_release_focus(param->pid, param->handle_id, param->focus_type,
- param->option, param->ext_info, true, param->is_for_session);
+ param->option, param->ext_info, true);
debug_fleave();
int ret = MM_ERROR_NONE;
debug_log("data read successfully..");
debug_log(" : pid[%d], handle_id[%d], focus_type[%d]", read_data.pid, read_data.handle_id, read_data.focus_type);
- debug_log(" : option[%d], ext_info[%s], is_for_session[%d]", read_data.option, read_data.ext_info, read_data.is_for_session);
+ debug_log(" : option[%d], ext_info[%s]", read_data.option, read_data.ext_info);
if ((ret = focus_functions_handler(&read_data)))
debug_log("failed to focus_function_handler(), err[0x%x]", ret);
* MMSound Play APIs
*/
-/**
- * This function is to play system sound.
- *
- * @param filename [in] Sound filename to play
- * @param volume config [in] Volume type & volume gain
- * @param callback [in] Callback function pointer when playing is terminated.
- * @param data [in] Pointer to user data when callback is called.
- * @param handle [out] Handle of sound play.
- *
- * @return This function returns MM_ERROR_NONE on success, or negative value
- * with error code.
- * @remark When the stop callback is set, it will be called when system sound is
- * terminated. If mm_sound_stop_sound() is called apparently before
- * system sound is terminated, stop_callback will not be called.
- * @see mm_sound_stop_sound mm_sound_stop_callback_func volume_type_t volume_gain_t
- * @pre None.
- * @post Sound will be generated with given filename.
- * @par Example
- * @code
-int g_stop=0;
-void _stop_callback(void* data)
-{
- printf("Stop callback\n");
- g_stop = 1;
-}
-
-int play_file()
-{
- char filename[] ="testfile.wav";
- volume_type_t volume = VOLUME_TYPE_SYSTEM;
- int ret = 0;
- int handle = -1;
-
- ret = mm_sound_play_sound(filename, volume, _stop_callback, NULL, &handle);
- if(ret < 0)
- {
- printf("play file failed\n");
- }
- else
- {
- printf("play file success\n");
- }
- while(g_stop == 0)
- {
- sleep(1);
- }
- printf("play stopped\n");
- return 0;
-}
- * @endcode
- */
-int mm_sound_play_sound(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle);
-
-/**
- * This function is to play system sound. And other audio stream will be mute during playing time
- *
- * @param filename [in] Sound filename to play
- * @param volume config [in] Volume type & volume gain
- * @param callback [in] Callback function pointer when playing is terminated.
- * @param data [in] Pointer to user data when callback is called.
- * @param handle [out] Handle of sound play.
- *
- * @return This function returns MM_ERROR_NONE on success, or negative value
- * with error code.
- * @remark This function is almost same with mm_sound_play_sound,
- * but this make other audio playback stream to mute during playing time.
- * @see mm_sound_stop_sound mm_sound_stop_callback_func volume_type_t volume_gain_t
- * @pre None.
- * @post Sound will be generated with given filename.
- * @par Example
- * @code
-int g_stop=0;
-void _stop_callback(void* data)
-{
- printf("Stop callback\n");
- g_stop = 1;
-}
-
-int play_file()
-{
- char filename[] ="testfile.wav";
- volume_type_t volume = VOLUME_TYPE_SYSTEM;
- int ret = 0;
- int handle = -1;
-
- ret = mm_sound_play_loud_solo_sound(filename, volume, _stop_callback, NULL, &handle);
- if(ret < 0)
- {
- printf("play file failed\n");
- }
- else
- {
- printf("play file success\n");
- }
- while(g_stop == 0)
- {
- sleep(1);
- }
- printf("play stopped\n");
- return 0;
-}
- * @endcode
- */
-int mm_sound_play_loud_solo_sound(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle);
+int mm_sound_play_sound_with_stream_info(const char *filename, char *stream_type, int stream_id, unsigned int loop, mm_sound_stop_callback_func _completed_cb, void *data, int *handle);
/**
* This function is to stop playing system sound.
typedef unsigned long sound_time_msec_t; /**< millisecond unit */
-/**
- * This function is to play tone sound.
- *
- * @param num [in] predefined tone type (MMSoundTone_t)
- * volume config [in] volume type & volume gain
- * volume [in] volume ratio (0.0 ~1.0)
- * duration [in] millisecond (-1 for infinite)
- * handle [in] Handle of mm_sound_play_tone
- * enable_session [in] set enable/unable session
- *
- * @return This function returns MM_ERROR_NONE on success, or negative value
- * with error code.
- *
- * @remark It doesn't provide stop
- * @see volume_type_t volume_gain_t MMSoundTone_t
- * @pre None.
- * @post TONE sound will be played.
- * @par Example
- * @code
-int ret = 0;
-
-ret = mm_sound_play_tone_ex(MM_SOUND_TONE_DTMF_9, VOLUME_TYPE_SYSTEM, 1.0, 1000, &handle, TRUE); //play 1 second with volume ratio 1.0
-if(ret < 0)
-{
- printf("play tone failed\n");
-}
-else
-{
- printf("play tone success\n");
-}
- * @endcode
- */
-int mm_sound_play_tone_ex(MMSoundTone_t num, int volume_config, const double volume, const int duration, int *handle, bool enable_session);
-
-/**
- * This function is to play tone sound.
- *
- * @param num [in] predefined tone type (MMSoundTone_t)
- * volume config [in] volume type & volume gain
- * volume [in] volume ratio (0.0 ~1.0)
- * duration [in] millisecond (-1 for infinite)
- * handle [in] Handle of mm_sound_play_tone
- *
- * @return This function returns MM_ERROR_NONE on success, or negative value
- * with error code.
- *
- * @remark It doesn't provide stop
- * @see volume_type_t volume_gain_t MMSoundTone_t
- * @pre None.
- * @post TONE sound will be played.
- * @par Example
- * @code
-int ret = 0;
-
-ret = mm_sound_play_tone(MM_SOUND_TONE_DTMF_9, VOLUME_TYPE_SYSTEM, 1.0, 1000, &handle); //play 1 second with volume ratio 1.0
-if(ret < 0)
-{
- printf("play tone failed\n");
-}
-else
-{
- printf("play tone success\n");
-}
- * @endcode
- */
-int mm_sound_play_tone(MMSoundTone_t num, int volume_config, const double volume, const int duration, int *handle);
-
int mm_sound_play_tone_with_stream_info(MMSoundTone_t tone, char *stream_type, int stream_id, const double volume, const int duration, int *handle);
/*
void mm_sound_convert_volume_type_to_stream_type(int volume_type, char *stream_type);
-typedef enum {
- MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS,
- MM_SOUND_SIGNAL_MAX,
-} mm_sound_signal_name_t;
-
-typedef void (*mm_sound_signal_callback) (mm_sound_signal_name_t signal_type, int value, void *user_data);
-int mm_sound_subscribe_signal(mm_sound_signal_name_t signal_type, unsigned int *subscribe_id, mm_sound_signal_callback callback, void *user_data);
-int mm_sound_subscribe_signal_for_daemon(mm_sound_signal_name_t signal_type, int client_pid, unsigned int *subscribe_id, mm_sound_signal_callback callback, void *user_data);
-void mm_sound_unsubscribe_signal(unsigned int subscribe_id);
-int mm_sound_send_signal(mm_sound_signal_name_t signal_type, int value);
-int mm_sound_get_signal_value(mm_sound_signal_name_t signal_type, int *value);
int mm_sound_is_stream_on_device(int stream_id, MMSoundDevice_t device_h, bool *is_on);
int mm_sound_is_device_running(MMSoundDevice_t device_h, bool *is_running);
int mm_sound_client_initialize(void);
int mm_sound_client_finalize(void);
-int mm_sound_client_play_tone(int number, int volume_config, double volume, int time, int *handle, bool enable_session);
int mm_sound_client_play_tone_with_stream_info(int tone, char *stream_type, int stream_id, double volume, int duration, int *handle);
-int mm_sound_client_play_sound(MMSoundPlayParam *param, int tone, int *handle);
int mm_sound_client_play_sound_with_stream_info(MMSoundPlayParam *param, int *handle, char* stream_type, int stream_id);
int mm_sound_client_stop_sound(int handle);
int mm_sound_client_set_volume_by_type(const int volume_type, const unsigned int volume_level);
int mm_sound_client_remove_device_running_changed_callback(unsigned int id);
int mm_sound_client_is_stream_on_device(int stream_id, int device_id, bool *is_on);
#ifdef USE_FOCUS
-int mm_sound_client_set_session_interrupt_callback(mm_sound_focus_session_interrupt_cb callback, void* user_data);
-int mm_sound_client_unset_session_interrupt_callback(void);
int mm_sound_client_get_unique_id(int *id);
int mm_sound_client_is_focus_cb_thread(GThread *mine, bool *result);
-int mm_sound_client_register_focus(int id, int pid, const char *stream_type, bool is_for_session, mm_sound_focus_changed_cb callback, void* user_data);
+int mm_sound_client_register_focus(int id, int pid, const char *stream_type, mm_sound_focus_changed_cb callback, void* user_data);
int mm_sound_client_unregister_focus(int id);
-int mm_sound_client_set_focus_reacquisition(int id, bool reacquisition, bool is_for_session);
+int mm_sound_client_set_focus_reacquisition(int id, bool reacquisition);
int mm_sound_client_get_focus_reacquisition(int id, bool *reacquisition);
int mm_sound_client_get_acquired_focus_stream_type(int focus_type, char **stream_type, int *option, char **ext_info);
int mm_sound_client_acquire_focus(int id, mm_sound_focus_type_e type, int option, const char *ext_info);
int mm_sound_client_release_focus(int id, mm_sound_focus_type_e type, int option, const char *ext_info);
int mm_sound_client_update_stream_focus_status(int id, unsigned int status);
int mm_sound_client_deliver_focus(int pid, int src_id, int dst_id, mm_sound_focus_type_e focus_type);
-int mm_sound_client_set_focus_watch_callback(int pid, mm_sound_focus_type_e type, bool is_for_session, bool is_for_monitor, mm_sound_focus_changed_watch_cb callback, void* user_data, int *id);
+int mm_sound_client_set_focus_watch_callback(int pid, mm_sound_focus_type_e type, mm_sound_focus_changed_watch_cb callback, void* user_data, int *id);
int mm_sound_client_unset_focus_watch_callback(int id);
int mm_sound_client_request_unset_focus_watch_callback(int id);
int mm_sound_client_execute_focus_func_in_main_context(focus_idle_event_type_e type, int data);
typedef void (*mm_sound_focus_changed_cb) (int id, mm_sound_focus_type_e focus_type, mm_sound_focus_state_e state, const char *reason_for_change, int option, const char *ext_info, void *user_data);
int mm_sound_register_focus(int id, const char *stream_type, mm_sound_focus_changed_cb callback, void *user_data);
-int mm_sound_register_focus_for_session(int id, int pid, const char *stream_type, mm_sound_focus_changed_cb callback, void *user_data);
int mm_sound_unregister_focus(int id);
int mm_sound_set_focus_reacquisition(int id, bool reacquisition);
-int mm_sound_set_focus_reacquisition_for_session(int id, bool reacquisition);
int mm_sound_get_focus_reacquisition(int id, bool *reacquisition);
int mm_sound_get_stream_type_of_acquired_focus(int focus_type, char **stream_type, int *option, char **ext_info);
int mm_sound_acquire_focus(int id, mm_sound_focus_type_e focus_type, const char *ext_info);
typedef void (*mm_sound_focus_changed_watch_cb) (int id, mm_sound_focus_type_e focus_type, mm_sound_focus_state_e state, const char *reason_for_change, const char *ext_info, void *user_data);
int mm_sound_set_focus_watch_callback(mm_sound_focus_type_e focus_type, mm_sound_focus_changed_watch_cb callback, void *user_data, int *id);
-int mm_sound_set_focus_watch_callback_for_session(int pid, mm_sound_focus_type_e focus_type, mm_sound_focus_changed_watch_cb callback, void *user_data, int *id);
-int mm_sound_set_focus_watch_callback_for_session_monitor(int pid, mm_sound_focus_type_e focus_type, mm_sound_focus_changed_watch_cb callback, void *user_data, int *id);
int mm_sound_unset_focus_watch_callback(int id);
-typedef void (*mm_sound_focus_session_interrupt_cb) (mm_sound_focus_state_e state, const char *reason_for_change, void *user_data);
-int mm_sound_focus_set_session_interrupt_callback(mm_sound_focus_session_interrupt_cb callback, void *user_data);
-int mm_sound_focus_unset_session_interrupt_callback(void);
-
-
#ifdef __cplusplus
}
#endif
int option;
char ext_info[MM_SOUND_NAME_NUM];
bool is_in_thread; /* Called within focus callback thread */
- bool is_for_session; /* will be removed when the session concept is completely left out*/
} _mm_sound_mgr_focus_socket_param_t;
/* Function names */
#define FOCUS_ERROR_INTERNAL "error_internal"
#define FOCUS_ERROR_INVALID_STATE "error_invalid_state"
-int mm_sound_focus_socket_acquire(int instance, int id, mm_sound_focus_type_e focus_type, int option, const char *ext_info, bool is_in_thread, bool is_for_session);
-int mm_sound_focus_socket_release(int instance, int id, mm_sound_focus_type_e focus_type, int option, const char *ext_info, bool is_in_thread, bool is_for_session);
+int mm_sound_focus_socket_acquire(int instance, int id, mm_sound_focus_type_e focus_type, int option, const char *ext_info, bool is_in_thread);
+int mm_sound_focus_socket_release(int instance, int id, mm_sound_focus_type_e focus_type, int option, const char *ext_info, bool is_in_thread);
#ifdef __cplusplus
}
typedef enum audio_method {
AUDIO_METHOD_TEST,
- AUDIO_METHOD_PLAY_FILE_START,
AUDIO_METHOD_PLAY_FILE_START_WITH_STREAM_INFO,
AUDIO_METHOD_PLAY_FILE_STOP,
- AUDIO_METHOD_PLAY_DTMF,
AUDIO_METHOD_PLAY_DTMF_WITH_STREAM_INFO,
- AUDIO_METHOD_CLEAR_FOCUS, /* Not original focus feature, only for tone/wav player internal focus usage. */
AUDIO_METHOD_GET_BT_A2DP_STATUS,
AUDIO_METHOD_SET_PATH_FOR_ACTIVE_DEVICE,
AUDIO_METHOD_GET_CONNECTED_DEVICE_LIST,
*/
-#define MM_SOUND_VOLUME_CONFIG_TYPE(vol) (vol & 0x00FF)
-
typedef struct {
- const char *filename; /**< filename to play */
- bool skip_session; /**< skip session control */
- int volume; /**< relative volume level */
- int loop; /**< loop count */
- mm_sound_stop_callback_func callback; /**< callback function when playing is terminated */
- void *data; /**< user data to callback */
- void *mem_ptr; /**< memory buffer to play */
- int mem_size; /**< size of memory buffer */
- int volume_config; /**< volume type & volume gain */
+ const char *filename; /**< filename to play */
+ int volume; /**< relative volume level */
+ int loop; /**< loop count */
+ mm_sound_stop_callback_func callback; /**< callback function when playing is terminated */
+ void *data; /**< user data to callback */
+ int volume_config; /**< volume type & volume gain */
} MMSoundPlayParam;
/**
- * This function is to play system sound with specified parameters.
- *
- * @param param [in] Reference pointer to MMSoundPlayParam structure
- * @param handle [out] Handle of sound play.
- *
- * @return This function returns MM_ERROR_NONE on success, or negative value
- * with error code.
- * @remark When the stop callback is set, it will be called when system sound is
- * terminated. If mm_sound_stop_sound() is called apparently before
- * system sound is terminated, stop_callback will not be called.
- * This function can use various sound route path with mm_sound_set_path
- * @see mm_sound_stop_sound mm_sound_set_path
- * @since R1, 1.0
- * @limo
- */
-int mm_sound_play_sound_ex(MMSoundPlayParam *param, int *handle);
-
-int mm_sound_play_sound_with_stream_info(const char *filename, char *stream_type, int stream_id, unsigned int loop, mm_sound_stop_callback_func _completed_cb, void *data, int *handle);
-
-/**
* This function is to play key sound.
*
* @param filename [in] keytone filename to play
typedef void (*mm_sound_proxy_userdata_free) (void *data);
-int mm_sound_proxy_play_tone(int tone, int repeat, int volume, int volume_config,
- int session_type, int session_options, int client_pid,
- bool enable_session, int *codechandle, char *stream_type, int stream_index);
int mm_sound_proxy_play_tone_with_stream_info(int client_pid, int tone, char *stream_type, int stream_id, int volume, int repeat, int *codechandle);
-int mm_sound_proxy_play_sound(const char* filename, int tone, int repeat, int volume, int volume_config,
- int session_type, int session_options, int client_pid, bool enable_session, int *codechandle, char *stream_type, int stream_index);
int mm_sound_proxy_play_sound_with_stream_info(const char* filename, int repeat, int volume,
int client_pid, int *codechandle, char *stream_type, int stream_index);
int mm_sound_proxy_stop_sound(int handle);
-int mm_sound_proxy_clear_focus(int pid); // Not original focus feature, only for cleaning up tone/wav player internal focus usage.
int mm_sound_proxy_add_play_sound_end_callback(mm_sound_stop_callback_wrapper_func func, void* userdata, mm_sound_proxy_userdata_free freefunc, unsigned *subs_id);
int mm_sound_proxy_remove_play_sound_end_callback(unsigned subs_id);
int mm_sound_proxy_get_current_connected_device_list(int device_flags, GList** device_list);
#ifdef USE_FOCUS
int mm_sound_proxy_get_unique_id(int *id);
-int mm_sound_proxy_register_focus(int id, int instance, const char *stream_type, mm_sound_focus_changed_cb callback, bool is_for_session, void* user_data);
-int mm_sound_proxy_unregister_focus(int instance, int id, bool is_for_session);
-int mm_sound_proxy_set_focus_reacquisition(int instance, int id, bool reacquisition, bool is_for_session);
+int mm_sound_proxy_register_focus(int id, int instance, const char *stream_type, mm_sound_focus_changed_cb callback, void* user_data);
+int mm_sound_proxy_unregister_focus(int instance, int id);
+int mm_sound_proxy_set_focus_reacquisition(int instance, int id, bool reacquisition);
int mm_sound_proxy_get_acquired_focus_stream_type(int focus_type, char **stream_type, int *option, char **ext_info);
-int mm_sound_proxy_acquire_focus(int instance, int id, mm_sound_focus_type_e type, int option, const char *ext_info, bool is_for_session);
-int mm_sound_proxy_release_focus(int instance, int id, mm_sound_focus_type_e type, int option, const char *ext_info, bool is_for_session);
+int mm_sound_proxy_acquire_focus(int instance, int id, mm_sound_focus_type_e type, int option, const char *ext_info);
+int mm_sound_proxy_release_focus(int instance, int id, mm_sound_focus_type_e type, int option, const char *ext_info);
int mm_sound_proxy_update_stream_focus_status(int focus_id, unsigned int status);
int mm_sound_proxy_deliver_focus(int pid, int src_id, int dst_id, mm_sound_focus_type_e focus_type);
-int mm_sound_proxy_set_focus_watch_callback(int instance, int handle, mm_sound_focus_type_e type, bool is_for_session, bool is_for_monitor, mm_sound_focus_changed_watch_cb callback, void *user_data);
-int mm_sound_proxy_unset_focus_watch_callback(int focus_tid, int handle, bool is_for_session);
+int mm_sound_proxy_set_focus_watch_callback(int instance, int handle, mm_sound_focus_type_e type, mm_sound_focus_changed_watch_cb callback, void *user_data);
+int mm_sound_proxy_unset_focus_watch_callback(int focus_tid, int handle);
#endif
int mm_sound_proxy_add_test_callback(mm_sound_test_cb func, void *userdata, mm_sound_proxy_userdata_free freefunc, unsigned *subs_id);
#include <vconf.h>
#include <mm_types.h>
#include <mm_error.h>
-#include <mm_session_private.h>
#include <mm_debug.h>
#include "include/mm_sound_private.h"
#include "include/mm_sound_utils.h"
#include <gio/gio.h>
-static pthread_mutex_t g_subscribe_cb_list_mutex = PTHREAD_MUTEX_INITIALIZER;
-
#define MM_SOUND_DBUS_BUS_NAME_PREPIX "org.tizen.MMSound"
#define MM_SOUND_DBUS_OBJECT_PATH "/org/tizen/MMSound"
#define MM_SOUND_DBUS_INTERFACE "org.tizen.mmsound"
-static GDBusConnection *g_dbus_conn_mmsound;
-static int g_dbus_signal_values[MM_SOUND_SIGNAL_MAX] = {0,};
-static const char* dbus_signal_name_str[] = {
- "ReleaseInternalFocus",
-};
-
-typedef struct _subscribe_cb {
- mm_sound_signal_name_t signal_type;
- mm_sound_signal_callback callback;
- void *user_data;
- unsigned int id;
- int client_pid;
-} subscribe_cb_t;
-
static const char* _get_volume_str(volume_type_t type)
{
static const char *volume_type_str[VOLUME_TYPE_MAX] = {
///////////////////////////////////
//// MMSOUND PLAY APIs
///////////////////////////////////
-static inline void _mm_sound_fill_play_param(MMSoundPlayParam *param, const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data)
-{
- param->filename = filename;
- param->volume = 0; //volume value dose not effect anymore
- param->callback = callback;
- param->data = data;
- param->loop = 1;
- param->volume_config = volume_config;
-}
-
-EXPORT_API
-int mm_sound_play_loud_solo_sound(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle)
-{
- MMSoundPlayParam param = { 0, };
-
- /* FIXME : this function will be deleted */
- _mm_sound_fill_play_param(¶m, filename, volume_config, callback, data);
- return mm_sound_play_sound_ex(¶m, handle);
-}
-
-EXPORT_API
-int mm_sound_play_sound(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle)
-{
- MMSoundPlayParam param = { 0, };
-
- _mm_sound_fill_play_param(¶m, filename, volume_config, callback, data);
- return mm_sound_play_sound_ex(¶m, handle);
-}
-
-EXPORT_API
-int mm_sound_play_sound_ex(MMSoundPlayParam *param, int *handle)
-{
- int err;
- int lhandle = -1;
- int volume_type = 0;
- /* Check input param */
- if (param == NULL) {
- debug_error("param is null");
- return MM_ERROR_INVALID_ARGUMENT;
- }
-
- volume_type = MM_SOUND_VOLUME_CONFIG_TYPE(param->volume_config);
-
- if (param->filename == NULL) {
- debug_error("filename is NULL");
- return MM_ERROR_SOUND_FILE_NOT_FOUND;
- }
- if (volume_type < 0 || volume_type >= VOLUME_TYPE_MAX) {
- debug_error("Volume type is invalid %d", volume_type);
- return MM_ERROR_INVALID_ARGUMENT;
- }
-
- /* Play sound */
- err = mm_sound_client_play_sound(param, 0, &lhandle);
- if (err < 0) {
- debug_error("Failed to play sound");
- return err;
- }
-
- /* Set handle to return */
- if (handle) {
- *handle = lhandle;
- } else {
- debug_critical("The sound hadle cannot be get [%d]", lhandle);
- }
-
- debug_warning("success : handle=[%p]", handle);
-
- return MM_ERROR_NONE;
-}
-
EXPORT_API
int mm_sound_play_sound_with_stream_info(const char *filename, char *stream_type, int stream_id, unsigned int loop, mm_sound_stop_callback_func callback, void *data, int *handle)
{
//// MMSOUND TONE APIs
///////////////////////////////////
EXPORT_API
-int mm_sound_play_tone_ex(MMSoundTone_t num, int volume_config, const double volume, const int duration, int *handle, bool enable_session)
-{
- int lhandle = -1;
- int err = MM_ERROR_NONE;
- int volume_type = MM_SOUND_VOLUME_CONFIG_TYPE(volume_config);
-
- debug_fenter();
-
- /* Check input param */
- if (duration < -1) {
- debug_error("number is invalid %d", duration);
- return MM_ERROR_INVALID_ARGUMENT;
- }
- if (num >= MM_SOUND_TONE_NUM) {
- debug_error("TONE Value is invalid %d", num);
- return MM_ERROR_INVALID_ARGUMENT;
- }
- if (volume_type < 0 || volume_type >= VOLUME_TYPE_MAX) {
- debug_error("Volume type is invalid %d", volume_type);
- return MM_ERROR_INVALID_ARGUMENT;
- }
- if (volume < 0.0 || volume > 1.0) {
- debug_error("Volume Value is invalid %f", volume);
- return MM_ERROR_INVALID_ARGUMENT;
- }
-
- /* Play tone */
- debug_msg("Call MMSoundClientPlayTone");
- err = mm_sound_client_play_tone(num, volume_config, volume, duration, &lhandle, enable_session);
- if (err < 0) {
- debug_error("Failed to play sound");
- return err;
- }
-
- /* Set handle to return */
- if (handle)
- *handle = lhandle;
- else
- debug_critical("The sound handle cannot be get [%d]", lhandle);
-
- debug_fleave();
- return MM_ERROR_NONE;
-}
-
-EXPORT_API
int mm_sound_play_tone_with_stream_info(MMSoundTone_t tone, char *stream_type, int stream_id, const double volume, const int duration, int *handle)
{
}
-
-EXPORT_API
-int mm_sound_play_tone(MMSoundTone_t num, int volume_config, const double volume, const int duration, int *handle)
-{
- return mm_sound_play_tone_ex(num, volume_config, volume, duration, handle, true);
-}
-
///////////////////////////////////
//// MMSOUND ROUTING APIs
///////////////////////////////////
return ret;
}
-static int _convert_signal_name_str_to_enum(const char *name_str, mm_sound_signal_name_t *name_enum)
-{
- int ret = MM_ERROR_NONE;
-
- if (!name_str || !name_enum)
- return MM_ERROR_INVALID_ARGUMENT;
-
- if (!strncmp(name_str, "ReleaseInternalFocus", strlen("ReleaseInternalFocus"))) {
- *name_enum = MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS;
- } else {
- ret = MM_ERROR_INVALID_ARGUMENT;
- LOGE("not supported signal name(%s), err(0x%08x)", name_str, ret);
- }
- return ret;
-}
-
-static void _dbus_signal_callback(const char *signal_name, int value, void *user_data)
-{
- int ret = MM_ERROR_NONE;
- mm_sound_signal_name_t signal;
- subscribe_cb_t *subscribe_cb = (subscribe_cb_t*)user_data;
-
- debug_fenter();
-
- if (!subscribe_cb)
- return;
-
- ret = _convert_signal_name_str_to_enum(signal_name, &signal);
- if (ret)
- return;
-
- debug_msg("signal: name[%s], value[0x%08x], user_data[%p], type[%d]",
- signal_name, value, user_data, subscribe_cb->signal_type);
-
- if (subscribe_cb->signal_type == MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS) {
- /* Trigger the signal callback when it comes from the same process.
- * In this case, the second integer argument is consist of
- * |<-- pid (16bits) -->|<-- value (16bits) -->|,
- * FYI, #define PID_MAX_DEFAULT (CONFIG_BASE_SMALL ? 0x1000 : 0x8000).
- * In case of daemon usage, it uses the client_pid of subscribe_cb. */
- debug_msg("client_pid[%d], getpid[%d], value>>16[%d], callback[%p]",
- subscribe_cb->client_pid, getpid(), (value >> 16), subscribe_cb);
- if ((subscribe_cb->client_pid ? subscribe_cb->client_pid : getpid()) == (value >> 16))
- subscribe_cb->callback(signal, (value & 0x0000FFFF), subscribe_cb->user_data);
- } else {
- debug_warning("not supported type[%d]", subscribe_cb->signal_type);
- }
-
- debug_fleave();
-
- return;
-}
-
-static void signal_callback(GDBusConnection *conn,
- const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal_name,
- GVariant *parameters,
- gpointer user_data)
-{
- int value = 0;
- const GVariantType* value_type;
-
- debug_msg("sender : %s, object : %s, interface : %s, signal : %s",
- sender_name, object_path, interface_name, signal_name);
- if (g_variant_is_of_type(parameters, G_VARIANT_TYPE("(i)"))) {
- g_variant_get(parameters, "(i)", &value);
- debug_msg(" - value : 0x08%x", value);
- _dbus_signal_callback(signal_name, value, user_data);
- } else {
- value_type = g_variant_get_type(parameters);
- debug_warning("signal type is %p", value_type);
- }
-}
-
-EXPORT_API
-int mm_sound_subscribe_signal(mm_sound_signal_name_t signal_type, unsigned int *subscribe_id,
- mm_sound_signal_callback callback, void *user_data)
-{
- int ret = MM_ERROR_NONE;
- GError *err = NULL;
- guint subs_id;
- subscribe_cb_t *subscribe_cb = NULL;
-
- debug_fenter();
-
- MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_subscribe_cb_list_mutex, MM_ERROR_SOUND_INTERNAL);
-
- if (signal_type >= MM_SOUND_SIGNAL_MAX || !subscribe_id) {
- debug_error("invalid argument, signal(%d), subscribe_id(%p)", signal_type, subscribe_id);
- ret = MM_ERROR_INVALID_ARGUMENT;
- goto error;
- }
-
- subscribe_cb = malloc(sizeof(subscribe_cb_t));
- if (!subscribe_cb) {
- ret = MM_ERROR_SOUND_INTERNAL;
- goto error;
- }
- memset(subscribe_cb, 0, sizeof(subscribe_cb_t));
- subscribe_cb->signal_type = signal_type;
- subscribe_cb->callback = callback;
- subscribe_cb->user_data = user_data;
-
- g_dbus_conn_mmsound = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
- if (!g_dbus_conn_mmsound || err) {
- debug_error("g_bus_get_sync() error (%s) ", err ? err->message : NULL);
- g_error_free(err);
- ret = MM_ERROR_SOUND_INTERNAL;
- goto error;
- }
- subs_id = g_dbus_connection_signal_subscribe(g_dbus_conn_mmsound, NULL, MM_SOUND_DBUS_INTERFACE,
- dbus_signal_name_str[signal_type], MM_SOUND_DBUS_OBJECT_PATH,
- NULL, G_DBUS_SIGNAL_FLAGS_NONE, signal_callback,
- subscribe_cb, free);
- if (subs_id == 0) {
- debug_error("g_dbus_connection_signal_subscribe() error (%d)", subs_id);
- ret = MM_ERROR_SOUND_INTERNAL;
- g_object_unref(g_dbus_conn_mmsound);
- goto error;
- }
- subscribe_cb->id = subs_id;
- *subscribe_id = subs_id;
-
- MMSOUND_LEAVE_CRITICAL_SECTION(&g_subscribe_cb_list_mutex);
-
- debug_fleave();
-
- return ret;
-
-error:
- if (subscribe_cb)
- free(subscribe_cb);
-
- MMSOUND_LEAVE_CRITICAL_SECTION(&g_subscribe_cb_list_mutex);
-
- return ret;
-}
-
-/* ToDo : Almost same as mm_sound_subscribe_signal, need to be merged */
-EXPORT_API
-int mm_sound_subscribe_signal_for_daemon(mm_sound_signal_name_t signal_type, int client_pid, unsigned int *subscribe_id,
- mm_sound_signal_callback callback, void *user_data)
-{
- int ret = MM_ERROR_NONE;
- GError *err = NULL;
- guint subs_id;
- subscribe_cb_t *subscribe_cb = NULL;
-
- debug_fenter();
-
- MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_subscribe_cb_list_mutex, MM_ERROR_SOUND_INTERNAL);
-
- if (signal_type >= MM_SOUND_SIGNAL_MAX || !client_pid || !subscribe_id) {
- debug_error("invalid argument, signal(%d), client_pid(%d), subscribe_id(%p)", signal_type, client_pid, subscribe_id);
- ret = MM_ERROR_INVALID_ARGUMENT;
- goto error;
- }
-
- subscribe_cb = malloc(sizeof(subscribe_cb_t));
- if (!subscribe_cb) {
- ret = MM_ERROR_SOUND_INTERNAL;
- goto error;
- }
- memset(subscribe_cb, 0, sizeof(subscribe_cb_t));
- subscribe_cb->signal_type = signal_type;
- subscribe_cb->callback = callback;
- subscribe_cb->user_data = user_data;
- subscribe_cb->client_pid = client_pid;
-
- g_dbus_conn_mmsound = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
- if (!g_dbus_conn_mmsound || err) {
- debug_error("g_bus_get_sync() error (%s) ", err ? err->message : NULL);
- g_error_free(err);
- ret = MM_ERROR_SOUND_INTERNAL;
- goto error;
- }
- subs_id = g_dbus_connection_signal_subscribe(g_dbus_conn_mmsound, NULL, MM_SOUND_DBUS_INTERFACE,
- dbus_signal_name_str[signal_type], MM_SOUND_DBUS_OBJECT_PATH,
- NULL, G_DBUS_SIGNAL_FLAGS_NONE, signal_callback,
- subscribe_cb, free);
- if (subs_id == 0) {
- debug_error("g_dbus_connection_signal_subscribe() error (%d)", subs_id);
- ret = MM_ERROR_SOUND_INTERNAL;
- g_object_unref(g_dbus_conn_mmsound);
- goto error;
- }
- subscribe_cb->id = subs_id;
- *subscribe_id = subs_id;
-
- MMSOUND_LEAVE_CRITICAL_SECTION(&g_subscribe_cb_list_mutex);
-
- debug_fleave();
-
- return ret;
-
-error:
- if (subscribe_cb)
- free(subscribe_cb);
-
- MMSOUND_LEAVE_CRITICAL_SECTION(&g_subscribe_cb_list_mutex);
-
- return ret;
-}
-
-EXPORT_API
-void mm_sound_unsubscribe_signal(unsigned int subscribe_id)
-{
- debug_fenter();
-
- MMSOUND_ENTER_CRITICAL_SECTION(&g_subscribe_cb_list_mutex);
-
- if (g_dbus_conn_mmsound && subscribe_id) {
- g_dbus_connection_signal_unsubscribe(g_dbus_conn_mmsound, subscribe_id);
- g_object_unref(g_dbus_conn_mmsound);
- }
-
- MMSOUND_LEAVE_CRITICAL_SECTION(&g_subscribe_cb_list_mutex);
-
- debug_fleave();
-}
-
-EXPORT_API
-int mm_sound_send_signal(mm_sound_signal_name_t signal_type, int value)
-{
- int ret = MM_ERROR_NONE;
- GError *err = NULL;
- GDBusConnection *conn = NULL;
- gboolean dbus_ret = TRUE;
-
- debug_fenter();
-
- MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_subscribe_cb_list_mutex, MM_ERROR_SOUND_INTERNAL);
-
- if (signal_type >= MM_SOUND_SIGNAL_MAX) {
- debug_error("invalid argument, signal(%d)", signal_type);
- ret = MM_ERROR_INVALID_ARGUMENT;
- goto error;
- }
-
- conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
- if (!conn || err) {
- debug_error("g_bus_get_sync() error (%s)", err ? err->message : NULL);
- ret = MM_ERROR_SOUND_INTERNAL;
- goto error;
- }
-
- g_dbus_signal_values[signal_type] = value;
- if (signal_type == MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS) {
- /* Trigger the signal callback when it comes from the same process.
- * |<-- pid (16bits) -->|<-- value (16bits) -->|,
- * FYI, #define PID_MAX_DEFAULT (CONFIG_BASE_SMALL ? 0x1000 : 0x8000). */
- value |= ((int)getpid() << 16);
- if ((_mm_session_util_write_information((int)getpid(), MM_SESSION_TYPE_REPLACED_BY_STREAM, 0)))
- debug_error("failed to _mm_session_util_write_information for MM_SESSION_TYPE_REPLACED_BY_STREAM");
- }
- dbus_ret = g_dbus_connection_emit_signal(conn,
- NULL, MM_SOUND_DBUS_OBJECT_PATH, MM_SOUND_DBUS_INTERFACE, dbus_signal_name_str[signal_type],
- g_variant_new("(i)", value),
- &err);
- if (!dbus_ret || err) {
- debug_error("g_dbus_connection_emit_signal() error (%s)", err ? err->message : NULL);
- ret = MM_ERROR_SOUND_INTERNAL;
- goto error;
- }
-
- dbus_ret = g_dbus_connection_flush_sync(conn, NULL, &err);
- if (!dbus_ret || err) {
- debug_error("g_dbus_connection_flush_sync() error (%s)", err ? err->message : NULL);
- ret = MM_ERROR_SOUND_INTERNAL;
- goto error;
- }
-
- g_object_unref(conn);
- debug_msg("sending signal[%s], value[%d] success", dbus_signal_name_str[signal_type], value);
-
- MMSOUND_LEAVE_CRITICAL_SECTION(&g_subscribe_cb_list_mutex);
-
- debug_fleave();
-
- return ret;
-
-error:
- if (err)
- g_error_free(err);
- if (conn)
- g_object_unref(conn);
-
- MMSOUND_LEAVE_CRITICAL_SECTION(&g_subscribe_cb_list_mutex);
-
- return ret;
-}
-
-EXPORT_API
-int mm_sound_get_signal_value(mm_sound_signal_name_t signal_type, int *value)
-{
- int ret = MM_ERROR_NONE;
-
- debug_fenter();
-
- MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_subscribe_cb_list_mutex, MM_ERROR_SOUND_INTERNAL);
-
- *value = g_dbus_signal_values[signal_type];
-
- MMSOUND_LEAVE_CRITICAL_SECTION(&g_subscribe_cb_list_mutex);
-
- debug_fleave();
-
- return ret;
-}
-
#ifdef TIZEN_TV
EXPORT_API
void mm_sound_dotnet_cleanup(int signo)
#include "include/mm_sound_device.h"
#include "include/mm_sound_stream.h"
-#include <mm_session.h>
-#include <mm_session_private.h>
-
#include <glib.h>
#if defined(__GSOURCE_CALLBACK__)
#include <sys/poll.h>
mm_sound_focus_changed_watch_cb watch_callback;
void* user_data;
bool unset_watch_callback_requested;
-
- /* will be removed when the session concept is completely left out*/
- bool is_for_session;
- bool is_for_monitor;
} focus_sound_info_t;
typedef struct {
int option;
} focus_cb_data_lib;
-typedef struct {
- int watch_cb_id;
- mm_sound_focus_session_interrupt_cb user_cb;
- void* user_data;
-} focus_session_interrupt_info_t;
-
typedef gboolean(*focus_callback_handler_t)(gpointer user_data);
focus_sound_info_t g_focus_sound_handle[FOCUS_HANDLE_MAX];
-focus_session_interrupt_info_t g_focus_session_interrupt_info = {-1, NULL, NULL};
static pthread_mutex_t g_index_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t g_event_mutex = PTHREAD_MUTEX_INITIALIZER;
-guint g_focus_signal_handle;
guint g_idle_event_src;
#endif
/*****************************************************************************************
DBUS SUPPORTED FUNCTIONS
******************************************************************************************/
-#ifdef USE_FOCUS
-void _mm_sound_client_focus_signal_callback(mm_sound_signal_name_t signal, int value, void *user_data)
-{
- int ret = MM_ERROR_NONE;
-
- debug_fenter();
- debug_msg("focus signal received, value = %d", value);
-
- if (value == 1) {
- ret = mm_sound_proxy_clear_focus(getpid());
- if (ret)
- debug_error("clear focus failed ret = 0x%x", ret);
- mm_sound_unsubscribe_signal(g_focus_signal_handle);
- g_focus_signal_handle = 0;
- }
-}
-#endif
-
-int mm_sound_client_play_tone(int number, int volume_config, double volume,
- int time, int *handle, bool enable_session)
-{
- int ret = MM_ERROR_NONE;
-// int instance = -1; /* instance is unique to communicate with server : client message queue filter type */
- int volume_type = MM_SOUND_VOLUME_CONFIG_TYPE(volume_config);
- char stream_type[MAX_STREAM_TYPE_LEN] = {0, };
-
- debug_fenter();
-
- /* read session information */
- int session_type = MM_SESSION_TYPE_MEDIA;
- int session_options = 0;
- int is_focus_registered = 0;
-
- ret = mm_sound_get_signal_value(MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, &is_focus_registered);
- if (ret) {
- debug_error("mm_sound_get_signal_value failed [0x%x]", ret);
- return MM_ERROR_POLICY_INTERNAL;
- }
-
- if (is_focus_registered)
- enable_session = false;
-
- if (enable_session) {
- if (MM_ERROR_NONE != _mm_session_util_read_information(-1, &session_type, &session_options)) {
- debug_warning("Read Session Information failed. use default \"media\" type");
- session_type = MM_SESSION_TYPE_MEDIA;
-
- if (MM_ERROR_NONE != mm_session_init(session_type)) {
- debug_critical("MMSessionInit() failed");
- return MM_ERROR_POLICY_INTERNAL;
- }
- }
- }
-
- // instance = getpid();
- //debug_log("pid for client ::: [%d]", instance);
-
- /* Send msg */
- debug_msg("Input number : %d", number);
- /* Send req memory */
-
- mm_sound_convert_volume_type_to_stream_type(volume_type, stream_type);
- ret = mm_sound_proxy_play_tone(number, time, volume, volume_config,
- session_type, session_options, getpid(), enable_session, handle, stream_type, -1);
-#ifdef USE_FOCUS
- if (enable_session && !g_focus_signal_handle) {
- ret = mm_sound_subscribe_signal(MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, &g_focus_signal_handle,
- _mm_sound_client_focus_signal_callback, NULL);
- if (ret) {
- debug_error("mm_sound_subscribe_signal failed [0x%x]", ret);
- return MM_ERROR_POLICY_INTERNAL;
- }
- }
-#endif
-
- debug_fleave();
- return ret;
-}
-
int mm_sound_client_play_tone_with_stream_info(int tone, char *stream_type, int stream_id,
double volume, int duration, int *handle)
{
}
}
-int mm_sound_client_play_sound(MMSoundPlayParam *param, int tone, int *handle)
-{
- int ret = MM_ERROR_NONE;
- int session_type = MM_SESSION_TYPE_MEDIA;
- int session_options = 0;
- int is_focus_registered = 0;
-// int instance = -1; /* instance is unique to communicate with server : client message queue filter type */
- int volume_type = MM_SOUND_VOLUME_CONFIG_TYPE(param->volume_config);
- char stream_type[MAX_STREAM_TYPE_LEN] = {0, };
- struct callback_data *cb_data = NULL;
- play_sound_end_callback_data_t *end_cb_data;
-
- debug_fenter();
-
- /* read session information */
-
- ret = mm_sound_get_signal_value(MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, &is_focus_registered);
- if (ret) {
- debug_error("mm_sound_get_signal_value failed [0x%x]", ret);
- return MM_ERROR_POLICY_INTERNAL;
- }
-
- if (is_focus_registered)
- param->skip_session = true;
-
- if (param->skip_session == false) {
- if (MM_ERROR_NONE != _mm_session_util_read_information(-1, &session_type, &session_options)) {
- debug_warning("Read MMSession Type failed. use default \"media\" type");
- session_type = MM_SESSION_TYPE_MEDIA;
-
- if (MM_ERROR_NONE != mm_session_init(session_type)) {
- debug_critical("MMSessionInit() failed");
- return MM_ERROR_POLICY_INTERNAL;
- }
- }
- }
-
- /* Send msg */
- if ((param->mem_ptr && param->mem_size)) {
- // Play memory, deprecated
- return MM_ERROR_INVALID_ARGUMENT;
- }
-
- mm_sound_convert_volume_type_to_stream_type(volume_type, stream_type);
- ret = mm_sound_proxy_play_sound(param->filename, tone, param->loop, param->volume, param->volume_config,
- session_type, session_options, getpid(), param->skip_session, handle, stream_type, -1);
- if (ret != MM_ERROR_NONE) {
- debug_error("Play Sound Failed");
- goto failed;
- }
- if (param->callback) {
- end_cb_data = (play_sound_end_callback_data_t *) g_malloc0(sizeof(play_sound_end_callback_data_t));
- end_cb_data->watching_handle = *handle;
- GET_CB_DATA(cb_data, param->callback, param->data, end_cb_data);
-
- ret = mm_sound_proxy_add_play_sound_end_callback(_mm_sound_stop_callback_wrapper_func, cb_data,
- play_end_callback_data_free_func, &end_cb_data->subs_id);
- if (ret != MM_ERROR_NONE)
- debug_error("Add callback for play sound(%d) Failed", *handle);
- }
-#ifdef USE_FOCUS
- if (!param->skip_session && !g_focus_signal_handle) {
- ret = mm_sound_subscribe_signal(MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, &g_focus_signal_handle,
- _mm_sound_client_focus_signal_callback, NULL);
- if (ret) {
- debug_error("mm_sound_subscribe_signal failed [0x%x]", ret);
- return MM_ERROR_POLICY_INTERNAL;
- }
- }
-#endif
-
-failed:
-
- debug_fleave();
- return ret;
-}
-
int mm_sound_client_play_sound_with_stream_info(MMSoundPlayParam *param, int *handle, char* stream_type, int stream_id)
{
int ret = MM_ERROR_NONE;
}
#ifdef USE_FOCUS
-static gboolean _interrupted_completed(gpointer *data)
-{
- if (!data) {
- debug_error("data is null");
- return false;
- }
- if (!g_focus_session_interrupt_info.user_cb) {
- debug_error("user_cb is null");
- free(data);
- return false;
- }
-
- debug_msg("invoke user_cb(%p)", g_focus_session_interrupt_info.user_cb);
- (g_focus_session_interrupt_info.user_cb)(FOCUS_IS_RELEASED, (const char *)data, g_focus_session_interrupt_info.user_data);
- debug_msg("invoked");
-
- free(data);
- return false;
-}
-
-static void _session_interrupted_cb(int id, mm_sound_focus_type_e focus_type, mm_sound_focus_state_e state,
- const char *reason_for_change, const char *ext_info, void *user_data)
-{
- debug_msg("id(%d), focus_type(%d), state(%d), reason(%s)", id, focus_type, state, reason_for_change);
-
- if (id != g_focus_session_interrupt_info.watch_cb_id) {
- debug_error("id is not valid(param id:%d, g_focus_session_interrupt_watch_cb_id:%d)",
- id, g_focus_session_interrupt_info.watch_cb_id);
- return;
- }
- if (!g_focus_session_interrupt_info.user_cb) {
- debug_error("user callback is null");
- return;
- }
-
- debug_msg(" >>> invoking session interrupt callback(%p)", g_focus_session_interrupt_info.user_cb);
- if (state == FOCUS_IS_RELEASED)
- (g_focus_session_interrupt_info.user_cb)(FOCUS_IS_ACQUIRED, reason_for_change, g_focus_session_interrupt_info.user_data);
- else {
- debug_msg("INTERRUPTED COMPLETED case, append it to idle");
- g_idle_add((GSourceFunc)_interrupted_completed, strdup(reason_for_change));
- }
- debug_msg(" <<< session interrupt callback finished");
-}
-
-int mm_sound_client_set_session_interrupt_callback(mm_sound_focus_session_interrupt_cb callback, void* user_data)
-{
- int ret = MM_ERROR_NONE;
-
- debug_fenter();
-
- if (!callback)
- return MM_ERROR_INVALID_ARGUMENT;
-
- /* add internal focus watch callback */
- if (g_focus_session_interrupt_info.watch_cb_id == -1) {
- if ((ret = mm_sound_client_set_focus_watch_callback(getpid(), FOCUS_FOR_BOTH, true, true, _session_interrupted_cb, NULL,
- &g_focus_session_interrupt_info.watch_cb_id))) {
- debug_error("failed to mm_sound_client_set_focus_watch_callback(), ret(0x%x)", ret);
- return ret;
- }
- }
- g_focus_session_interrupt_info.user_cb = callback;
- g_focus_session_interrupt_info.user_data = user_data;
-
- debug_fleave();
- return ret;
-}
-
-int mm_sound_client_unset_session_interrupt_callback(void)
-{
- int ret = MM_ERROR_NONE;
-
- debug_fenter();
-
- if (!g_focus_session_interrupt_info.user_cb || g_focus_session_interrupt_info.watch_cb_id == -1) {
- debug_error("no callback to unset");
- return MM_ERROR_SOUND_INTERNAL;
- }
-
- /* remove internal focus watch callback */
- if ((ret = mm_sound_client_unset_focus_watch_callback(g_focus_session_interrupt_info.watch_cb_id))) {
- debug_error("failed to mm_sound_client_unset_focus_watch_callback(), id(%d), ret(0x%x)",
- g_focus_session_interrupt_info.watch_cb_id, ret);
- return ret;
- }
- g_focus_session_interrupt_info.watch_cb_id = -1;
- g_focus_session_interrupt_info.user_cb = NULL;
- g_focus_session_interrupt_info.user_data = NULL;
-
- debug_fleave();
- return ret;
-}
-
static gpointer _focus_thread_func(gpointer data)
{
unsigned int thread_id = (unsigned int)pthread_self();
if (!is_for_watching) {
if (!_focus_add_sound_callback(index, _focus_callback_handler))
debug_error("failed to _focus_add_sound_callback(%p)", _focus_callback_handler);
- } else { // need to check if it's necessary
+ } else {
if (!_focus_add_sound_callback(index, _focus_watch_callback_handler))
debug_error("failed to _focus_add_sound_callback(%p)", _focus_watch_callback_handler);
}
return ret;
}
-int mm_sound_client_register_focus(int id, int pid, const char *stream_type, bool is_for_session,
+int mm_sound_client_register_focus(int id, int pid, const char *stream_type,
mm_sound_focus_changed_cb callback, void* user_data)
{
int ret = MM_ERROR_NONE;
g_focus_sound_handle[index].handle = id;
g_focus_sound_handle[index].focus_callback = callback;
g_focus_sound_handle[index].user_data = user_data;
- g_focus_sound_handle[index].is_for_session = is_for_session;
g_focus_sound_handle[index].auto_reacquire = true;
- ret = mm_sound_proxy_register_focus(id, pid, stream_type, callback, is_for_session, user_data);
+ ret = mm_sound_proxy_register_focus(id, pid, stream_type, callback, user_data);
if (ret == MM_ERROR_NONE) {
debug_msg("Success to register focus");
g_need_emergent_exit = TRUE;
if (!g_mutex_trylock(&g_focus_sound_handle[index].focus_lock)) {
debug_warning("maybe focus_callback is being called, try one more time..");
- usleep(2500000); // 2.5 sec
+ usleep(2500000); /* 2.5 sec */
if (g_mutex_trylock(&g_focus_sound_handle[index].focus_lock))
debug_msg("finally got focus_lock");
}
- ret = mm_sound_proxy_unregister_focus(instance, id, g_focus_sound_handle[index].is_for_session);
+ ret = mm_sound_proxy_unregister_focus(instance, id);
if (ret == MM_ERROR_NONE)
debug_msg("Success to unregister focus");
else
return ret;
}
-int mm_sound_client_set_focus_reacquisition(int id, bool reacquisition, bool is_for_session)
+int mm_sound_client_set_focus_reacquisition(int id, bool reacquisition)
{
int ret = MM_ERROR_NONE;
int instance;
debug_fenter();
- /* Since the muse server which uses this library for multiple handles executes requests from clients serially,
- * we can skip locking/unlocking the mutex for this case. */
- if (!is_for_session)
- MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_index_mutex, MM_ERROR_SOUND_INTERNAL);
+ MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_index_mutex, MM_ERROR_SOUND_INTERNAL);
index = _focus_find_index_by_handle(id);
if (index == -1) {
debug_error("mm_sound_client_is_focus_cb_thread failed");
goto cleanup;
} else if (!result) {
- ret = mm_sound_proxy_set_focus_reacquisition(instance, id, reacquisition, is_for_session);
+ ret = mm_sound_proxy_set_focus_reacquisition(instance, id, reacquisition);
if (ret == MM_ERROR_NONE) {
debug_msg("Success to set focus reacquisition to [%d]", reacquisition);
} else {
debug_msg("set focus reacquisition(%d) for id(%d)", reacquisition, id);
cleanup:
- if (!is_for_session)
- MMSOUND_LEAVE_CRITICAL_SECTION(&g_index_mutex);
+ MMSOUND_LEAVE_CRITICAL_SECTION(&g_index_mutex);
debug_fleave();
return ret;
}
}
instance = g_focus_sound_handle[index].focus_tid;
- ret = mm_sound_proxy_acquire_focus(instance, id, type, option, ext_info, g_focus_sound_handle[index].is_for_session);
+ ret = mm_sound_proxy_acquire_focus(instance, id, type, option, ext_info);
if (ret == MM_ERROR_NONE)
debug_msg("Success to acquire focus");
else
}
instance = g_focus_sound_handle[index].focus_tid;
- ret = mm_sound_proxy_release_focus(instance, id, type, option, ext_info, g_focus_sound_handle[index].is_for_session);
+ ret = mm_sound_proxy_release_focus(instance, id, type, option, ext_info);
if (ret == MM_ERROR_NONE)
debug_msg("Success to release focus");
else
return ret;
}
-int mm_sound_client_set_focus_watch_callback(int pid, mm_sound_focus_type_e focus_type, bool is_for_session, bool is_for_monitor,
+int mm_sound_client_set_focus_watch_callback(int pid, mm_sound_focus_type_e focus_type,
mm_sound_focus_changed_watch_cb callback, void* user_data, int *id)
{
int ret = MM_ERROR_NONE;
if (!id)
return MM_ERROR_INVALID_ARGUMENT;
- //pthread_mutex_lock(&g_thread_mutex2);
-
instance = pid;
ret = mm_sound_proxy_get_unique_id(id);
g_focus_sound_handle[index].handle = *id;
g_focus_sound_handle[index].watch_callback = callback;
g_focus_sound_handle[index].user_data = user_data;
- g_focus_sound_handle[index].is_for_session = is_for_session;
- g_focus_sound_handle[index].is_for_monitor = is_for_monitor;
g_focus_sound_handle[index].unset_watch_callback_requested = false;
ret = mm_sound_proxy_set_focus_watch_callback(pid, g_focus_sound_handle[index].handle, focus_type,
- is_for_session, is_for_monitor, callback, user_data);
+ callback, user_data);
if (ret == MM_ERROR_NONE) {
debug_msg("Success to watch focus");
g_focus_sound_handle[index].is_used = false;
ret = mm_sound_proxy_unset_focus_watch_callback(g_focus_sound_handle[index].focus_tid,
- g_focus_sound_handle[index].handle,
- g_focus_sound_handle[index].is_for_session);
+ g_focus_sound_handle[index].handle);
if (ret == MM_ERROR_NONE)
debug_msg("Success to unwatch focus");
} \
EXPORT_API
-int mm_sound_focus_set_session_interrupt_callback(mm_sound_focus_session_interrupt_cb callback, void *user_data)
-{
- int ret = MM_ERROR_NONE;
- debug_fenter();
-
- RETURN_ERROR_IF_FOCUS_CB_THREAD(g_thread_self());
-
- if (!callback)
- return MM_ERROR_INVALID_ARGUMENT;
-
- ret = mm_sound_client_set_session_interrupt_callback(callback, user_data);
-
- debug_fleave();
-
- return ret;
-}
-
-EXPORT_API
-int mm_sound_focus_unset_session_interrupt_callback(void)
-{
- int ret = MM_ERROR_NONE;
- debug_fenter();
-
- RETURN_ERROR_IF_FOCUS_CB_THREAD(g_thread_self());
-
- ret = mm_sound_client_unset_session_interrupt_callback();
- if (ret)
- debug_error("Failed to mm_sound_client_unset_session_interrupt_callback(), ret[0x%x]", ret);
-
- debug_fleave();
-
- return ret;
-}
-
-EXPORT_API
int mm_sound_focus_get_id(int *id)
{
int ret = MM_ERROR_NONE;
return MM_ERROR_INVALID_ARGUMENT;
}
- ret = mm_sound_client_register_focus(id, getpid(), stream_type, false, callback, user_data);
+ ret = mm_sound_client_register_focus(id, getpid(), stream_type, callback, user_data);
if (ret)
debug_error("Could not register focus, ret[0x%x]", ret);
}
EXPORT_API
-int mm_sound_register_focus_for_session(int id, int pid, const char *stream_type, mm_sound_focus_changed_cb callback, void *user_data)
-{
- int ret = MM_ERROR_NONE;
-
- debug_fenter();
-
- RETURN_ERROR_IF_FOCUS_CB_THREAD(g_thread_self());
-
- if (id < 0 || callback == NULL) {
- debug_error("argument is not valid");
- return MM_ERROR_INVALID_ARGUMENT;
- }
-
- ret = mm_sound_client_register_focus(id, pid, stream_type, true, callback, user_data);
- if (ret)
- debug_error("Could not register focus for session, ret[0x%x]", ret);
-
- debug_fleave();
-
- return ret;
-}
-
-EXPORT_API
int mm_sound_unregister_focus(int id)
{
int ret = MM_ERROR_NONE;
return MM_ERROR_INVALID_ARGUMENT;
}
- if ((ret = mm_sound_client_set_focus_reacquisition(id, reacquisition, false)))
- debug_error("Could not set focus reacquisition, ret[0x%x]", ret);
-
- debug_fleave();
-
- return ret;
-}
-
-EXPORT_API
-int mm_sound_set_focus_reacquisition_for_session(int id, bool reacquisition)
-{
- int ret = MM_ERROR_NONE;
-
- debug_fenter();
-
- if (id < 0) {
- debug_error("argument is not valid");
- return MM_ERROR_INVALID_ARGUMENT;
- }
-
- if ((ret = mm_sound_client_set_focus_reacquisition(id, reacquisition, true)))
+ if ((ret = mm_sound_client_set_focus_reacquisition(id, reacquisition)))
debug_error("Could not set focus reacquisition, ret[0x%x]", ret);
debug_fleave();
debug_error("argument is not valid");
return MM_ERROR_INVALID_ARGUMENT;
}
- ret = mm_sound_client_set_focus_watch_callback(getpid(), focus_type, false, false, callback, user_data, id);
- if (ret)
- debug_error("Could not set focus watch callback, ret[0x%x]", ret);
-
- debug_fleave();
-
- return ret;
-}
-
-EXPORT_API
-int mm_sound_set_focus_watch_callback_for_session(int pid, mm_sound_focus_type_e focus_type, mm_sound_focus_changed_watch_cb callback, void *user_data, int *id)
-{
- int ret = MM_ERROR_NONE;
-
- debug_fenter();
-
- RETURN_ERROR_IF_FOCUS_CB_THREAD(g_thread_self());
-
- if (callback == NULL || id == NULL) {
- debug_error("argument is not valid");
- return MM_ERROR_INVALID_ARGUMENT;
- }
- ret = mm_sound_client_set_focus_watch_callback(pid, focus_type, true, false, callback, user_data, id);
- if (ret)
- debug_error("Could not set focus watch callback, ret[0x%x]", ret);
-
- debug_fleave();
-
- return ret;
-}
-
-EXPORT_API
-int mm_sound_set_focus_watch_callback_for_session_monitor(int pid, mm_sound_focus_type_e focus_type, mm_sound_focus_changed_watch_cb callback, void *user_data, int *id)
-{
- int ret = MM_ERROR_NONE;
-
- debug_fenter();
-
- RETURN_ERROR_IF_FOCUS_CB_THREAD(g_thread_self());
-
- if (callback == NULL || id == NULL) {
- debug_error("argument is not valid");
- return MM_ERROR_INVALID_ARGUMENT;
- }
- ret = mm_sound_client_set_focus_watch_callback(pid, focus_type, true, true, callback, user_data, id);
+ ret = mm_sound_client_set_focus_watch_callback(getpid(), focus_type, callback, user_data, id);
if (ret)
debug_error("Could not set focus watch callback, ret[0x%x]", ret);
#include "include/mm_sound_common.h"
#include "include/mm_sound_focus_socket.h"
-#define FILL_SOCKET_PARAM(x_param, x_func_name, x_instance, x_id, x_focus_type, x_option, x_ext_info, x_is_in_thread, x_is_for_session) \
+#define FILL_SOCKET_PARAM(x_param, x_func_name, x_instance, x_id, x_focus_type, x_option, x_ext_info, x_is_in_thread) \
do { \
MMSOUND_STRNCPY(x_param.func_name, x_func_name, MM_SOUND_NAME_NUM); \
x_param.pid = x_instance; \
x_param.option = x_option; \
MMSOUND_STRNCPY(x_param.ext_info, x_ext_info, MM_SOUND_NAME_NUM); \
x_param.is_in_thread = x_is_in_thread; \
- x_param.is_for_session = x_is_for_session; \
} while (0) \
static int _convert_error_from_string(const char *error_string)
}
EXPORT_API
-int mm_sound_focus_socket_acquire(int instance, int id, mm_sound_focus_type_e focus_type, int option, const char *ext_info, bool is_in_thread, bool is_for_session)
+int mm_sound_focus_socket_acquire(int instance, int id, mm_sound_focus_type_e focus_type, int option, const char *ext_info, bool is_in_thread)
{
int ret = MM_ERROR_NONE;
int fd = -1;
memset(&data, 0x00, sizeof(_mm_sound_mgr_focus_socket_param_t));
FILL_SOCKET_PARAM(data, FOCUS_FUNC_NAME_ACQUIRE, instance, id, focus_type,
- option, ext_info, is_in_thread, is_for_session);
+ option, ext_info, is_in_thread);
if ((ret = _send_data_to_server(fd, &data))) {
debug_error("failed to _send_data_to_server(), ret[0x%x]", ret);
}
EXPORT_API
-int mm_sound_focus_socket_release(int instance, int id, mm_sound_focus_type_e focus_type, int option, const char *ext_info, bool is_in_thread, bool is_for_session)
+int mm_sound_focus_socket_release(int instance, int id, mm_sound_focus_type_e focus_type, int option, const char *ext_info, bool is_in_thread)
{
int ret = MM_ERROR_NONE;
int fd = -1;
memset(&data, 0x00, sizeof(_mm_sound_mgr_focus_socket_param_t));
FILL_SOCKET_PARAM(data, FOCUS_FUNC_NAME_RELEASE, instance, id, focus_type,
- option, ext_info, is_in_thread, is_for_session);
+ option, ext_info, is_in_thread);
if ((ret = _send_data_to_server(fd, &data))) {
debug_error("failed to _send_data_to_server()");
return ret;
}
-int mm_sound_proxy_play_tone(int tone, int repeat, int volume, int volume_config,
- int session_type, int session_options, int client_pid,
- bool enable_session, int *codechandle, char *stream_type, int stream_index)
-{
- int ret = MM_ERROR_NONE;
- int handle = 0;
- GVariant *params = NULL, *result = NULL;
- gboolean _enable_session = enable_session;
-
- if (!codechandle) {
- debug_error("Param for play is null");
- return MM_ERROR_INVALID_ARGUMENT;
- }
-
- debug_fenter();
-
- params = g_variant_new("(iiiiiiibsi)", tone, repeat, volume, volume_config, session_type,
- session_options, client_pid, _enable_session, stream_type, stream_index);
- if (params) {
- if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_SOUND_SERVER, AUDIO_METHOD_PLAY_DTMF, params, &result)) != MM_ERROR_NONE) {
- debug_error("dbus play tone failed");
- goto cleanup;
- }
- } else {
- debug_error("Construct Param for method call failed");
- }
-
- if (result) {
- g_variant_get(result, "(i)", &handle);
- debug_log("handle : %d", handle);
- *codechandle = handle;
- } else {
- debug_error("reply null");
- }
-
-cleanup:
- if (result)
- g_variant_unref(result);
-
- debug_fleave();
- return ret;
-}
-
int mm_sound_proxy_play_tone_with_stream_info(int client_pid, int tone, char *stream_type, int stream_index, int volume, int repeat, int *codechandle)
{
int ret = MM_ERROR_NONE;
return ret;
}
-int mm_sound_proxy_play_sound(const char* filename, int tone, int repeat, int volume, int volume_config,
- int session_type, int session_options, int client_pid, bool enable_session, int *codechandle,
- char *stream_type, int stream_index)
-{
- int ret = MM_ERROR_NONE;
- int handle = 0;
- GVariant *params = NULL, *result = NULL;
- gboolean _enable_session = enable_session;
-
- if (!filename || !codechandle) {
- debug_error("Param for play is null");
- return MM_ERROR_INVALID_ARGUMENT;
- }
-
- debug_fenter();
-
- params = g_variant_new("(siiiiiiibsi)", filename, tone, repeat, volume,
- volume_config, session_type, session_options, client_pid, _enable_session, stream_type, stream_index);
- if (params) {
- if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_SOUND_SERVER, AUDIO_METHOD_PLAY_FILE_START, params, &result)) != MM_ERROR_NONE) {
- debug_error("dbus play file failed");
- goto cleanup;
- }
- } else {
- debug_error("Construct Param for method call failed");
- }
-
- if (result) {
- g_variant_get(result, "(i)", &handle);
- debug_log("handle : %d", handle);
- *codechandle = handle;
- } else {
- debug_error("reply null");
- }
-
-cleanup:
- if (result)
- g_variant_unref(result);
-
- debug_fleave();
- return ret;
-}
-
int mm_sound_proxy_play_sound_with_stream_info(const char* filename, int repeat, int volume,
int client_pid, int *codechandle, char *stream_type, int stream_index)
{
return ret;
}
-int mm_sound_proxy_clear_focus(int pid)
-{
- int ret = MM_ERROR_NONE;
- GVariant *result = NULL;
-
- debug_fenter();
-
- if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_SOUND_SERVER, AUDIO_METHOD_CLEAR_FOCUS, g_variant_new("(i)", pid), &result)) != MM_ERROR_NONE)
- debug_error("dbus clear focus failed");
-
- if (result)
- g_variant_unref(result);
-
- debug_fleave();
- return ret;
-}
-
int mm_sound_proxy_add_play_sound_end_callback(mm_sound_stop_callback_wrapper_func func, void* userdata, mm_sound_proxy_userdata_free freefunc, unsigned *subs_id)
{
int ret = MM_ERROR_NONE;
return ret;
}
-int mm_sound_proxy_register_focus(int id, int instance, const char *stream_type, mm_sound_focus_changed_cb callback, bool is_for_session, void* userdata)
+int mm_sound_proxy_register_focus(int id, int instance, const char *stream_type, mm_sound_focus_changed_cb callback, void* userdata)
{
int ret = MM_ERROR_NONE;
GVariant *params = NULL, *result = NULL;
debug_fenter();
- params = g_variant_new("(iisb)", instance, id, stream_type, is_for_session);
+ params = g_variant_new("(iis)", instance, id, stream_type);
if (params) {
if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_FOCUS_SERVER, AUDIO_METHOD_REGISTER_FOCUS, params, &result)) != MM_ERROR_NONE)
debug_error("dbus register focus failed");
}
-int mm_sound_proxy_unregister_focus(int instance, int id, bool is_for_session)
+int mm_sound_proxy_unregister_focus(int instance, int id)
{
int ret = MM_ERROR_NONE;
GVariant *params = NULL, *result = NULL;
debug_fenter();
- params = g_variant_new("(iib)", instance, id, is_for_session);
+ params = g_variant_new("(ii)", instance, id);
if (params) {
if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_FOCUS_SERVER, AUDIO_METHOD_UNREGISTER_FOCUS, params, &result)) != MM_ERROR_NONE)
debug_error("dbus unregister focus failed");
return ret;
}
-int mm_sound_proxy_set_focus_reacquisition(int instance, int id, bool reacquisition, bool is_for_session)
+int mm_sound_proxy_set_focus_reacquisition(int instance, int id, bool reacquisition)
{
int ret = MM_ERROR_NONE;
GVariant *params = NULL, *result = NULL;
debug_fenter();
- params = g_variant_new("(iibb)", instance, id, reacquisition, is_for_session);
+ params = g_variant_new("(iib)", instance, id, reacquisition);
if (params) {
if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_FOCUS_SERVER, AUDIO_METHOD_SET_FOCUS_REACQUISITION, params, &result)) != MM_ERROR_NONE)
debug_error("dbus set focus reacquisition failed");
return ret;
}
-int mm_sound_proxy_acquire_focus(int instance, int id, mm_sound_focus_type_e type, int option, const char *ext_info, bool is_for_session)
+int mm_sound_proxy_acquire_focus(int instance, int id, mm_sound_focus_type_e type, int option, const char *ext_info)
{
int ret = MM_ERROR_NONE;
bool is_in_focus_cb_thread = false;
mm_sound_client_is_focus_cb_thread(g_thread_self(), &is_in_focus_cb_thread);
if (is_in_focus_cb_thread) {
- if ((ret = mm_sound_focus_socket_acquire(instance, id, type, option, ext_info ? ext_info : "", true, is_for_session)))
+ if ((ret = mm_sound_focus_socket_acquire(instance, id, type, option, ext_info ? ext_info : "", true)))
debug_error("failed to mm_sound_focus_socket_acquire(), ret[0x%x]", ret);
} else {
GVariant *params = NULL, *result = NULL;
- params = g_variant_new("(iiiisb)", instance, id, type, option, ext_info ? ext_info : "", is_for_session);
+ params = g_variant_new("(iiiis)", instance, id, type, option, ext_info ? ext_info : "");
if (params) {
if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_FOCUS_SERVER, AUDIO_METHOD_ACQUIRE_FOCUS, params, &result)) != MM_ERROR_NONE)
debug_error("dbus acquire focus failed");
return ret;
}
-int mm_sound_proxy_release_focus(int instance, int id, mm_sound_focus_type_e type, int option, const char *ext_info, bool is_for_session)
+int mm_sound_proxy_release_focus(int instance, int id, mm_sound_focus_type_e type, int option, const char *ext_info)
{
int ret = MM_ERROR_NONE;
bool is_in_focus_cb_thread = false;
mm_sound_client_is_focus_cb_thread(g_thread_self(), &is_in_focus_cb_thread);
if (is_in_focus_cb_thread) {
- if ((ret = mm_sound_focus_socket_release(instance, id, type, option, ext_info ? ext_info : "", true, is_for_session)))
+ if ((ret = mm_sound_focus_socket_release(instance, id, type, option, ext_info ? ext_info : "", true)))
debug_error("failed to mm_sound_focus_socket_release(), ret[0x%x]", ret);
} else {
GVariant *params = NULL, *result = NULL;
- params = g_variant_new("(iiiisb)", instance, id, type, option, ext_info ? ext_info : "", is_for_session);
+ params = g_variant_new("(iiiis)", instance, id, type, option, ext_info ? ext_info : "");
if (params) {
if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_FOCUS_SERVER, AUDIO_METHOD_RELEASE_FOCUS, params, &result)) != MM_ERROR_NONE)
debug_error("dbus release focus failed");
return ret;
}
-int mm_sound_proxy_set_focus_watch_callback(int instance, int handle, mm_sound_focus_type_e type, bool is_for_session, bool is_for_monitor, mm_sound_focus_changed_watch_cb callback, void* userdata)
+int mm_sound_proxy_set_focus_watch_callback(int instance, int handle, mm_sound_focus_type_e type, mm_sound_focus_changed_watch_cb callback, void* userdata)
{
int ret = MM_ERROR_NONE;
GVariant *params = NULL, *result = NULL;
debug_fenter();
- params = g_variant_new("(iiibb)", instance, handle, type, is_for_session, is_for_monitor);
+ params = g_variant_new("(iii)", instance, handle, type);
if (params) {
if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_FOCUS_SERVER, AUDIO_METHOD_WATCH_FOCUS, params, &result)) != MM_ERROR_NONE)
debug_error("dbus set watch focus failed");
}
-int mm_sound_proxy_unset_focus_watch_callback(int focus_tid, int handle, bool is_for_session)
+int mm_sound_proxy_unset_focus_watch_callback(int focus_tid, int handle)
{
int ret = MM_ERROR_NONE;
GVariant *params = NULL, *result = NULL;
debug_fenter();
- params = g_variant_new("(iib)", focus_tid, handle, is_for_session);
+ params = g_variant_new("(ii)", focus_tid, handle);
if (params) {
if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_FOCUS_SERVER, AUDIO_METHOD_UNWATCH_FOCUS, params, &result)) != MM_ERROR_NONE)
debug_error("dbus unset watch focus failed");
Name: libmm-sound
Summary: MMSound Package contains client lib and sound_server binary
-Version: 0.12.11
+Version: 0.12.12
Release: 0
Group: System/Libraries
License: Apache-2.0
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
BuildRequires: pkgconfig(mm-common)
-BuildRequires: pkgconfig(mm-session)
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(gio-2.0)
BuildRequires: pkgconfig(vconf)
Name : mmfsound
Description : Multimedia Framework Sound Library
-Requires : mm-keysound mm-bootsound mm-session glib-2.0 vconf
+Requires : mm-keysound mm-bootsound glib-2.0 vconf
Version : @VERSION@
Libs : -L${libdir} -lmmfsound
Cflags : -I${includedir}/mmf
int tone;
int repeat_count;
double volume;
- int session_type;
- int session_options;
- int session_handle;
- int focus_handle;
- int focus_wcb_id;
void *stopcb;
int (*callback)(int, void *, void *, int);
void *msgcallback; /* Client callback function */
int samplerate;
int channels;
int volume_config;
- bool enable_session;
char stream_type[MAX_STREAM_TYPE_LEN];
int stream_index;
} mmsound_mgr_codec_param_t;
int MMSoundMgrCodecInit(const char *targetdir, GSourceFunc _shutdown_cb);
int MMSoundMgrCodecFini(void);
-int MMSoundMgrCodecPlay(int *slotid, const mmsound_mgr_codec_param_t *param);
int MMSoundMgrCodecPlayWithStreamInfo(int *slotid, const mmsound_mgr_codec_param_t *param);
int MMSoundMgrCodecStop(const int slotid);
-int MMSoundMgrCodecClearFocus(int pid);
-int MMSoundMgrCodecPlayDtmf(int *slotid, const mmsound_mgr_codec_param_t *param);
int MMSoundMgrCodecPlayDtmfWithStreamInfo(int *slotid, const mmsound_mgr_codec_param_t *param);
#include <glib.h>
/* Msg processing */
-int _MMSoundMgrIpcPlayFile(char* filename, int tone, int repeat, int volume, int volume_config, int session_type,
- int session_options, int client_pid, gboolean enable_session, int *codechandle, char *stream_type, int stream_index);
int _MMSoundMgrIpcPlayFileWithStreamInfo(char* filename, int repeat, int volume,
- int client_pid, int *codechandle, char *stream_type, int stream_index);
+ int client_pid, int *codechandle, char *stream_type, int stream_index);
int _MMSoundMgrIpcStop(int handle);
-#ifdef FOCUS_INTEGRATION
-int _MMSoundMgrIpcClearFocus(int pid);
-#endif
-int _MMSoundMgrIpcPlayDTMF(int tone, int repeat, int volume, int volume_config,
- int session_type, int session_options, int client_pid,
- gboolean enable_session, int *codechandle, char *stream_type, int stream_index);
-int _MMSoundMgrIpcPlayDTMFWithStreamInfo(int tone, int repeat, int volume, int client_pid, int *codechandle, char *stream_type, int stream_index);
+int _MMSoundMgrIpcPlayDTMFWithStreamInfo(int tone, int repeat, int volume, int client_pid, int *codechandle,
+ char *stream_type, int stream_index);
int __mm_sound_mgr_ipc_notify_play_file_end(int handle);
#endif /* __MM_SOUND_MGR_H__ */
-
#include <mm_error.h>
#include <mm_types.h>
#include <mm_debug.h>
-#include <mm_session.h>
#include <glib.h>
#include "include/mm_sound_thread_pool.h"
#include "../include/mm_sound_common.h"
-#include "../include/mm_sound_focus.h"
#include "../include/mm_sound.h"
#define SHUTDOWN_TIMEOUT_SEC 60
#define STATUS_IDLE 0
#define STATUS_SOUND 3
#define SOUND_SLOT_START 0
-#define FOCUS_INTEGRATION
#define MANAGER_HANDLE_MAX 256
typedef struct {
int pluginid;
int status;
- int session_type;
- int session_options;
-#ifdef FOCUS_INTEGRATION
- int focus_handle;
- int focus_wcb_id;
- unsigned int subs_id;
- mm_sound_focus_type_e current_focus_type;
-#endif
bool stop_by_user;
- bool enable_session;
} __mmsound_mgr_codec_handle_t;
static MMSoundPluginType *g_codec_plugins = NULL;
static int _MMSoundMgrCodecRegisterInterface(MMSoundPluginType *plugin);
static int _MMSoundMgrCodecStopCallback(int param);
-
-#ifdef FOCUS_INTEGRATION
-
-static void _handle_focus_event(int slotid, mm_sound_focus_type_e focus_type, mm_sound_focus_state_e focus_state, bool is_watch)
-{
- int result = MM_ERROR_NONE;
-
- if (g_slots[slotid].session_options & MM_SESSION_OPTION_UNINTERRUPTIBLE) {
- debug_warning("session option is UNINTERRUPTIBLE, nothing to do with focus");
- return;
- }
-
- if (focus_state == FOCUS_IS_RELEASED) {
- if (!is_watch)
- g_slots[slotid].current_focus_type = FOCUS_FOR_BOTH & (~focus_type);
- debug_warning("focus is released -> stop playing");
-
- result = MMSoundMgrCodecStop(slotid);
- if (result != MM_ERROR_NONE)
- debug_error("result error 0x%X", result);
- }
-}
-
-static void _sound_codec_focus_callback(int id, mm_sound_focus_type_e focus_type, mm_sound_focus_state_e focus_state,
- const char *reason_for_change, int option, const char *ext_info, void *user_data)
-{
- debug_warning("focus callback called -> focus_state(%d), reason_for_change(%s)",
- focus_state, reason_for_change ? reason_for_change : "N/A");
-
- _handle_focus_event((int)user_data, focus_type, focus_state, false);
-}
-
-static void _sound_codec_focus_watch_callback(int id, mm_sound_focus_type_e focus_type, mm_sound_focus_state_e focus_state,
- const char *reason_for_change, const char *ext_info, void *user_data)
-{
- debug_warning("focus watch callback called -> focus_state(%d), reason_for_change(%s)",
- focus_state, reason_for_change ? reason_for_change : "N/A");
-
- _handle_focus_event((int)user_data, focus_type, focus_state, true);
-}
-
-static void _sound_codec_device_connected_callback(MMSoundDevice_t device, bool is_connected, void *user_data)
-{
- int slotid = (int)user_data;
- int result = MM_ERROR_NONE;
- mm_sound_device_type_e type;
-
- debug_warning("device_connected_callback called : handle[%p], connected[%d], slotid[%d]", device, is_connected, slotid);
-
- if (mm_sound_get_device_type(device, &type) != MM_ERROR_NONE) {
- debug_error("getting device type failed");
- return;
- }
-
- switch (type) {
- case MM_SOUND_DEVICE_TYPE_AUDIOJACK:
- case MM_SOUND_DEVICE_TYPE_BLUETOOTH:
- case MM_SOUND_DEVICE_TYPE_HDMI:
- case MM_SOUND_DEVICE_TYPE_MIRRORING:
- case MM_SOUND_DEVICE_TYPE_USB_AUDIO:
- if (!is_connected) {
- debug_warning("sound device unplugged");
- result = MMSoundMgrCodecStop(slotid);
- if (result != MM_ERROR_NONE)
- debug_error("MMSoundMgrCodecStop error %d", result);
-
- result = mm_sound_remove_device_connected_callback(g_slots[slotid].subs_id);
- if (result != MM_ERROR_NONE)
- debug_error("mm_sound_remove_device_connected_callback error %d", result);
- }
- break;
-
- default:
- break;
- }
-}
-#endif
-
/* FIXME : critical section for g_timer_id? */
static void _mm_sound_mgr_codec_shutdown_timer_start()
{
return -1;
}
-int MMSoundMgrCodecPlay(int *slotid, const mmsound_mgr_codec_param_t *param)
-{
- int plugin_id = 0;
- mmsound_codec_info_t info;
- mmsound_codec_param_t codec_param;
- int err = MM_ERROR_NONE;
-
-#ifdef FOCUS_INTEGRATION
- int need_focus_unregister = 0;
-#endif
-
-#ifdef DEBUG_DETAIL
- debug_enter();
-#endif
- plugin_id = _MMSoundMgrCodecFindCodecPluginID(MM_SOUND_SUPPORTED_CODEC_WAVE);
- if (plugin_id == -1) {
- debug_error("Could not find proper codec plugin!!!");
- err = MM_ERROR_SOUND_INTERNAL;
- goto cleanup;
- }
-
- err = g_plugins[plugin_id].Parse(param->pfilename, &info);
- if (err != MM_ERROR_NONE) {
- debug_error("Could not parse file [%s] by plugin[%d]", param->pfilename, plugin_id);
- goto cleanup;
- }
-
- debug_msg("DTMF[%d] Repeat[%d] Volume[%f] plugin_codec[%d]", param->tone, param->repeat_count, param->volume, plugin_id);
-
-#ifdef DEBUG_DETAIL
- debug_msg("Get New handle");
-#endif
-
- err = _mm_sound_mgr_codec_slot_get_empty(slotid);
- if (err != MM_ERROR_NONE || *slotid < 0) {
- debug_error("Empty g_slot is not found");
- goto cleanup;
- }
-
- codec_param.tone = param->tone;
- codec_param.volume_config = param->volume_config;
- codec_param.repeat_count = param->repeat_count;
- codec_param.volume = param->volume;
- codec_param.pfilename = param->pfilename;
- codec_param.stop_cb = _MMSoundMgrCodecStopCallback;
- codec_param.param = *slotid;
- codec_param.pid = (int)param->param;
- codec_param.stream_index = param->stream_index;
- MMSOUND_STRNCPY(codec_param.stream_type, param->stream_type, MAX_STREAM_TYPE_LEN);
- SLOT_LOCK();
-
-#ifdef FOCUS_INTEGRATION
- /*
- * Register FOCUS here
- */
-
- if (param->session_type != MM_SESSION_TYPE_CALL &&
- param->session_type != MM_SESSION_TYPE_VIDEOCALL &&
- param->session_type != MM_SESSION_TYPE_VOIP &&
- param->session_type != MM_SESSION_TYPE_VOICE_RECOGNITION &&
- param->enable_session) {
-
- unsigned int subs_id = 0;
-
- err = mm_sound_add_device_connected_callback(MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG,
- (mm_sound_device_connected_cb)_sound_codec_device_connected_callback,
- (void*) *slotid, &subs_id);
- if (err) {
- debug_error("mm_sound_add_device_connected_callback failed [0x%x]", err);
- SLOT_UNLOCK();
- return MM_ERROR_POLICY_INTERNAL;
- }
- g_slots[*slotid].subs_id = subs_id;
-
- if ((param->session_options & MM_SESSION_OPTION_PAUSE_OTHERS) ||
- param->session_type == MM_SESSION_TYPE_ALARM ||
- param->session_type == MM_SESSION_TYPE_NOTIFY ||
- param->session_type == MM_SESSION_TYPE_EMERGENCY) {
- debug_warning("session option is PAUSE_OTHERS -> acquire focus");
- err = mm_sound_focus_get_id((int *)(¶m->focus_handle));
- err = mm_sound_register_focus_for_session(param->focus_handle, (int)param->param, "media", _sound_codec_focus_callback, (void*)*slotid);
- if (err) {
- debug_error("mm_sound_register_focus_for_session failed [0x%x]", err);
- SLOT_UNLOCK();
- return MM_ERROR_POLICY_INTERNAL;
- }
- err = mm_sound_acquire_focus(param->focus_handle, FOCUS_FOR_BOTH, NULL);
- if (err) {
- debug_error("mm_sound_acquire_focus failed [0x%x]", err);
- err = mm_sound_unregister_focus(param->focus_handle);
- SLOT_UNLOCK();
- return MM_ERROR_POLICY_INTERNAL;
- }
- g_slots[*slotid].current_focus_type = FOCUS_FOR_BOTH;
- } else if (param->session_options & MM_SESSION_OPTION_UNINTERRUPTIBLE) {
- /* do nothing */
- debug_warning("session option is UNINTERRUPTIBLE, nothing to do with focus");
- } else {
- debug_warning("need to set focus watch callback");
- err = mm_sound_set_focus_watch_callback_for_session((int)param->param, FOCUS_FOR_BOTH, _sound_codec_focus_watch_callback,
- (void*)*slotid, (int *)(¶m->focus_wcb_id));
- if (err) {
- debug_error("mm_sound_set_focus_watch_callback_for_session failed [0x%x]", err);
- SLOT_UNLOCK();
- return MM_ERROR_POLICY_INTERNAL;
- }
- }
- }
- //
-#endif
-
- /* Codec id WAV or MP3 */
- g_slots[*slotid].pluginid = plugin_id;
- g_slots[*slotid].param = param->param; /* This arg is used callback data */
- g_slots[*slotid].session_type = param->session_type;
- g_slots[*slotid].session_options = param->session_options;
-#ifdef FOCUS_INTEGRATION
- g_slots[*slotid].focus_handle = param->focus_handle;
- g_slots[*slotid].focus_wcb_id = param->focus_wcb_id;
-#endif
- g_slots[*slotid].enable_session = true;
- g_slots[*slotid].pid = (int)param->param;
-
-
- debug_msg("Using Slotid : [%d] Slot Status : [%d]", *slotid, g_slots[*slotid].status);
-
- err = g_plugins[g_slots[*slotid].pluginid].Create(&codec_param, &info, &(g_slots[*slotid].plughandle));
- debug_msg("Created audio handle : [%p]", g_slots[*slotid].plughandle);
- if (err != MM_ERROR_NONE) {
- debug_error("Plugin create fail : 0x%08X", err);
- g_slots[*slotid].status = STATUS_IDLE;
- SLOT_UNLOCK();
-#ifdef FOCUS_INTEGRATION
- if (param->focus_handle)
- need_focus_unregister = 1;
-#endif
- goto cleanup;
- }
-
- err = g_plugins[g_slots[*slotid].pluginid].Play(g_slots[*slotid].plughandle);
- if (err != MM_ERROR_NONE) {
- debug_error("Fail to play : 0x%08X", err);
- g_plugins[g_slots[*slotid].pluginid].Destroy(g_slots[*slotid].plughandle);
-#ifdef FOCUS_INTEGRATION
- if (param->focus_handle)
- need_focus_unregister = 1;
-#endif
- }
-
- SLOT_UNLOCK();
-
-cleanup:
- if (_mm_sound_mgr_codec_slot_is_empty())
- _mm_sound_mgr_codec_shutdown_timer_start();
-
-#ifdef FOCUS_INTEGRATION
- if (param->session_type != MM_SESSION_TYPE_CALL &&
- param->session_type != MM_SESSION_TYPE_VIDEOCALL &&
- param->session_type != MM_SESSION_TYPE_VOIP &&
- param->session_type != MM_SESSION_TYPE_VOICE_RECOGNITION &&
- param->enable_session &&
- need_focus_unregister == 1) {
-
- if ((param->session_options & MM_SESSION_OPTION_PAUSE_OTHERS) ||
- param->session_type == MM_SESSION_TYPE_ALARM ||
- param->session_type == MM_SESSION_TYPE_NOTIFY ||
- param->session_type == MM_SESSION_TYPE_EMERGENCY) {
- err = mm_sound_release_focus(param->focus_handle, FOCUS_FOR_BOTH, NULL);
- if (mm_sound_unregister_focus(param->focus_handle) || err) {
- debug_error("focus cleaning up failed[0x%x]", err);
- return MM_ERROR_POLICY_INTERNAL;
- }
- } else if (!(param->session_options & MM_SESSION_OPTION_PAUSE_OTHERS)) {
- err = mm_sound_unset_focus_watch_callback(param->focus_wcb_id);
- if (err) {
- debug_error("focus watch cleaning up failed[0x%x]", err);
- return MM_ERROR_POLICY_INTERNAL;
- }
- }
- }
-#endif
-
-
-#ifdef DEBUG_DETAIL
- debug_leave();
-#endif
-
- return err;
-}
-
int MMSoundMgrCodecPlayWithStreamInfo(int *slotid, const mmsound_mgr_codec_param_t *param)
{
int plugin_id = 0;
}
-#define DTMF_PLUGIN_COUNT 2
-int MMSoundMgrCodecPlayDtmf(int *slotid, const mmsound_mgr_codec_param_t *param)
-{
- int plugin_id = 0;
- mmsound_codec_info_t info;
- mmsound_codec_param_t codec_param;
- int err = MM_ERROR_NONE;
-#ifdef FOCUS_INTEGRATION
- int need_focus_unregister = 0;
-#endif
-
-#ifdef DEBUG_DETAIL
- debug_enter();
-#endif
- plugin_id = _MMSoundMgrCodecFindCodecPluginID(MM_SOUND_SUPPORTED_CODEC_DTMF);
- if (plugin_id == -1) {
- debug_error("Could not find proper codec plugin!!!");
- err = MM_ERROR_SOUND_INTERNAL;
- goto cleanup;
- }
-
- /*The count num means codec type DTMF */
- debug_msg("DTMF[%d] Repeat[%d] Volume[%f] plugin_codec[%d]", param->tone, param->repeat_count, param->volume, plugin_id);
-
- if (g_plugins[plugin_id].GetSupportTypes == NULL) { /* Codec not found */
- debug_error("unsupported file type %d", plugin_id);
- printf("unsupported file type %d", plugin_id);
- err = MM_ERROR_SOUND_UNSUPPORTED_MEDIA_TYPE;
- goto cleanup;
- }
-
-#ifdef DEBUG_DETAIL
- debug_msg("Get New handle");
-#endif
-
- err = _mm_sound_mgr_codec_slot_get_empty(slotid);
- if (err != MM_ERROR_NONE || *slotid < 0) {
- debug_error("Empty g_slot is not found");
- goto cleanup;
- }
-
- codec_param.tone = param->tone;
- codec_param.volume_config = param->volume_config;
- codec_param.repeat_count = param->repeat_count;
- codec_param.volume = param->volume;
- codec_param.stop_cb = _MMSoundMgrCodecStopCallback;
- codec_param.param = *slotid;
- codec_param.pid = (int)param->param;
- codec_param.stream_index = param->stream_index;
- MMSOUND_STRNCPY(codec_param.stream_type, param->stream_type, MAX_STREAM_TYPE_LEN);
- SLOT_LOCK();
-
-#ifdef FOCUS_INTEGRATION
- //
- /*
- * Register FOCUS here
- */
-
- if (param->session_type != MM_SESSION_TYPE_CALL &&
- param->session_type != MM_SESSION_TYPE_VIDEOCALL &&
- param->session_type != MM_SESSION_TYPE_VOIP &&
- param->session_type != MM_SESSION_TYPE_VOICE_RECOGNITION &&
- param->enable_session) {
-
- unsigned int subs_id = 0;
-
- err = mm_sound_add_device_connected_callback(MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG,
- (mm_sound_device_connected_cb)_sound_codec_device_connected_callback,
- (void*) *slotid, &subs_id);
- if (err) {
- debug_error("mm_sound_add_device_connected_callback failed [0x%x]", err);
- SLOT_UNLOCK();
- return MM_ERROR_POLICY_INTERNAL;
- }
- g_slots[*slotid].subs_id = subs_id;
-
- if ((param->session_options & MM_SESSION_OPTION_PAUSE_OTHERS) ||
- param->session_type == MM_SESSION_TYPE_ALARM ||
- param->session_type == MM_SESSION_TYPE_NOTIFY ||
- param->session_type == MM_SESSION_TYPE_EMERGENCY) {
- debug_warning("session option is PAUSE_OTHERS -> acquire focus");
- err = mm_sound_focus_get_id((int *)(¶m->focus_handle));
- err = mm_sound_register_focus_for_session(param->focus_handle, (int)param->param, "media", _sound_codec_focus_callback, (void*)*slotid);
- if (err) {
- debug_error("mm_sound_register_focus failed [0x%x]", err);
- SLOT_UNLOCK();
- return MM_ERROR_POLICY_INTERNAL;
- }
- err = mm_sound_acquire_focus(param->focus_handle, FOCUS_FOR_BOTH, NULL);
- if (err) {
- debug_error("mm_sound_acquire_focus failed [0x%x]", err);
- err = mm_sound_unregister_focus(param->focus_handle);
- SLOT_UNLOCK();
- return MM_ERROR_POLICY_INTERNAL;
- }
- g_slots[*slotid].current_focus_type = FOCUS_FOR_BOTH;
- } else if (param->session_options & MM_SESSION_OPTION_UNINTERRUPTIBLE) {
- /* do nothing */
- debug_warning("session option is UNINTERRUPTIBLE, nothing to do with focus");
- } else {
- debug_warning("need to set focus watch callback");
- err = mm_sound_set_focus_watch_callback_for_session((int)param->param, FOCUS_FOR_BOTH, _sound_codec_focus_watch_callback,
- (void*)*slotid, (int *)(¶m->focus_wcb_id));
- if (err) {
- debug_error("mm_sound_set_focus_watch_callback failed [0x%x]", err);
- SLOT_UNLOCK();
- return MM_ERROR_POLICY_INTERNAL;
- }
- }
- }
-#endif
-
- g_slots[*slotid].pluginid = plugin_id;
- g_slots[*slotid].param = param->param; /* This arg is used callback data */
- g_slots[*slotid].session_type = param->session_type;
- g_slots[*slotid].session_options = param->session_options;
-#ifdef FOCUS_INTEGRATION
- g_slots[*slotid].focus_handle = param->focus_handle;
- g_slots[*slotid].focus_wcb_id = param->focus_wcb_id;
-#endif
- g_slots[*slotid].enable_session = param->enable_session;
- g_slots[*slotid].pid = (int)param->param;
-
-#ifdef DEBUG_DETAIL
- debug_msg("Using Slotid : [%d] Slot Status : [%d]", *slotid, g_slots[*slotid].status);
-#endif
-
- err = g_plugins[g_slots[*slotid].pluginid].Create(&codec_param, &info, &(g_slots[*slotid].plughandle));
- debug_msg("Created audio handle : [%p]", g_slots[*slotid].plughandle);
- if (err != MM_ERROR_NONE) {
- debug_error("Plugin create fail : 0x%08X", err);
- g_slots[*slotid].status = STATUS_IDLE;
- SLOT_UNLOCK();
-#ifdef FOCUS_INTEGRATION
- need_focus_unregister = 1;
-#endif
- goto cleanup;
- }
-
- err = g_plugins[g_slots[*slotid].pluginid].Play(g_slots[*slotid].plughandle);
- if (err != MM_ERROR_NONE) {
- debug_error("Fail to play : 0x%08X", err);
- g_plugins[g_slots[*slotid].pluginid].Destroy(g_slots[*slotid].plughandle);
-#ifdef FOCUS_INTEGRATION
- need_focus_unregister = 1;
-#endif
- }
-
- SLOT_UNLOCK();
- debug_msg("Using Slotid : [%d] Slot Status : [%d]", *slotid, g_slots[*slotid].status);
-
-cleanup:
-#ifdef FOCUS_INTEGRATION
- if (param->session_type != MM_SESSION_TYPE_CALL &&
- param->session_type != MM_SESSION_TYPE_VIDEOCALL &&
- param->session_type != MM_SESSION_TYPE_VOIP &&
- param->session_type != MM_SESSION_TYPE_VOICE_RECOGNITION &&
- param->enable_session &&
- need_focus_unregister == 1) {
-
- if ((param->session_options & MM_SESSION_OPTION_PAUSE_OTHERS) ||
- param->session_type == MM_SESSION_TYPE_ALARM ||
- param->session_type == MM_SESSION_TYPE_NOTIFY ||
- param->session_type == MM_SESSION_TYPE_EMERGENCY) {
- err = mm_sound_release_focus(param->focus_handle, FOCUS_FOR_BOTH, NULL);
- if (mm_sound_unregister_focus(param->focus_handle) || err) {
- debug_error("focus cleaning up failed[0x%x]", err);
- return MM_ERROR_POLICY_INTERNAL;
- }
- } else if (!(param->session_options & MM_SESSION_OPTION_PAUSE_OTHERS)) {
- err = mm_sound_unset_focus_watch_callback(param->focus_wcb_id);
- if (err) {
- debug_error("focus watch cleaning up failed[0x%x]", err);
- return MM_ERROR_POLICY_INTERNAL;
- }
- }
- }
-#endif
-
-#ifdef DEBUG_DETAIL
- debug_leave();
-#endif
-
- return err;
-}
-
int MMSoundMgrCodecPlayDtmfWithStreamInfo(int *slotid, const mmsound_mgr_codec_param_t *param)
{
int plugin_id = 0;
g_slots[*slotid].pluginid = plugin_id;
g_slots[*slotid].param = param->param; /* This arg is used callback data */
- g_slots[*slotid].enable_session = param->enable_session;
#ifdef DEBUG_DETAIL
debug_msg("Using Slotid : [%d] Slot Status : [%d]", *slotid, g_slots[*slotid].status);
return err;
}
-#ifdef FOCUS_INTEGRATION
-int MMSoundMgrCodecClearFocus(int pid)
-{
- int err = MM_ERROR_NONE;
- int slotid;
-
- debug_enter("(pid : [%d])", pid);
-
- SLOT_LOCK();
-
- for (slotid = 0 ; slotid < MANAGER_HANDLE_MAX ; slotid++) {
- if (g_slots[slotid].pid == pid) {
- if (g_slots[slotid].focus_handle || g_slots[slotid].focus_wcb_id) {
- if (g_slots[slotid].session_type != MM_SESSION_TYPE_CALL &&
- g_slots[slotid].session_type != MM_SESSION_TYPE_VIDEOCALL &&
- g_slots[slotid].session_type != MM_SESSION_TYPE_VOIP &&
- g_slots[slotid].session_type != MM_SESSION_TYPE_VOICE_RECOGNITION &&
- g_slots[slotid].enable_session) {
- if ((g_slots[slotid].session_options & MM_SESSION_OPTION_PAUSE_OTHERS) ||
- g_slots[slotid].session_type == MM_SESSION_TYPE_ALARM ||
- g_slots[slotid].session_type == MM_SESSION_TYPE_NOTIFY ||
- g_slots[slotid].session_type == MM_SESSION_TYPE_EMERGENCY) {
- err = mm_sound_release_focus(g_slots[slotid].focus_handle, FOCUS_FOR_BOTH, NULL);
- if (err)
- debug_error("mm_sound_release_focus failed [0x%x]", err);
-
- if (mm_sound_unregister_focus(g_slots[slotid].focus_handle) || err) {
- debug_error("Focus clean up failed [0x%x]", err);
- err = MM_ERROR_POLICY_INTERNAL;
- goto cleanup;
- }
- } else if (!(g_slots[slotid].session_options & MM_SESSION_OPTION_PAUSE_OTHERS)) {
- err = mm_sound_unset_focus_watch_callback(g_slots[slotid].focus_wcb_id);
- if (err) {
- debug_error("mm_sound_unset_focus_watch_callback failed [0x%x]", err);
- err = MM_ERROR_POLICY_INTERNAL;
- goto cleanup;
- }
- }
- }
- if (mm_sound_remove_device_connected_callback(g_slots[slotid].subs_id) != MM_ERROR_NONE)
- debug_error("mm_sound_remove_device_connected_callback() failed");
- g_slots[slotid].focus_handle = 0;
- g_slots[slotid].focus_wcb_id = 0;
- g_slots[slotid].subs_id = 0;
- }
- }
- }
-
-cleanup:
- SLOT_UNLOCK();
- debug_leave("(err : 0x%08X)", err);
-
- return err;
-}
-#endif
static int _MMSoundMgrCodecStopCallback(int param)
{
if (g_slots[param].stop_by_user == false)
SLOT_LOCK();
-#ifdef FOCUS_INTEGRATION
- /*
- * Unregister FOCUS here
- */
- debug_msg("[CODEC MGR] enable_session %d ", g_slots[param].enable_session);
-
- if (g_slots[param].focus_handle || g_slots[param].focus_wcb_id) {
- if (g_slots[param].session_type != MM_SESSION_TYPE_CALL &&
- g_slots[param].session_type != MM_SESSION_TYPE_VIDEOCALL &&
- g_slots[param].session_type != MM_SESSION_TYPE_VOIP &&
- g_slots[param].session_type != MM_SESSION_TYPE_VOICE_RECOGNITION &&
- g_slots[param].enable_session) {
- if ((g_slots[param].session_options & MM_SESSION_OPTION_PAUSE_OTHERS) ||
- g_slots[param].session_type == MM_SESSION_TYPE_ALARM ||
- g_slots[param].session_type == MM_SESSION_TYPE_NOTIFY ||
- g_slots[param].session_type == MM_SESSION_TYPE_EMERGENCY) {
- if (g_slots[param].current_focus_type != FOCUS_NONE) {
- err = mm_sound_release_focus(g_slots[param].focus_handle, g_slots[param].current_focus_type, NULL);
- if (err)
- debug_error("mm_sound_release_focus failed [0x%x]", err);
- }
- if (mm_sound_unregister_focus(g_slots[param].focus_handle) || err) {
- debug_error("Focus clean up failed [0x%x]", err);
- err = MM_ERROR_POLICY_INTERNAL;
- goto finish;
- }
- } else if (!(g_slots[param].session_options & MM_SESSION_OPTION_PAUSE_OTHERS)) {
- err = mm_sound_unset_focus_watch_callback(g_slots[param].focus_wcb_id);
- if (err) {
- debug_error("mm_sound_unset_focus_watch_callback failed [0x%x]", err);
- err = MM_ERROR_POLICY_INTERNAL;
- goto finish;
- }
- }
- }
- if (mm_sound_remove_device_connected_callback(g_slots[param].subs_id) != MM_ERROR_NONE)
- debug_error("mm_sound_remove_device_connected_callback() failed");
- }
-#endif
-
__mm_sound_mgr_ipc_notify_play_file_end(param);
debug_msg("Client callback msg_type (instance) : [%d]", (int)g_slots[param].param);
if (_mm_sound_mgr_codec_slot_is_empty())
_mm_sound_mgr_codec_shutdown_timer_start();
-finish:
if (g_slots[param].stop_by_user == false)
SLOT_UNLOCK();
Functions For handling request from client
******************************************************************************************/
// except msgid
-int _MMSoundMgrIpcPlayFile(char* filename, int tone, int repeat, int volume, int volume_config,
- int session_type, int session_options, int client_pid, gboolean enable_session,
- int *codechandle, char *stream_type, int stream_index)
-{
- mmsound_mgr_codec_param_t param = { 0, };
- int ret = MM_ERROR_NONE;
-
- /* Set sound player parameter */
- param.tone = tone;
- param.repeat_count = repeat;
- param.volume = volume;
- param.volume_config = volume_config;
- param.session_type = session_type;
- param.session_options = session_options;
- param.param = (void*)client_pid;
- param.pfilename = filename;
- param.enable_session = enable_session;
- param.stream_index = stream_index;
- MMSOUND_STRNCPY(param.stream_type, stream_type, MAX_STREAM_TYPE_LEN);
-
- ret = MMSoundMgrCodecPlay(codechandle, ¶m);
- if (ret != MM_ERROR_NONE) {
- debug_error("Will be closed a sources, codechandle : 0x%08X", *codechandle);
- return ret;
- }
-
- return MM_ERROR_NONE;
-}
-
int _MMSoundMgrIpcStop(int handle)
{
int ret = MM_ERROR_NONE;
return MM_ERROR_NONE;
}
-#ifdef FOCUS_INTEGRATION
-int _MMSoundMgrIpcClearFocus(int pid)
-{
- int ret = MM_ERROR_NONE;
-
- ret = MMSoundMgrCodecClearFocus(pid);
-
- if (ret != MM_ERROR_NONE) {
- debug_error("Fail to clear focus");
- return ret;
- }
-
- return MM_ERROR_NONE;
-}
-#endif
-
int _MMSoundMgrIpcPlayFileWithStreamInfo(char *filename, int repeat, int volume,
int client_pid, int *codechandle, char *stream_type, int stream_index)
{
}
-int _MMSoundMgrIpcPlayDTMF(int tone, int repeat, int volume, int volume_config,
- int session_type, int session_options, int client_pid,
- gboolean enable_session, int *codechandle,
- char *stream_type, int stream_index)
-{
- mmsound_mgr_codec_param_t param = { 0, };
- int ret = MM_ERROR_NONE;
-
- /* Set sound player parameter */
- param.tone = tone;
- param.repeat_count = repeat;
- param.volume = volume;
- param.volume_config = volume_config;
- param.param = (void*)client_pid;
- param.session_type = session_type;
- param.session_options = session_options;
- param.enable_session = enable_session;
- param.stream_index = stream_index;
- MMSOUND_STRNCPY(param.stream_type, stream_type, MAX_STREAM_TYPE_LEN);
-
- debug_msg("DTMF %d", param.tone);
- debug_msg("Loop %d", param.repeat_count);
- debug_msg("Volume %f", param.volume);
- debug_msg("VolumeConfig %x", param.volume_config);
- debug_msg("session %d", param.session_type);
- debug_msg("session options %x", param.session_options);
- debug_msg("enable_session %d", param.enable_session);
-
- ret = MMSoundMgrCodecPlayDtmf(codechandle, ¶m);
- if (ret != MM_ERROR_NONE) {
- debug_error("Will be closed a sources, codec handle : [0x%d]", *codechandle);
- return ret;
- }
-
- return ret;
-}
-
int _MMSoundMgrIpcPlayDTMFWithStreamInfo(int tone, int repeat, int volume, int client_pid, int *codechandle,
char *stream_type, int stream_index)
{
" <arg type='b' name='is_bt_on' direction='out'/>"
" <arg type='s' name='bt_name' direction='out'/>"
" </method>"
- " <method name='PlayFileStart'>"
+ " <method name='PlayFileStartWithStreamInfo'>"
" <arg type='s' name='filename' direction='in'/>"
- " <arg type='i' name='tone' direction='in'/>"
" <arg type='i' name='repeat' direction='in'/>"
" <arg type='i' name='volume' direction='in'/>"
- " <arg type='i' name='vol_config' direction='in'/>"
- " <arg type='i' name='session_type' direction='in'/>"
- " <arg type='i' name='session_option' direction='in'/>"
" <arg type='i' name='client_pid' direction='in'/>"
- " <arg type='b' name='enable_session' direction='in'/>"
" <arg type='s' name='stream_type' direction='in'/>"
" <arg type='i' name='stream_index' direction='in'/>"
" <arg type='i' name='handle' direction='out'/>"
" </method>"
- " <method name='PlayFileStartWithStreamInfo'>"
- " <arg type='s' name='filename' direction='in'/>"
- " <arg type='i' name='repeat' direction='in'/>"
- " <arg type='i' name='volume' direction='in'/>"
- " <arg type='i' name='client_pid' direction='in'/>"
- " <arg type='s' name='stream_type' direction='in'/>"
- " <arg type='i' name='stream_index' direction='in'/>"
- " <arg type='i' name='handle' direction='out'/>"
- " </method>"
" <method name='PlayFileStop'>"
" <arg type='i' name='handle' direction='in'/>"
" </method>"
-#ifdef FOCUS_INTEGRATION
- " <method name='ClearFocus'>"
- " <arg type='i' name='pid' direction='in'/>"
- " </method>"
-#endif
- " <method name='PlayDTMF'>"
+ " <method name='PlayDTMFWithStreamInfo'>"
" <arg type='i' name='tone' direction='in'/>"
" <arg type='i' name='repeat' direction='in'/>"
" <arg type='i' name='volume' direction='in'/>"
- " <arg type='i' name='vol_config' direction='in'/>"
- " <arg type='i' name='session_type' direction='in'/>"
- " <arg type='i' name='session_option' direction='in'/>"
" <arg type='i' name='client_pid' direction='in'/>"
- " <arg type='b' name='enable_session' direction='in'/>"
- " <arg type='s' name='stream_type' direction='in'/>"
- " <arg type='i' name='stream_index' direction='in'/>"
+ " <arg type='s' name='stream_type' direction='in'/>"
+ " <arg type='i' name='stream_index' direction='in'/>"
" <arg type='i' name='handle' direction='out'/>"
" </method>"
- " <method name='PlayDTMFWithStreamInfo'>"
- " <arg type='i' name='tone' direction='in'/>"
- " <arg type='i' name='repeat' direction='in'/>"
- " <arg type='i' name='volume' direction='in'/>"
- " <arg type='i' name='client_pid' direction='in'/>"
- " <arg type='s' name='stream_type' direction='in'/>"
- " <arg type='i' name='stream_index' direction='in'/>"
- " <arg type='i' name='handle' direction='out'/>"
- " </method>"
" <method name='GetConnectedDeviceList'>"
" <arg type='i' name='device_mask' direction='in'/>"
" <arg type='a(iiiis)' name='device_list' direction='out'/>"
"</node>";
static GDBusConnection* conn_g;
-static void handle_method_play_file_start(GDBusMethodInvocation* invocation);
static void handle_method_play_file_start_with_stream_info(GDBusMethodInvocation* invocation);
static void handle_method_play_file_stop(GDBusMethodInvocation* invocation);
-static void handle_method_play_dtmf(GDBusMethodInvocation* invocation);
static void handle_method_play_dtmf_with_stream_info(GDBusMethodInvocation* invocation);
#ifdef FOCUS_INTEGRATION
static void handle_method_clear_focus(GDBusMethodInvocation* invocation);
},
.handler = handle_method_test
},
- [AUDIO_METHOD_PLAY_FILE_START] = {
- .info = {
- .name = "PlayFileStart",
- },
- .handler = handle_method_play_file_start
- },
[AUDIO_METHOD_PLAY_FILE_START_WITH_STREAM_INFO] = {
.info = {
.name = "PlayFileStartWithStreamInfo",
},
.handler = handle_method_play_file_stop
},
-#ifdef FOCUS_INTEGRATION
- [AUDIO_METHOD_CLEAR_FOCUS] = {
- .info = {
- .name = "ClearFocus",
- },
- .handler = handle_method_clear_focus
- },
-#endif
- [AUDIO_METHOD_PLAY_DTMF] = {
- .info = {
- .name = "PlayDTMF",
- },
- .handler = handle_method_play_dtmf
- },
[AUDIO_METHOD_PLAY_DTMF_WITH_STREAM_INFO] = {
.info = {
.name = "PlayDTMFWithStreamInfo",
debug_fleave();
}
-static void handle_method_play_file_start(GDBusMethodInvocation* invocation)
-{
- gchar* filename = NULL;
- gchar *stream_type = NULL;
- gint32 ret = MM_ERROR_NONE, slotid = 0;
- gint32 tone = 0, repeat = 0, volume = 0, vol_config = 0;
- gint32 session_type = 0, session_option = 0, pid = 0, stream_index = 0;
- gboolean enable_session = 0;
- GVariant *params = NULL;
-
- debug_fenter();
-
- if (!(params = g_dbus_method_invocation_get_parameters(invocation))) {
- debug_error("Parameter for Method is NULL");
- ret = MM_ERROR_SOUND_INTERNAL;
- goto send_reply;
- }
-
- g_variant_get(params, "(siiiiiiibsi)", &filename, &tone, &repeat, &volume,
- &vol_config, &session_type, &session_option, &pid, &enable_session, &stream_type, &stream_index);
- if (!filename) {
- debug_error("filename null");
- ret = MM_ERROR_SOUND_INTERNAL;
- goto send_reply;
- }
- ret = _MMSoundMgrIpcPlayFile(filename, tone, repeat, volume, vol_config,
- session_type, session_option, _get_sender_pid(invocation), enable_session, &slotid, stream_type, stream_index);
-
-
-send_reply:
- if (ret == MM_ERROR_NONE)
- _method_call_return_value(invocation, g_variant_new("(i)", slotid));
- else
- _method_call_return_error(invocation, ret);
-
- g_free(filename);
- g_free(stream_type);
-
- debug_fleave();
-}
-
static void handle_method_play_file_start_with_stream_info(GDBusMethodInvocation* invocation)
{
gchar* filename = NULL;
debug_fleave();
}
-static void handle_method_play_dtmf(GDBusMethodInvocation* invocation)
-{
- int ret = MM_ERROR_NONE, slotid = 0;
- int tone = 0, repeat = 0, volume = 0, vol_config = 0, session_type = 0, session_option = 0, pid = 0, stream_index = 0;
- gchar* stream_type = NULL;
- gboolean enable_session = 0;
- GVariant *params = NULL;
-
- debug_fenter();
-
- if (!(params = g_dbus_method_invocation_get_parameters(invocation))) {
- debug_error("Parameter for Method is NULL");
- ret = MM_ERROR_SOUND_INTERNAL;
- goto send_reply;
- }
-
- g_variant_get(params, "(iiiiiiibsi)", &tone, &repeat, &volume,
- &vol_config, &session_type, &session_option, &pid, &enable_session, &stream_type, &stream_index);
- debug_error("volume - %d", volume);
- ret = _MMSoundMgrIpcPlayDTMF(tone, repeat, volume, vol_config,
- session_type, session_option, _get_sender_pid(invocation),
- enable_session, &slotid, stream_type, stream_index);
-
-send_reply:
- if (ret == MM_ERROR_NONE)
- _method_call_return_value(invocation, g_variant_new("(i)", slotid));
- else
- _method_call_return_error(invocation, ret);
-
- g_free(stream_type);
-
- debug_fleave();
-}
-
static void handle_method_play_dtmf_with_stream_info(GDBusMethodInvocation* invocation)
{
int ret = MM_ERROR_NONE, slotid = 0;
#define MAX_PATH_LEN 1024
#define MIN_TONE_PLAY_TIME 300
#include "../include/mm_sound.h"
-#ifdef USE_FOCUS
#include "../include/mm_sound_focus.h"
-#endif
#include "../include/mm_sound_common.h"
#include "../include/mm_sound_private.h"
#include "../include/mm_sound_pa_client.h"
#include <unistd.h>
#include <dirent.h>
#include <vconf.h>
-#include <mm_session_private.h>
#define POWERON_FILE "/usr/share/feedback/sound/operation/power_on.wav"
#define KEYTONE_FILE "/usr/share/feedback/sound/operation/operation.wav"
-
-// For testsuite status
enum {
- CURRENT_STATUS_MAINMENU = 0,
- CURRENT_STATUS_FILENAME = 1,
- CURRENT_STATUS_POSITION = 2,
- CURRENT_STATUS_DIRNAME = 3,
+ CURRENT_STATUS_MAINMENU = 0,
+ CURRENT_STATUS_FILENAME = 1,
+ CURRENT_STATUS_POSITION = 2,
+ CURRENT_STATUS_DIRNAME = 3,
};
int g_menu_state = CURRENT_STATUS_MAINMENU;
-
volume_type_t g_volume_type = VOLUME_TYPE_MEDIA;
unsigned int g_volume_value;
-
GIOChannel *stdin_channel;
char g_file_name[MAX_STRING_LEN];
char g_dir_name[MAX_PATH_LEN];
-
-#ifdef USE_FOCUS
int g_focus_watch_index = -1;
-#endif
GMainLoop* g_loop;
-
unsigned int g_subs_id_test, g_subs_id_volume, g_subs_id_device_conn, g_subs_id_device_state;
-// Function
-static void interpret (char *buf);
+static void interpret(char *buf);
gboolean timeout_menu_display(void *data);
gboolean timeout_quit_program(void *data);
-gboolean input (GIOChannel *channel);
+gboolean input(GIOChannel *channel);
void mycallback(void *data, int id)
{
char *str = (char*)data;
- if(data != NULL)
+ if (data != NULL)
debug_log("mycallback called (user data:%s ,id:%d)", str, id);
else
debug_log("mycallback called (no user data)");
debug_log("dbus test user callback called: param(%d), userdata(%d)", a, (int)user_data);
g_print("my callback pid : %u tid : %ld\n", getpid(), pthread_self());
}
-void device_connected_cb (MMSoundDevice_t device_h, bool is_connected, void *user_data)
+void device_connected_cb(MMSoundDevice_t device_h, bool is_connected, void *user_data)
{
int ret = 0;
mm_sound_device_type_e device_type = 0;
"vendor-id(%04x) product-id(%04x)",
device_type, id, io_direction, state, name, vendor_id, product_id);
}
-void device_state_changed_cb (MMSoundDevice_t device_h, mm_sound_device_state_e new_state, void *user_data)
+void device_state_changed_cb(MMSoundDevice_t device_h, mm_sound_device_state_e new_state, void *user_data)
{
int ret = 0;
mm_sound_device_type_e device_type = 0;
"vendor-id(%04x) product-id(%04x)",
device_type, id, io_direction, state, name, vendor_id, product_id);
}
-#ifdef USE_FOCUS
+
void focus_cb0(int index, mm_sound_focus_type_e type, mm_sound_focus_state_e state, const char *reason_for_change, int option, const char *ext_info, void *user_data)
{
char *_state = NULL;
debug_log("*** focus_watch_cb is called, index[%d], focus_type[%d], state[%s], reason_for_change[%s], ext_info[%s], user_data[%s]",
index, type, _state, reason_for_change, ext_info, (char*)user_data);
}
-#endif
+
void quit_program()
{
g_main_loop_quit(g_loop);
{
if (g_menu_state == CURRENT_STATUS_MAINMENU) {
g_print("==================================================================\n");
- g_print(" Sound Path APIs\n");
- g_print("==================================================================\n");
- g_print("1. Play speaker \t");
- g_print("2. Play headset \n");
- g_print("3. (blank) \n");
- g_print("4. Rec. with mic \t");
- g_print("5. (blank) \t");
- g_print("6. Call receiver \n");
- g_print("7. Call end \t");
- g_print("8. VT call speaker \t");
- g_print("9. VT call end \n");
- g_print("==================================================================\n");
g_print(" Sound Play APIs\n");
g_print("==================================================================\n");
g_print("k : Key Sound \t");
- g_print("an : play sound \t");
- g_print("as : play sound with stream type\t");
- g_print("A : play loud solo\n");
- g_print("c : play sound ex \t");
- g_print("FN : Play DTMF \t");
+ g_print("as : play sound with stream type\n");
g_print("FS : Play DTMF with stream type\t");
g_print("b : Play directory\n");
- g_print("s : Stop play \t");
- g_print("m : stereo to mono\n");
+ g_print("s : Stop play \n");
g_print("==================================================================\n");
g_print(" Volume APIs\n");
g_print("==================================================================\n");
g_print("{ : Get BT A2DP Status\n");
g_print("} : Set Active Route\n");
g_print("==================================================================\n");
- g_print(" Session Test\n");
- g_print("==================================================================\n");
- g_print("z : Call start \t");
- g_print("Z : VideoCall start \t");
- g_print("N : Notification start \n");
- g_print("n : VOIP start \t");
- g_print("v : Session end \n");
- g_print("==================================================================\n");
g_print(" Audio device APIs\n");
g_print("==================================================================\n");
g_print("L : Get current list of connected devices \n");
g_print("Q : Add device state. changed callback \t");
g_print("W : Remove device state. changed callback \n");
g_print("==================================================================\n");
-#ifdef USE_FOCUS
g_print(" Focus APIs\n");
g_print("==================================================================\n");
- g_print("DS : signal subscribe for stream info\t");
- g_print("DU : signal unsubscribe for stream info\n");
- g_print("SS : Send signal for stream info\n");
g_print("GU : Get Focus id\n");
g_print("SF : Set Focus Callback\t");
- g_print("FFS : Set Focus Callback for session\t");
g_print("UF : Unset Focus Callback\n");
g_print("DF : Disable Auto Focus Reacquirement\t");
g_print("AF : Acquire Focus\t");
g_print("RF : Release Focus\n");
g_print("WS : Set Focus Watch Callback\t");
- g_print("WFS : Set Focus Watch Callback for session\t");
g_print("WU : Unset Focus Watch Callback\n");
g_print("==================================================================\n");
-#endif
g_print("d : Input Directory \t");
g_print("f : Input File name \t");
g_print("x : Exit Program \n");
g_print("==================================================================\n");
g_print(" Input command >>>>>>>> ");
- }
- else if (g_menu_state == CURRENT_STATUS_FILENAME) {
+ } else if (g_menu_state == CURRENT_STATUS_FILENAME) {
g_print(">>>>Input file name to play : ");
- }
- else if (g_menu_state == CURRENT_STATUS_DIRNAME) {
+ } else if (g_menu_state == CURRENT_STATUS_DIRNAME) {
g_print(">>>>Input directory which contain audio files : ");
- }
- else {
+ } else {
g_print("**** Unknown status.\n");
quit_program();
}
return FALSE;
}
-gboolean input (GIOChannel *channel)
+gboolean input(GIOChannel *channel)
{
GError *err = NULL;
gchar *buf = NULL;
static void input_filename(char *filename)
{
MMSOUND_STRNCPY(g_file_name, filename, MAX_STRING_LEN);
- g_print("\nThe input filename is '%s' \n\n",g_file_name);
+ g_print("\nThe input filename is '%s' \n\n", g_file_name);
}
static void input_dirname(char *dirname)
{
MMSOUND_STRNCPY(g_dir_name, dirname, MAX_PATH_LEN);
- g_print("\nThe input directory is '%s' \n\n",g_dir_name);
+ g_print("\nThe input directory is '%s' \n\n", g_dir_name);
}
-#ifdef USE_FOCUS
-static void __mm_sound_signal_cb1 (mm_sound_signal_name_t signal, int value, void *user_data)
+static void interpret(char *cmd)
{
- int _value = 0;
- g_print ("[%s] signal[%d], value[%d], user_data[%p]]\n", __func__, signal, value, user_data);
- mm_sound_get_signal_value (signal, &_value);
- g_print (" -- get value : %d\n", _value);
-}
+ int ret = 0;
+ static int handle = -1;
-static void __mm_sound_signal_cb2 (mm_sound_signal_name_t signal, int value, void *user_data)
-{
- int _value = 0;
- g_print ("[%s] signal[%d], value[%d], user_data[%p]]\n", __func__, signal, value, user_data);
- mm_sound_get_signal_value (signal, &_value);
- g_print (" -- get value : %d\n", _value);
-}
+ switch (g_menu_state) {
+ case CURRENT_STATUS_MAINMENU:
+ if (strncmp(cmd, "GU", 2) == 0) {
+ int id = 0;
+ ret = mm_sound_focus_get_id(&id);
+ if (ret < 0)
+ debug_log("mm_sound_focus_get_id() failed with 0x%x", ret);
+ else
+ debug_log("id : %d", id);
-unsigned int g_subscribe_id1 = 0;
-unsigned int g_subscribe_id2 = 0;
-#endif
+ } else if (strncmp(cmd, "SF", 2) == 0) {
+ int ret = 0;
+ char input_string[128];
+ char flag_1, flag_2;
+ int id = 2;
+ char *stream_type = "media";
+ const char *user_data = "this is user data";
-static void interpret (char *cmd)
-{
- int ret=0;
- static int handle = -1;
- MMSoundPlayParam soundparam = {0,};
-
- switch (g_menu_state)
- {
- case CURRENT_STATUS_MAINMENU:
-#ifdef USE_FOCUS
- if(strncmp(cmd, "DS", 2) == 0) {
- ret = mm_sound_subscribe_signal(MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, &g_subscribe_id1, __mm_sound_signal_cb1, NULL);
- if(ret < 0)
- debug_log("mm_sound_subscribe_signal() failed with 0x%x", ret);
- else
- debug_log("id: %u, callback:%p", g_subscribe_id1, __mm_sound_signal_cb1);
- ret = mm_sound_subscribe_signal(MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, &g_subscribe_id2, __mm_sound_signal_cb2, NULL);
- if(ret < 0)
- debug_log("mm_sound_subscribe_signal() failed with 0x%x", ret);
- else
- debug_log("id: %u, callback:%p", g_subscribe_id2, __mm_sound_signal_cb2);
- }
+ fflush(stdin);
+ g_print("1. Media\n");
+ g_print("2. Alarm\n");
+ g_print("3. Notification\n");
+ g_print("4. Emergency\n");
+ g_print("5. Voice Information\n");
+ g_print("6. Ringtone\n");
+ g_print("7. Ringtone Call\n");
+ g_print("8. VOIP\n");
+ g_print("0. Voice Recognition\n");
+ g_print("> select id and stream type: (eg. 0 3)");
- else if(strncmp(cmd, "DU", 2) == 0) {
- mm_sound_unsubscribe_signal(g_subscribe_id1);
- debug_log("unsubscribe_signal for id[%d]", g_subscribe_id1);
- mm_sound_unsubscribe_signal(g_subscribe_id2);
- debug_log("unsubscribe_signal for id[%d]", g_subscribe_id2);
- }
+ if (fgets(input_string, sizeof(input_string)-1, stdin)) {
+ flag_1 = input_string[0];
+ flag_2 = input_string[2];
- else if(strncmp(cmd, "SS", 2) == 0) {
- int value = 0;
- ret = mm_sound_send_signal(MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, 1);
- if(ret < 0)
- debug_log("mm_sound_send_signal() failed with 0x%x", ret);
- else
- debug_log("mm_sound_send_signal for signal[%d], value[%d] is success", MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, 1);
- mm_sound_get_signal_value (MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, &value);
- g_print (" -- get value of RELEASE_INTERNAL_FOCUS : %d\n", value);
- ret = mm_sound_send_signal(MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, 0);
- if(ret < 0)
- debug_log("mm_sound_send_signal() failed with 0x%x", ret);
+ if (flag_1 == '0')
+ id = 0;
+ else if (flag_1 == '1')
+ id = 1;
+ else if (flag_1 == '2')
+ id = 2;
+
+ if (flag_2 == '1')
+ stream_type = "media";
+ else if (flag_2 == '2')
+ stream_type = "alarm";
+ else if (flag_2 == '3')
+ stream_type = "notification";
+ else if (flag_2 == '4')
+ stream_type = "emergency";
+ else if (flag_2 == '5')
+ stream_type = "voice-information";
+ else if (flag_2 == '6')
+ stream_type = "ringtone";
+ else if (flag_2 == '7')
+ stream_type = "ringtone-call";
+ else if (flag_2 == '8')
+ stream_type = "voip";
+ else if (flag_2 == '0')
+ stream_type = "voice-recognition";
+
+ ret = mm_sound_register_focus(id, stream_type, (id == 0) ? focus_cb0 : focus_cb1, (void*)user_data);
+ if (ret)
+ g_print("failed to mm_sound_register_focus(), ret[0x%x]\n", ret);
else
- debug_log("mm_sound_send_signal for signal[%d], value[%d] is success", MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, 0);
- mm_sound_get_signal_value (MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, &value);
- g_print (" -- get value of RELEASE_INTERNAL_FOCUS : %d\n", value);
- }
+ g_print("id[%d], stream_type[%s], callback fun[%p]\n", id, stream_type, (id == 0) ? focus_cb0 : focus_cb1);
- else if(strncmp(cmd, "GU", 2) == 0) {
- int id = 0;
- ret = mm_sound_focus_get_id(&id);
- if(ret < 0)
- debug_log("mm_sound_focus_get_id() failed with 0x%x", ret);
- else
- debug_log("id : %d", id);
+ } else {
+ g_print("### fgets return NULL\n");
}
-
- else if(strncmp(cmd, "SF", 2) == 0) {
- int ret = 0;
- char input_string[128];
- char flag_1, flag_2;
- int id = 0;
- char *stream_type = NULL;
- const char *user_data = "this is user data";
-
- fflush(stdin);
- g_print ("1. Media\n");
- g_print ("2. Alarm\n");
- g_print ("3. Notification\n");
- g_print ("4. Emergency\n");
- g_print ("5. Voice Information\n");
- g_print ("6. Ringtone\n");
- g_print ("7. Ringtone Call\n");
- g_print ("8. VOIP\n");
- g_print ("0. Voice Recognition\n");
- g_print("> select id and stream type: (eg. 0 3)");
-
- if (fgets(input_string, sizeof(input_string)-1, stdin)) {
- flag_1 = input_string[0];
- flag_2 = input_string[2];
-
- if(flag_1 == '0') { id = 0; }
- else if(flag_1 == '1') { id = 1; }
- else if(flag_1 == '2') { id = 2; }
- else { id = 2; }
- if(flag_2 == '1') { stream_type = "media"; }
- else if(flag_2 == '2') { stream_type = "alarm"; }
- else if(flag_2 == '3') { stream_type = "notification"; }
- else if(flag_2 == '4') { stream_type = "emergency"; }
- else if(flag_2 == '5') { stream_type = "voice-information"; }
- else if(flag_2 == '6') { stream_type = "ringtone"; }
- else if(flag_2 == '7') { stream_type = "ringtone-call"; }
- else if(flag_2 == '8') { stream_type = "voip"; }
- else if(flag_2 == '0') { stream_type = "voice-recognition"; }
- else { stream_type = "media"; }
-
- ret = mm_sound_register_focus(id, stream_type, (id == 0)? focus_cb0 : focus_cb1, (void*)user_data);
- if (ret) {
- g_print("failed to mm_sound_register_focus(), ret[0x%x]\n", ret);
- } else {
- g_print("id[%d], stream_type[%s], callback fun[%p]\n", id, stream_type, (id == 0)? focus_cb0 : focus_cb1);
- }
- } else {
- g_print ("### fgets return NULL\n");
- }
+ } else if (strncmp(cmd, "UF", 2) == 0) {
+ int ret = 0;
+ char input_string[128];
+ char flag_1;
+ int id = 2;
+ fflush(stdin);
+ g_print("> select id:");
+ if (fgets(input_string, sizeof(input_string)-1, stdin)) {
+ flag_1 = input_string[0];
+ if (flag_1 == '0')
+ id = 0;
+ else if (flag_1 == '1')
+ id = 1;
+ else if (flag_1 == '2')
+ id = 2;
+ ret = mm_sound_unregister_focus(id);
+ if (ret)
+ g_print("failed to mm_sound_unregister_focus(), ret[0x%x]\n", ret);
+ } else {
+ g_print("### fgets return NULL\n");
}
+ } else if (strncmp(cmd, "DF", 2) == 0) {
+ int ret = 0;
+ char input_string[128];
+ char flag_1, flag_2;
+ int id = 2;
+ bool reacquisition = true;
+ fflush(stdin);
+ g_print("1. enable auto reacquirement\n");
+ g_print("2. disable auto reacquirement\n");
+ g_print("> select id and option: (eg. 0 1)");
+ if (fgets(input_string, sizeof(input_string)-1, stdin)) {
+ flag_1 = input_string[0];
+ flag_2 = input_string[2];
- else if(strncmp(cmd, "FFS", 3) == 0) {
- int ret = 0;
- char input_string[128];
- char flag_1, flag_2;
- int id = 0;
- char *stream_type = NULL;
- const char *user_data = "this is user data";
+ if (flag_1 == '0')
+ id = 0;
+ else if (flag_1 == '1')
+ id = 1;
+ else if (flag_1 == '2')
+ id = 2;
- fflush(stdin);
- g_print ("1. Media\n");
- g_print ("2. Alarm\n");
- g_print ("3. Notification\n");
- g_print ("4. Emergency\n");
- g_print ("5. Voice Information\n");
- g_print ("6. Ringtone\n");
- g_print ("7. Ringtone Call\n");
- g_print ("8. VOIP\n");
- g_print ("0. Voice Recognition\n");
- g_print("> select id and stream type: (eg. 0 3)");
+ if (flag_2 == '1')
+ reacquisition = true;
+ else if (flag_2 == '2')
+ reacquisition = false;
- if (fgets(input_string, sizeof(input_string)-1, stdin)) {
- flag_1 = input_string[0];
- flag_2 = input_string[2];
-
- if(flag_1 == '0') { id = 0; }
- else if(flag_1 == '1') { id = 1; }
- else if(flag_1 == '2') { id = 2; }
- else { id = 2; }
- if(flag_2 == '1') { stream_type = "media"; }
- else if(flag_2 == '2') { stream_type = "alarm"; }
- else if(flag_2 == '3') { stream_type = "notification"; }
- else if(flag_2 == '4') { stream_type = "emergency"; }
- else if(flag_2 == '5') { stream_type = "voice-information"; }
- else if(flag_2 == '6') { stream_type = "ringtone"; }
- else if(flag_2 == '7') { stream_type = "ringtone-call"; }
- else if(flag_2 == '8') { stream_type = "voip"; }
- else if(flag_2 == '0') { stream_type = "voice-recognition"; }
- else { stream_type = "media"; }
-
- ret = mm_sound_register_focus_for_session(id, getpid(), stream_type, (id == 0)? focus_cb0 : focus_cb1, (void*)user_data);
- if (ret) {
- g_print("failed to mm_sound_register_focus_for_session(), ret[0x%x]\n", ret);
- } else {
- g_print("id[%d], stream_type[%s], callback fun[%p]\n", id, stream_type, (id == 0)? focus_cb0 : focus_cb1);
- }
- } else {
- g_print ("### fgets return NULL\n");
- }
+ ret = mm_sound_set_focus_reacquisition(id, reacquisition);
+ if (ret)
+ g_print("failed to mm_sound_disable_focus_reacquirement(), ret[0x%x]\n", ret);
+ } else {
+ g_print("### fgets return NULL\n");
}
+ }
- else if(strncmp(cmd, "UF", 2) == 0) {
- int ret = 0;
- char input_string[128];
- char flag_1;
- int id = 0;
- fflush(stdin);
- g_print("> select id:");
- if (fgets(input_string, sizeof(input_string)-1, stdin)) {
- flag_1 = input_string[0];
- if(flag_1 == '0') { id = 0; }
- else if(flag_1 == '1') { id = 1; }
- else if(flag_1 == '2') { id = 2; }
- else { id = 2; }
- ret = mm_sound_unregister_focus(id);
- if (ret) {
- g_print("failed to mm_sound_unregister_focus(), ret[0x%x]\n", ret);
- }
- } else {
- g_print ("### fgets return NULL\n");
- }
- }
+ else if (strncmp(cmd, "AF", 2) == 0) {
+ int ret = 0;
+ char input_string[128];
+ char flag_1, flag_2;
+ int id = 0;
+ mm_sound_focus_type_e type = FOCUS_FOR_PLAYBACK;
+ fflush(stdin);
+ g_print("1. focus for playback\n");
+ g_print("2. focus for recording\n");
+ g_print("3. focus for both\n");
+ g_print("> select id and focus_type: (eg. 0 1)");
+ if (fgets(input_string, sizeof(input_string)-1, stdin)) {
+ flag_1 = input_string[0];
+ flag_2 = input_string[2];
- else if(strncmp(cmd, "DF", 2) == 0) {
- int ret = 0;
- char input_string[128];
- char flag_1, flag_2;
- int id = 0;
- bool reacquisition = true;
- fflush(stdin);
- g_print ("1. enable auto reacquirement\n");
- g_print ("2. disable auto reacquirement\n");
- g_print("> select id and option: (eg. 0 1)");
- if (fgets(input_string, sizeof(input_string)-1, stdin)) {
- flag_1 = input_string[0];
- flag_2 = input_string[2];
-
- if(flag_1 == '0') { id = 0; }
- else if(flag_1 == '1') { id = 1; }
- else if(flag_1 == '2') { id = 2; }
- else { id = 2; }
-
- if(flag_2 == '1') { reacquisition = true; }
- else if(flag_2 == '2') { reacquisition = false; }
- else { reacquisition = true; }
- ret = mm_sound_set_focus_reacquisition(id, reacquisition);
- if (ret) {
- g_print("failed to mm_sound_disable_focus_reacquirement(), ret[0x%x]\n", ret);
- }
- } else {
- g_print ("### fgets return NULL\n");
- }
- }
+ if (flag_1 == '0')
+ id = 0;
+ else if (flag_1 == '1')
+ id = 1;
+ else
+ id = 2;
- else if(strncmp(cmd, "AF", 2) == 0) {
- int ret = 0;
- char input_string[128];
- char flag_1, flag_2;
- int id = 0;
- mm_sound_focus_type_e type = FOCUS_FOR_PLAYBACK;
- fflush(stdin);
- g_print ("1. focus for playback\n");
- g_print ("2. focus for recording\n");
- g_print ("3. focus for both\n");
- g_print("> select id and focus_type: (eg. 0 1)");
- if (fgets(input_string, sizeof(input_string)-1, stdin)) {
- flag_1 = input_string[0];
- flag_2 = input_string[2];
-
- if(flag_1 == '0') { id = 0; }
- else if(flag_1 == '1') { id = 1; }
- else { id = 2; }
-
- if(flag_2 == '1') { type = FOCUS_FOR_PLAYBACK; }
- else if(flag_2 == '2') { type = FOCUS_FOR_CAPTURE; }
- else { type = FOCUS_FOR_BOTH; }
- ret = mm_sound_acquire_focus(id, type, "additional_info. for acquire");
- if (ret) {
- g_print("failed to mm_sound_acquire_focus(), ret[0x%x]\n", ret);
- }
- } else {
- g_print ("### fgets return NULL\n");
- }
- }
+ if (flag_2 == '1')
+ type = FOCUS_FOR_PLAYBACK;
+ else if (flag_2 == '2')
+ type = FOCUS_FOR_CAPTURE;
+ else
+ type = FOCUS_FOR_BOTH;
+ ret = mm_sound_acquire_focus(id, type, "additional_info. for acquire");
+ if (ret)
+ g_print("failed to mm_sound_acquire_focus(), ret[0x%x]\n", ret);
- else if(strncmp(cmd, "RF", 2) == 0) {
- int ret = 0;
- char input_string[128];
- char flag_1, flag_2;
- int id = 0;
- mm_sound_focus_type_e type = FOCUS_FOR_PLAYBACK;
- fflush(stdin);
- g_print ("1. focus for playback\n");
- g_print ("2. focus for recording\n");
- g_print ("3. focus for all\n");
- g_print("> select id and focus_type: (eg. 0 1)");
- if (fgets(input_string, sizeof(input_string)-1, stdin)) {
- flag_1 = input_string[0];
- flag_2 = input_string[2];
-
- if(flag_1 == '0') { id = 0; }
- else if(flag_1 == '1') { id = 1; }
- else { id = 2; }
-
- if(flag_2 == '1') { type = FOCUS_FOR_PLAYBACK; }
- else if(flag_2 == '2') { type = FOCUS_FOR_CAPTURE; }
- else { type = FOCUS_FOR_BOTH; }
- ret = mm_sound_release_focus(id, type, "additional_info. for release");
- if (ret) {
- g_print("failed to mm_sound_release_focus(), ret[0x%x]\n", ret);
- }
- } else {
- g_print ("### fgets return NULL\n");
- }
+ } else {
+ g_print("### fgets return NULL\n");
}
- else if(strncmp(cmd, "WFS", 3) == 0) {
- int ret = 0;
- char input_string[128];
- char flag_1;
- int type = 0;
- const char *user_data = "this is user data for watch";
+ } else if (strncmp(cmd, "RF", 2) == 0) {
+ int ret = 0;
+ char input_string[128];
+ char flag_1, flag_2;
+ int id = 0;
+ mm_sound_focus_type_e type = FOCUS_FOR_PLAYBACK;
+ fflush(stdin);
+ g_print("1. focus for playback\n");
+ g_print("2. focus for recording\n");
+ g_print("3. focus for all\n");
+ g_print("> select id and focus_type: (eg. 0 1)");
+ if (fgets(input_string, sizeof(input_string)-1, stdin)) {
+ flag_1 = input_string[0];
+ flag_2 = input_string[2];
- fflush(stdin);
- g_print ("1. playback\n");
- g_print ("2. recording\n");
- g_print ("3. both\n");
- g_print("> select interest focus type:");
+ if (flag_1 == '0')
+ id = 0;
+ else if (flag_1 == '1')
+ id = 1;
+ else
+ id = 2;
- if (fgets(input_string, sizeof(input_string)-1, stdin)) {
- flag_1 = input_string[0];
-
- if(flag_1 == '1') { type = 1; }
- else if(flag_1 == '2') { type = 2; }
- else if(flag_1 == '3') { type = 3; }
- else { type = 1; }
- ret = mm_sound_set_focus_watch_callback_for_session(getpid(), type, focus_watch_cb, (void*)user_data, &g_focus_watch_index);
- if (ret) {
- g_print("failed to mm_sound_set_focus_watch_callback(), ret[0x%x]\n", ret);
- } else {
- g_print("index[%d], type[%d], callback fun[%p]\n", g_focus_watch_index, type, focus_watch_cb);
- }
- } else {
- g_print ("### fgets return NULL\n");
- }
+ if (flag_2 == '1')
+ type = FOCUS_FOR_PLAYBACK;
+ else if (flag_2 == '2')
+ type = FOCUS_FOR_CAPTURE;
+ else
+ type = FOCUS_FOR_BOTH;
+ ret = mm_sound_release_focus(id, type, "additional_info. for release");
+ if (ret)
+ g_print("failed to mm_sound_release_focus(), ret[0x%x]\n", ret);
+
+ } else {
+ g_print("### fgets return NULL\n");
}
- else if(strncmp(cmd, "WS", 2) == 0) {
- int ret = 0;
- char input_string[128];
- char flag_1;
- int type = 0;
- const char *user_data = "this is user data for watch";
+ } else if (strncmp(cmd, "WS", 2) == 0) {
+ int ret = 0;
+ char input_string[128];
+ char flag_1;
+ int type = 0;
+ const char *user_data = "this is user data for watch";
- fflush(stdin);
- g_print ("1. playback\n");
- g_print ("2. recording\n");
- g_print ("3. both\n");
- g_print("> select interest focus type:");
+ fflush(stdin);
+ g_print("1. playback\n");
+ g_print("2. recording\n");
+ g_print("3. both\n");
+ g_print("> select interest focus type:");
- if (fgets(input_string, sizeof(input_string)-1, stdin)) {
- flag_1 = input_string[0];
-
- if(flag_1 == '1') { type = 1; }
- else if(flag_1 == '2') { type = 2; }
- else if(flag_1 == '3') { type = 3; }
- else { type = 1; }
- ret = mm_sound_set_focus_watch_callback(type, focus_watch_cb, (void*)user_data, &g_focus_watch_index);
- if (ret) {
- g_print("failed to mm_sound_set_focus_watch_callback(), ret[0x%x]\n", ret);
- } else {
- g_print("index[%d], type[%d], callback fun[%p]\n", g_focus_watch_index, type, focus_watch_cb);
- }
- } else {
- g_print ("### fgets return NULL\n");
- }
- }
+ if (fgets(input_string, sizeof(input_string)-1, stdin)) {
+ flag_1 = input_string[0];
- else if(strncmp(cmd, "WU", 2) == 0) {
- int ret = 0;
- ret = mm_sound_unset_focus_watch_callback(g_focus_watch_index);
- if (ret) {
- g_print("failed to mm_sound_unset_focus_watch_callback(), ret[0x%x]\n", ret);
- }
+ if (flag_1 == '1')
+ type = 1;
+ else if (flag_1 == '2')
+ type = 2;
+ else if (flag_1 == '3')
+ type = 3;
+ else
+ type = 1;
+ ret = mm_sound_set_focus_watch_callback(type, focus_watch_cb, (void*)user_data, &g_focus_watch_index);
+ if (ret)
+ g_print("failed to mm_sound_set_focus_watch_callback(), ret[0x%x]\n", ret);
+ else
+ g_print("index[%d], type[%d], callback fun[%p]\n", g_focus_watch_index, type, focus_watch_cb);
+ } else {
+ g_print("### fgets return NULL\n");
}
- else if(strncmp(cmd, "k", 1) == 0)
-#else
- if(strncmp(cmd, "k", 1) == 0)
-#endif
- {
- ret = mm_sound_play_keysound(KEYTONE_FILE, 0);
- if(ret < 0)
- debug_log("keysound play failed with 0x%x", ret);
- }
- else if (strcmp(cmd, "dbus-m") == 0) {
- int ret = 0;
- int a = 3;
- int b = 4;
- int result_val = 0;
- g_print("dbus method test call\n");
- ret = mm_sound_test(a, b, &result_val);
- if (ret) {
+ } else if (strncmp(cmd, "WU", 2) == 0) {
+ int ret = 0;
+ ret = mm_sound_unset_focus_watch_callback(g_focus_watch_index);
+ if (ret)
+ g_print("failed to mm_sound_unset_focus_watch_callback(), ret[0x%x]\n", ret);
+ } else if (strncmp(cmd, "k", 1) == 0) {
+ ret = mm_sound_play_keysound(KEYTONE_FILE, 0);
+ if (ret < 0)
+ debug_log("keysound play failed with 0x%x", ret);
+ } else if (strcmp(cmd, "dbus-m") == 0) {
+ int ret = 0;
+ int a = 3;
+ int b = 4;
+ int result_val = 0;
+ g_print("dbus method test call\n");
+ ret = mm_sound_test(a, b, &result_val);
+ if (ret)
g_print("failed to mm_sound_test(), ret[0x%x]\n", ret);
- } else {
+ else
g_print("Got answer : %d\n", result_val);
- }
- } else if (strcmp(cmd, "dbus-a") == 0) {
- int ret = 0;
- int user_data = 3;
- g_print("dbus method test add callback\n");
- g_print("my testsuite pid : %u tid : %ld\n", getpid(), pthread_self());
- ret = mm_sound_add_test_callback(mm_sound_test_cb1, (void *)user_data, &g_subs_id_test);
- if (ret) {
+
+ } else if (strcmp(cmd, "dbus-a") == 0) {
+ int ret = 0;
+ int user_data = 3;
+ g_print("dbus method test add callback\n");
+ g_print("my testsuite pid : %u tid : %ld\n", getpid(), pthread_self());
+ ret = mm_sound_add_test_callback(mm_sound_test_cb1, (void *)user_data, &g_subs_id_test);
+ if (ret)
g_print("failed to mm_sound_add_test_callback(), ret[0x%x]\n", ret);
- } else {
+ else
g_print("add test callback success\n");
- }
- } else if (strcmp(cmd, "dbus-r") == 0) {
- int ret = 0;
- g_print("dbus method test remove callback\n");
- ret = mm_sound_remove_test_callback(g_subs_id_test);
- if (ret) {
+
+ } else if (strcmp(cmd, "dbus-r") == 0) {
+ int ret = 0;
+ g_print("dbus method test remove callback\n");
+ ret = mm_sound_remove_test_callback(g_subs_id_test);
+ if (ret)
g_print("failed to mm_sound_remove_test_callback(), ret[0x%x]\n", ret);
- } else {
+ else
g_print("remove test callback success\n");
- }
- }
- else if(strncmp(cmd, "q", 1) == 0)
- {//get media volume
- unsigned int value = 100;
- ret = mm_sound_volume_get_value(g_volume_type, &value);
- if(ret < 0) {
- debug_log("mm_sound_volume_get_value 0x%x", ret);
- }
- else{
- g_print("*** MEDIA VOLUME : %u ***\n", value);
- g_volume_value = value;
- }
- }
- else if(strncmp(cmd, "e", 1) == 0)
- {//set media volume down
- unsigned int value = 100;
- ret = mm_sound_volume_get_value(g_volume_type, &value);
- if(ret < 0) {
- debug_log("mm_sound_volume_get_value 0x%x", ret);
- }
- else {
- if(value != 0) {
- value--;
- }
- ret = mm_sound_volume_set_value(g_volume_type, value);
- if(ret < 0) {
- debug_log("mm_sound_volume_set_value 0x%x", ret);
- }
- }
- }
- else if(strncmp(cmd, "r", 1) == 0)
- {//get media volume
- unsigned int value = 100;
- ret = mm_sound_volume_get_value(VOLUME_TYPE_SYSTEM, &value);
- if(ret < 0) {
- debug_log("mm_sound_volume_get_value 0x%x", ret);
- }
- else{
- g_print("*** SYSTEM VOLUME : %u ***\n", value);
- g_volume_value = value;
- }
+ } else if (strncmp(cmd, "q", 1) == 0) {
+ unsigned int value = 100;
+ ret = mm_sound_volume_get_value(g_volume_type, &value);
+ if (ret < 0) {
+ debug_log("mm_sound_volume_get_value 0x%x", ret);
+ } else {
+ g_print("*** MEDIA VOLUME : %u ***\n", value);
+ g_volume_value = value;
}
- else if(strncmp(cmd, "y", 1) == 0)
- {//set media volume down
- unsigned int value = 100;
- ret = mm_sound_volume_get_value(VOLUME_TYPE_SYSTEM, &value);
- if(ret < 0) {
- debug_log("mm_sound_volume_get_value 0x%x", ret);
- }
- else {
- if(value != 0) {
- value--;
- }
- ret = mm_sound_volume_set_value(VOLUME_TYPE_SYSTEM, value);
- if(ret < 0) {
- debug_log("mm_sound_volume_set_value 0x%x", ret);
- }else {
- g_print("Current System volume is %d\n", value);
- }
- }
- }
- else if(strncmp(cmd, "g", 1) == 0)
- {//get voice volume
- unsigned int value = 100;
- ret = mm_sound_volume_get_value(VOLUME_TYPE_VOICE, &value);
- if(ret < 0) {
- debug_log("mm_sound_volume_get_value 0x%x", ret);
- }
- else{
- g_print("*** VOICE VOLUME : %u ***\n", value);
- g_volume_value = value;
- }
+ } else if (strncmp(cmd, "e", 1) == 0) {
+ unsigned int value = 100;
+ ret = mm_sound_volume_get_value(g_volume_type, &value);
+ if (ret < 0) {
+ debug_log("mm_sound_volume_get_value 0x%x", ret);
+ } else {
+ if (value != 0)
+ value--;
+ ret = mm_sound_volume_set_value(g_volume_type, value);
+ if (ret < 0)
+ debug_log("mm_sound_volume_set_value 0x%x", ret);
}
- else if(strncmp(cmd, "j", 1) == 0)
- {//set voice volume down
- unsigned int value = 100;
- ret = mm_sound_volume_get_value(VOLUME_TYPE_VOICE, &value);
- if(ret < 0) {
- debug_log("mm_sound_volume_get_value 0x%x", ret);
- }
- else {
- if(value != 0) {
- value--;
- }
- ret = mm_sound_volume_set_value(VOLUME_TYPE_VOICE, value);
- if(ret < 0) {
- debug_log("mm_sound_volume_set_value 0x%x", ret);
- }else {
- g_print("Current Voice volume is %d\n", value);
- }
- }
- }
- else if(strncmp(cmd, "an", 2) == 0)
- {
- debug_log("volume is %d type, %d", g_volume_type, g_volume_value);
- ret = mm_sound_play_sound(g_file_name, g_volume_type, mycallback ,"USERDATA", &handle);
- if(ret < 0)
- debug_log("mm_sound_play_sound() failed with 0x%x", ret);
+ } else if (strncmp(cmd, "r", 1) == 0) {
+ unsigned int value = 100;
+ ret = mm_sound_volume_get_value(VOLUME_TYPE_SYSTEM, &value);
+ if (ret < 0) {
+ debug_log("mm_sound_volume_get_value 0x%x", ret);
+ } else {
+ g_print("*** SYSTEM VOLUME : %u ***\n", value);
+ g_volume_value = value;
}
- else if(strncmp(cmd, "as", 2) == 0)
- {
- debug_log("stream %s type, %d", "media", g_volume_value);
- ret = mm_sound_play_sound_with_stream_info(g_file_name, "media", -1, 1, mycallback ,"USERDATA", &handle);
- if(ret < 0)
- debug_log("mm_sound_play_sound() failed with 0x%x", ret);
+
+ } else if (strncmp(cmd, "y", 1) == 0) {
+ unsigned int value = 100;
+ ret = mm_sound_volume_get_value(VOLUME_TYPE_SYSTEM, &value);
+ if (ret < 0) {
+ debug_log("mm_sound_volume_get_value 0x%x", ret);
+ } else {
+ if (value != 0)
+ value--;
+
+ ret = mm_sound_volume_set_value(VOLUME_TYPE_SYSTEM, value);
+ if (ret < 0)
+ debug_log("mm_sound_volume_set_value 0x%x", ret);
+ else
+ g_print("Current System volume is %d\n", value);
}
- else if(strncmp(cmd, "A", 1) == 0)
- {
- debug_log("volume is %d type, %d", g_volume_type, g_volume_value);
- ret = mm_sound_play_loud_solo_sound(g_file_name, g_volume_type, mycallback ,"USERDATA", &handle);
- if(ret < 0)
- debug_log("mm_sound_play_sound_loud_solo() failed with 0x%x", ret);
+
+ } else if (strncmp(cmd, "g", 1) == 0) {
+ unsigned int value = 100;
+ ret = mm_sound_volume_get_value(VOLUME_TYPE_VOICE, &value);
+ if (ret < 0) {
+ debug_log("mm_sound_volume_get_value 0x%x", ret);
+ } else {
+ g_print("*** VOICE VOLUME : %u ***\n", value);
+ g_volume_value = value;
}
- else if(strncmp(cmd, "FN", 2) == 0)
- {
- char num = 0;
- char input_string[128] = "";
- char *tok = NULL;
- char *ptr = NULL;
- int tonetime=0;
- double volume=1.0;
- int volume_type = -1;
- bool enable_session = 0;
- MMSoundTone_t tone = MM_SOUND_TONE_DTMF_0;
-
- while(num != 'q') {
- fflush(stdin);
- g_print("enter number(0~H exit:q), volume type(0~7), volume(0.0~1.0), time(ms), enable_session(0:unable , 1:enable):\t ");
- if (fgets(input_string, sizeof(input_string)-1, stdin)) {
- tok = strtok_r(input_string, " ", &ptr);
- if(!tok) continue;
- if(tok[0] == 'q') {
- break;
- }
- else if(tok[0] < '0' || tok[0] > '~') {
- if(tok[0] == '*' || tok[0] == '#')
- ;
- else
- continue;
- }
- num = tok[0];
- if(num >= '0' && num <= '9') {
- tone = (MMSoundTone_t)(num - '0');
- }
- else if(num == '*') {
- tone = MM_SOUND_TONE_DTMF_S;
- }
- else if(num == '#') {
- tone =MM_SOUND_TONE_DTMF_P;
- }
- else if(num == 'A') { tone = MM_SOUND_TONE_DTMF_A; }
- else if(num == 'B') { tone = MM_SOUND_TONE_DTMF_B; }
- else if(num == 'C') { tone = MM_SOUND_TONE_DTMF_C; }
- else if(num == 'D') { tone = MM_SOUND_TONE_DTMF_D; }
- else if(num == 'E') { tone = MM_SOUND_TONE_SUP_DIAL; }
- else if(num == 'F') { tone = MM_SOUND_TONE_ANSI_DIAL; }
- else if(num == 'G') { tone = MM_SOUND_TONE_JAPAN_DIAL; }
- else if(num == 'H') { tone = MM_SOUND_TONE_SUP_BUSY; }
- else if(num == 'I') { tone = MM_SOUND_TONE_ANSI_BUSY; }
- else if(num == 'J') { tone = MM_SOUND_TONE_JAPAN_BUSY; }
- else if(num == 'K') { tone = MM_SOUND_TONE_SUP_CONGESTION; }
- else if(num == 'L') { tone = MM_SOUND_TONE_ANSI_CONGESTION; }
- else if(num == 'M') { tone = MM_SOUND_TONE_SUP_RADIO_ACK; }
- else if(num == 'N') { tone = MM_SOUND_TONE_JAPAN_RADIO_ACK; }
- else if(num == 'O') { tone = MM_SOUND_TONE_SUP_RADIO_NOTAVAIL; }
- else if(num == 'P') { tone = MM_SOUND_TONE_SUP_ERROR; }
- else if(num == 'Q') { tone = MM_SOUND_TONE_SUP_CALL_WAITING; }
- else if(num == 'R') { tone = MM_SOUND_TONE_ANSI_CALL_WAITING; }
- else if(num == 'S') { tone = MM_SOUND_TONE_SUP_RINGTONE; }
- else if(num == 'T') { tone = MM_SOUND_TONE_ANSI_RINGTONE; }
- else if(num == 'U') { tone = MM_SOUND_TONE_PROP_BEEP; }
- else if(num == 'V') { tone = MM_SOUND_TONE_PROP_ACK; }
- else if(num == 'W') { tone = MM_SOUND_TONE_PROP_NACK; }
- else if(num == 'X') { tone = MM_SOUND_TONE_PROP_PROMPT; }
- else if(num == 'Y') { tone = MM_SOUND_TONE_PROP_BEEP2; }
- else if(num == 'Z') { tone =MM_SOUND_TONE_CDMA_HIGH_SLS; }
- else if(num == '[') { tone = MM_SOUND_TONE_CDMA_MED_SLS; }
- else if(num == ']') { tone = MM_SOUND_TONE_CDMA_LOW_SLS; }
- else if(num == '^') { tone =MM_SOUND_TONE_CDMA_HIGH_S_X4; }
- else if(num == '_') { tone =MM_SOUND_TONE_CDMA_MED_S_X4; }
- else if(num == 'a') { tone =MM_SOUND_TONE_CDMA_LOW_S_X4; }
- else if(num == 'b') { tone =MM_SOUND_TONE_CDMA_HIGH_PBX_L; }
- else if(num == 'c') { tone =MM_SOUND_TONE_CDMA_MED_PBX_L; }
- else if(num == 'd') { tone =MM_SOUND_TONE_CDMA_LOW_PBX_L; }
- else if(num == 'e') { tone =MM_SOUND_TONE_CDMA_HIGH_PBX_SS; }
- else if(num == 'f') { tone =MM_SOUND_TONE_CDMA_MED_PBX_SS; }
- else if(num == 'g') { tone =MM_SOUND_TONE_CDMA_LOW_PBX_SS; }
- else if(num == 'h') { tone =MM_SOUND_TONE_CDMA_HIGH_PBX_SSL; }
- else if(num == 'i') { tone =MM_SOUND_TONE_CDMA_MED_PBX_SSL; }
- else if(num == 'j') { tone =MM_SOUND_TONE_CDMA_LOW_PBX_SSL; }
- else if(num == 'k') { tone =MM_SOUND_TONE_CDMA_HIGH_PBX_SLS; }
- else if(num == 'l') { tone =MM_SOUND_TONE_CDMA_MED_PBX_SLS; }
- else if(num == 'm') { tone =MM_SOUND_TONE_CDMA_LOW_PBX_SLS; }
- else if(num == 'n') { tone =MM_SOUND_TONE_CDMA_HIGH_PBX_S_X4; }
- else if(num == 'o') { tone =MM_SOUND_TONE_CDMA_MED_PBX_S_X4; }
- else if(num == 'p') { tone =MM_SOUND_TONE_CDMA_LOW_PBX_S_X4; }
- else if(num == 'q') { tone =MM_SOUND_TONE_CDMA_ALERT_NETWORK_LITE; }
- else if(num == 'r') { tone =MM_SOUND_TONE_CDMA_ALERT_AUTOREDIAL_LITE; }
- else if(num == 's') { tone =MM_SOUND_TONE_CDMA_ONE_MIN_BEEP; }
- else if(num == 't') { tone =MM_SOUND_TONE_CDMA_KEYPAD_VOLUME_KEY_LITE; }
- else if(num == 'u') { tone =MM_SOUND_TONE_CDMA_PRESSHOLDKEY_LITE; }
- else if(num == 'v') { tone =MM_SOUND_TONE_CDMA_ALERT_INCALL_LITE; }
- else if(num == 'w') { tone =MM_SOUND_TONE_CDMA_EMERGENCY_RINGBACK; }
- else if(num == 'x') { tone =MM_SOUND_TONE_CDMA_ALERT_CALL_GUARD; }
- else if(num == 'y') { tone =MM_SOUND_TONE_CDMA_SOFT_ERROR_LITE; }
- else if(num == 'z') { tone =MM_SOUND_TONE_CDMA_CALLDROP_LITE; }
- else if(num == '{') { tone =MM_SOUND_TONE_LOW_FRE; }
- else if(num == '}') { tone =MM_SOUND_TONE_MED_FRE; }
- else if(num == '~') { tone =MM_SOUND_TONE_HIGH_FRE; }
- tok = strtok_r(NULL, " ", &ptr);
- if(tok) volume_type = (double)atoi(tok);
-
- tok = strtok_r(NULL, " ", &ptr);
- if(tok) volume = (double)atof(tok);
-
- tok = strtok_r(NULL, " ", &ptr);
- if(tok)
- {
- tonetime = atoi(tok);
- }
- else
- {
- tonetime = MIN_TONE_PLAY_TIME;
- }
- tok = strtok_r(NULL, " ", &ptr);
- if(tok) enable_session = (bool)atof(tok);
+ } else if (strncmp(cmd, "j", 1) == 0) {
+ unsigned int value = 100;
+ ret = mm_sound_volume_get_value(VOLUME_TYPE_VOICE, &value);
+ if (ret < 0) {
+ debug_log("mm_sound_volume_get_value 0x%x", ret);
+ } else {
+ if (value != 0)
+ value--;
- debug_log("volume type: %d\t volume is %f\t tonetime: %d\t enable_session %d ", volume_type, volume, tonetime, enable_session);
- ret = mm_sound_play_tone_ex(tone, volume_type, volume, tonetime, &handle, enable_session);
- if(ret<0)
- debug_log ("[magpie] Play DTMF sound cannot be played ! %d\n", handle);
- } else {
- g_print ("### fgets return NULL\n");
- }
- }
+ ret = mm_sound_volume_set_value(VOLUME_TYPE_VOICE, value);
+ if (ret < 0)
+ debug_log("mm_sound_volume_set_value 0x%x", ret);
+ else
+ g_print("Current Voice volume is %d\n", value);
}
- else if(strncmp(cmd, "FS", 2) == 0)
- {
- char num = 0;
- char input_string[128] = "";
- char *tok = NULL;
- char *ptr = NULL;
- char *stream_type = NULL;
- int tonetime=0;
- double volume=1.0;
- MMSoundTone_t tone = MM_SOUND_TONE_DTMF_0;
-
- while(num != 'q') {
- fflush(stdin);
- g_print("enter number(0~H exit:q), stream type(media, system, ...), volume(0.0~1.0), time(ms):\t ");
- if (fgets(input_string, sizeof(input_string)-1, stdin)) {
- tok = strtok_r(input_string, " ", &ptr);
- if(!tok) continue;
- if(tok[0] == 'q') {
- break;
- }
- else if(tok[0] < '0' || tok[0] > '~') {
- if(tok[0] == '*' || tok[0] == '#')
- ;
- else
- continue;
- }
- num = tok[0];
- if(num >= '0' && num <= '9') {
- tone = (MMSoundTone_t)(num - '0');
- }
- else if(num == '*') {
- tone = MM_SOUND_TONE_DTMF_S;
- }
- else if(num == '#') {
- tone =MM_SOUND_TONE_DTMF_P;
- }
- else if(num == 'A') { tone = MM_SOUND_TONE_DTMF_A; }
- else if(num == 'B') { tone = MM_SOUND_TONE_DTMF_B; }
- else if(num == 'C') { tone = MM_SOUND_TONE_DTMF_C; }
- else if(num == 'D') { tone = MM_SOUND_TONE_DTMF_D; }
- else if(num == 'E') { tone = MM_SOUND_TONE_SUP_DIAL; }
- else if(num == 'F') { tone = MM_SOUND_TONE_ANSI_DIAL; }
- else if(num == 'G') { tone = MM_SOUND_TONE_JAPAN_DIAL; }
- else if(num == 'H') { tone = MM_SOUND_TONE_SUP_BUSY; }
- else if(num == 'I') { tone = MM_SOUND_TONE_ANSI_BUSY; }
- else if(num == 'J') { tone = MM_SOUND_TONE_JAPAN_BUSY; }
- else if(num == 'K') { tone = MM_SOUND_TONE_SUP_CONGESTION; }
- else if(num == 'L') { tone = MM_SOUND_TONE_ANSI_CONGESTION; }
- else if(num == 'M') { tone = MM_SOUND_TONE_SUP_RADIO_ACK; }
- else if(num == 'N') { tone = MM_SOUND_TONE_JAPAN_RADIO_ACK; }
- else if(num == 'O') { tone = MM_SOUND_TONE_SUP_RADIO_NOTAVAIL; }
- else if(num == 'P') { tone = MM_SOUND_TONE_SUP_ERROR; }
- else if(num == 'Q') { tone = MM_SOUND_TONE_SUP_CALL_WAITING; }
- else if(num == 'R') { tone = MM_SOUND_TONE_ANSI_CALL_WAITING; }
- else if(num == 'S') { tone = MM_SOUND_TONE_SUP_RINGTONE; }
- else if(num == 'T') { tone = MM_SOUND_TONE_ANSI_RINGTONE; }
- else if(num == 'U') { tone = MM_SOUND_TONE_PROP_BEEP; }
- else if(num == 'V') { tone = MM_SOUND_TONE_PROP_ACK; }
- else if(num == 'W') { tone = MM_SOUND_TONE_PROP_NACK; }
- else if(num == 'X') { tone = MM_SOUND_TONE_PROP_PROMPT; }
- else if(num == 'Y') { tone = MM_SOUND_TONE_PROP_BEEP2; }
- else if(num == 'Z') { tone =MM_SOUND_TONE_CDMA_HIGH_SLS; }
- else if(num == '[') { tone = MM_SOUND_TONE_CDMA_MED_SLS; }
- else if(num == ']') { tone = MM_SOUND_TONE_CDMA_LOW_SLS; }
- else if(num == '^') { tone =MM_SOUND_TONE_CDMA_HIGH_S_X4; }
- else if(num == '_') { tone =MM_SOUND_TONE_CDMA_MED_S_X4; }
- else if(num == 'a') { tone =MM_SOUND_TONE_CDMA_LOW_S_X4; }
- else if(num == 'b') { tone =MM_SOUND_TONE_CDMA_HIGH_PBX_L; }
- else if(num == 'c') { tone =MM_SOUND_TONE_CDMA_MED_PBX_L; }
- else if(num == 'd') { tone =MM_SOUND_TONE_CDMA_LOW_PBX_L; }
- else if(num == 'e') { tone =MM_SOUND_TONE_CDMA_HIGH_PBX_SS; }
- else if(num == 'f') { tone =MM_SOUND_TONE_CDMA_MED_PBX_SS; }
- else if(num == 'g') { tone =MM_SOUND_TONE_CDMA_LOW_PBX_SS; }
- else if(num == 'h') { tone =MM_SOUND_TONE_CDMA_HIGH_PBX_SSL; }
- else if(num == 'i') { tone =MM_SOUND_TONE_CDMA_MED_PBX_SSL; }
- else if(num == 'j') { tone =MM_SOUND_TONE_CDMA_LOW_PBX_SSL; }
- else if(num == 'k') { tone =MM_SOUND_TONE_CDMA_HIGH_PBX_SLS; }
- else if(num == 'l') { tone =MM_SOUND_TONE_CDMA_MED_PBX_SLS; }
- else if(num == 'm') { tone =MM_SOUND_TONE_CDMA_LOW_PBX_SLS; }
- else if(num == 'n') { tone =MM_SOUND_TONE_CDMA_HIGH_PBX_S_X4; }
- else if(num == 'o') { tone =MM_SOUND_TONE_CDMA_MED_PBX_S_X4; }
- else if(num == 'p') { tone =MM_SOUND_TONE_CDMA_LOW_PBX_S_X4; }
- else if(num == 'q') { tone =MM_SOUND_TONE_CDMA_ALERT_NETWORK_LITE; }
- else if(num == 'r') { tone =MM_SOUND_TONE_CDMA_ALERT_AUTOREDIAL_LITE; }
- else if(num == 's') { tone =MM_SOUND_TONE_CDMA_ONE_MIN_BEEP; }
- else if(num == 't') { tone =MM_SOUND_TONE_CDMA_KEYPAD_VOLUME_KEY_LITE; }
- else if(num == 'u') { tone =MM_SOUND_TONE_CDMA_PRESSHOLDKEY_LITE; }
- else if(num == 'v') { tone =MM_SOUND_TONE_CDMA_ALERT_INCALL_LITE; }
- else if(num == 'w') { tone =MM_SOUND_TONE_CDMA_EMERGENCY_RINGBACK; }
- else if(num == 'x') { tone =MM_SOUND_TONE_CDMA_ALERT_CALL_GUARD; }
- else if(num == 'y') { tone =MM_SOUND_TONE_CDMA_SOFT_ERROR_LITE; }
- else if(num == 'z') { tone =MM_SOUND_TONE_CDMA_CALLDROP_LITE; }
- else if(num == '{') { tone =MM_SOUND_TONE_LOW_FRE; }
- else if(num == '}') { tone =MM_SOUND_TONE_MED_FRE; }
- else if(num == '~') { tone =MM_SOUND_TONE_HIGH_FRE; }
-
- stream_type = strtok_r(NULL, " ", &ptr);
-
- tok = strtok_r(NULL, " ", &ptr);
- if(tok) volume = (double)atof(tok);
-
- tok = strtok_r(NULL, " ", &ptr);
- if(tok)
- {
- tonetime = atoi(tok);
- }
- else
- {
- tonetime = MIN_TONE_PLAY_TIME;
- }
- debug_log("stream type: %s\t volume is %f\t tonetime: %d", stream_type, volume, tonetime);
- ret = mm_sound_play_tone_with_stream_info(tone, stream_type, -1, volume, tonetime, &handle);
- if(ret<0)
- debug_log ("[magpie] Play DTMF sound with stream type cannot be played ! %d", handle);
- } else {
- g_print ("### fgets return NULL\n");
+ } else if (strncmp(cmd, "as", 2) == 0) {
+ debug_log("stream %s type, %d", "media", g_volume_value);
+ ret = mm_sound_play_sound_with_stream_info(g_file_name, "media", -1, 1, mycallback, "USERDATA", &handle);
+ if (ret < 0)
+ debug_log("mm_sound_play_sound() failed with 0x%x", ret);
+
+ } else if (strncmp(cmd, "FS", 2) == 0) {
+ char num = 0;
+ char input_string[128] = "";
+ char *tok = NULL;
+ char *ptr = NULL;
+ char *stream_type = NULL;
+ int tonetime = 0;
+ double volume = 1.0;
+ MMSoundTone_t tone = MM_SOUND_TONE_DTMF_0;
+
+ while (num != 'q') {
+ fflush(stdin);
+ g_print("enter number(0~H exit:q), stream type(media, system, ...), volume(0.0~1.0), time(ms):\t ");
+ if (fgets(input_string, sizeof(input_string)-1, stdin)) {
+ tok = strtok_r(input_string, " ", &ptr);
+ if (!tok)
+ continue;
+ if (tok[0] == 'q') {
+ break;
+ } else if (tok[0] < '0' || tok[0] > '~') {
+ if (tok[0] != '*' && tok[0] != '#')
+ continue;
}
+ num = tok[0];
+ if (num >= '0' && num <= '9')
+ tone = (MMSoundTone_t)(num - '0');
+ else if (num == '*')
+ tone = MM_SOUND_TONE_DTMF_S;
+ else if (num == '#')
+ tone = MM_SOUND_TONE_DTMF_P;
+ else if (num == 'A')
+ tone = MM_SOUND_TONE_DTMF_A;
+ else if (num == 'B')
+ tone = MM_SOUND_TONE_DTMF_B;
+ else if (num == 'C')
+ tone = MM_SOUND_TONE_DTMF_C;
+ else if (num == 'D')
+ tone = MM_SOUND_TONE_DTMF_D;
+ else if (num == 'E')
+ tone = MM_SOUND_TONE_SUP_DIAL;
+ else if (num == 'F')
+ tone = MM_SOUND_TONE_ANSI_DIAL;
+ else if (num == 'G')
+ tone = MM_SOUND_TONE_JAPAN_DIAL;
+ else if (num == 'H')
+ tone = MM_SOUND_TONE_SUP_BUSY;
+ else if (num == 'I')
+ tone = MM_SOUND_TONE_ANSI_BUSY;
+ else if (num == 'J')
+ tone = MM_SOUND_TONE_JAPAN_BUSY;
+ else if (num == 'K')
+ tone = MM_SOUND_TONE_SUP_CONGESTION;
+ else if (num == 'L')
+ tone = MM_SOUND_TONE_ANSI_CONGESTION;
+ else if (num == 'M')
+ tone = MM_SOUND_TONE_SUP_RADIO_ACK;
+ else if (num == 'N')
+ tone = MM_SOUND_TONE_JAPAN_RADIO_ACK;
+ else if (num == 'O')
+ tone = MM_SOUND_TONE_SUP_RADIO_NOTAVAIL;
+ else if (num == 'P')
+ tone = MM_SOUND_TONE_SUP_ERROR;
+ else if (num == 'Q')
+ tone = MM_SOUND_TONE_SUP_CALL_WAITING;
+ else if (num == 'R')
+ tone = MM_SOUND_TONE_ANSI_CALL_WAITING;
+ else if (num == 'S')
+ tone = MM_SOUND_TONE_SUP_RINGTONE;
+ else if (num == 'T')
+ tone = MM_SOUND_TONE_ANSI_RINGTONE;
+ else if (num == 'U')
+ tone = MM_SOUND_TONE_PROP_BEEP;
+ else if (num == 'V')
+ tone = MM_SOUND_TONE_PROP_ACK;
+ else if (num == 'W')
+ tone = MM_SOUND_TONE_PROP_NACK;
+ else if (num == 'X')
+ tone = MM_SOUND_TONE_PROP_PROMPT;
+ else if (num == 'Y')
+ tone = MM_SOUND_TONE_PROP_BEEP2;
+ else if (num == 'Z')
+ tone = MM_SOUND_TONE_CDMA_HIGH_SLS;
+ else if (num == '[')
+ tone = MM_SOUND_TONE_CDMA_MED_SLS;
+ else if (num == ']')
+ tone = MM_SOUND_TONE_CDMA_LOW_SLS;
+ else if (num == '^')
+ tone = MM_SOUND_TONE_CDMA_HIGH_S_X4;
+ else if (num == '_')
+ tone = MM_SOUND_TONE_CDMA_MED_S_X4;
+ else if (num == 'a')
+ tone = MM_SOUND_TONE_CDMA_LOW_S_X4;
+ else if (num == 'b')
+ tone = MM_SOUND_TONE_CDMA_HIGH_PBX_L;
+ else if (num == 'c')
+ tone = MM_SOUND_TONE_CDMA_MED_PBX_L;
+ else if (num == 'd')
+ tone = MM_SOUND_TONE_CDMA_LOW_PBX_L;
+ else if (num == 'e')
+ tone = MM_SOUND_TONE_CDMA_HIGH_PBX_SS;
+ else if (num == 'f')
+ tone = MM_SOUND_TONE_CDMA_MED_PBX_SS;
+ else if (num == 'g')
+ tone = MM_SOUND_TONE_CDMA_LOW_PBX_SS;
+ else if (num == 'h')
+ tone = MM_SOUND_TONE_CDMA_HIGH_PBX_SSL;
+ else if (num == 'i')
+ tone = MM_SOUND_TONE_CDMA_MED_PBX_SSL;
+ else if (num == 'j')
+ tone = MM_SOUND_TONE_CDMA_LOW_PBX_SSL;
+ else if (num == 'k')
+ tone = MM_SOUND_TONE_CDMA_HIGH_PBX_SLS;
+ else if (num == 'l')
+ tone = MM_SOUND_TONE_CDMA_MED_PBX_SLS;
+ else if (num == 'm')
+ tone = MM_SOUND_TONE_CDMA_LOW_PBX_SLS;
+ else if (num == 'n')
+ tone = MM_SOUND_TONE_CDMA_HIGH_PBX_S_X4;
+ else if (num == 'o')
+ tone = MM_SOUND_TONE_CDMA_MED_PBX_S_X4;
+ else if (num == 'p')
+ tone = MM_SOUND_TONE_CDMA_LOW_PBX_S_X4;
+ else if (num == 'q')
+ tone = MM_SOUND_TONE_CDMA_ALERT_NETWORK_LITE;
+ else if (num == 'r')
+ tone = MM_SOUND_TONE_CDMA_ALERT_AUTOREDIAL_LITE;
+ else if (num == 's')
+ tone = MM_SOUND_TONE_CDMA_ONE_MIN_BEEP;
+ else if (num == 't')
+ tone = MM_SOUND_TONE_CDMA_KEYPAD_VOLUME_KEY_LITE;
+ else if (num == 'u')
+ tone = MM_SOUND_TONE_CDMA_PRESSHOLDKEY_LITE;
+ else if (num == 'v')
+ tone = MM_SOUND_TONE_CDMA_ALERT_INCALL_LITE;
+ else if (num == 'w')
+ tone = MM_SOUND_TONE_CDMA_EMERGENCY_RINGBACK;
+ else if (num == 'x')
+ tone = MM_SOUND_TONE_CDMA_ALERT_CALL_GUARD;
+ else if (num == 'y')
+ tone = MM_SOUND_TONE_CDMA_SOFT_ERROR_LITE;
+ else if (num == 'z')
+ tone = MM_SOUND_TONE_CDMA_CALLDROP_LITE;
+ else if (num == '{')
+ tone = MM_SOUND_TONE_LOW_FRE;
+ else if (num == '}')
+ tone = MM_SOUND_TONE_MED_FRE;
+ else if (num == '~')
+ tone = MM_SOUND_TONE_HIGH_FRE;
+
+ stream_type = strtok_r(NULL, " ", &ptr);
+
+ tok = strtok_r(NULL, " ", &ptr);
+ if (tok)
+ volume = (double)atof(tok);
+
+ tok = strtok_r(NULL, " ", &ptr);
+ if (tok)
+ tonetime = atoi(tok);
+ else
+ tonetime = MIN_TONE_PLAY_TIME;
+
+ debug_log("stream type: %s\t volume is %f\t tonetime: %d", stream_type, volume, tonetime);
+ ret = mm_sound_play_tone_with_stream_info(tone, stream_type, -1, volume, tonetime, &handle);
+ if (ret < 0)
+ debug_log("failed to mm_sound_play_tone_with_stream_info(), ret[0x%x]", ret);
+ } else {
+ g_print("### fgets return NULL\n");
}
}
- else if (strncmp (cmd, "b",1) == 0)
- {
- DIR *basedir;
- struct dirent *entry = NULL;
- struct dirent *prev_entry = NULL;
- int entry_len;
- int ret;
- struct stat file_stat;
- char fullpath[MAX_PATH_LEN]="";
- struct timespec start_time = {0,};
- struct timespec current_time = {0,};
-
- if(g_dir_name[strlen(g_dir_name)-1] == '/')
- g_dir_name[strlen(g_dir_name)-1] = '\0';
-
- basedir = opendir(g_dir_name);
- if(basedir != NULL)
- {
- entry_len = offsetof(struct dirent, d_name) + fpathconf(dirfd(basedir), MAX_STRING_LEN) + 1;
- prev_entry = malloc(entry_len);
-
- while (1)
- {
- int playfail = 0;
- int mywait = 0;
-
- ret = readdir_r(basedir, prev_entry, &entry);
- if (ret == 0)
- {
- debug_error("error on readdir_r(%s)", basedir);
- break;
- }
- if (entry == NULL)
- break;
-
- if(entry->d_name[0] == '.')
- continue;
- memset(fullpath, '\0' ,sizeof(fullpath));
- snprintf(fullpath, sizeof(fullpath)-1,"%s/%s", g_dir_name, entry->d_name);
- debug_log("Try %s", fullpath);
- if (lstat(fullpath, &file_stat) == -1)
- continue;
-
- if(S_ISREG(file_stat.st_mode))
- {
- test_callback_done = 0 ;
- start_time.tv_sec = (long int)(time(NULL));
- start_time.tv_nsec = 0;
- ret = mm_sound_play_sound(fullpath, g_volume_type, test_callback, NULL, &handle);
- if(ret != MM_ERROR_NONE)
- {
- debug_log("Play file error : %s", fullpath);
- sleep(4);
- playfail = 1;
- }
- }
- else
- {
- debug_log("this is not regular file : %s", fullpath);
+ } else if (strncmp(cmd, "b", 1) == 0) {
+ DIR *basedir;
+ struct dirent *entry = NULL;
+ struct dirent *prev_entry = NULL;
+ int entry_len;
+ int ret;
+ struct stat file_stat;
+ char fullpath[MAX_PATH_LEN] = "";
+ struct timespec start_time = {0,};
+ struct timespec current_time = {0,};
+
+ if (g_dir_name[strlen(g_dir_name)-1] == '/')
+ g_dir_name[strlen(g_dir_name)-1] = '\0';
+
+ basedir = opendir(g_dir_name);
+ if (basedir != NULL) {
+ entry_len = offsetof(struct dirent, d_name) + fpathconf(dirfd(basedir), MAX_STRING_LEN) + 1;
+ prev_entry = malloc(entry_len);
+
+ while (1) {
+ int playfail = 0;
+ int mywait = 0;
+
+ ret = readdir_r(basedir, prev_entry, &entry);
+ if (ret == 0) {
+ debug_error("error on readdir_r(%s)", basedir);
+ break;
+ }
+ if (entry == NULL)
+ break;
+
+ if (entry->d_name[0] == '.')
+ continue;
+ memset(fullpath, '\0', sizeof(fullpath));
+ snprintf(fullpath, sizeof(fullpath) - 1, "%s/%s", g_dir_name, entry->d_name);
+ debug_log("Try %s", fullpath);
+
+ if (lstat(fullpath, &file_stat) == -1)
+ continue;
+
+ if (S_ISREG(file_stat.st_mode)) {
+ test_callback_done = 0 ;
+ start_time.tv_sec = (long int)(time(NULL));
+ start_time.tv_nsec = 0;
+
+ ret = mm_sound_play_sound_with_stream_info(fullpath, "media", -1, 1, test_callback, "USERDATA", &handle);
+ if (ret != MM_ERROR_NONE) {
+ debug_log("Play file error : %s", fullpath);
+ sleep(4);
playfail = 1;
}
- while((test_callback_done == 0) && (playfail ==0))
- {
- current_time.tv_sec = (long int)(time(NULL));
- current_time.tv_nsec = 0;
- if(current_time.tv_sec - start_time.tv_sec > 200)
- {
- if((++mywait)%5 == 0)
- {
- debug_log("I'm waiting callback for %d seconds after play %s",
- (int)(current_time.tv_sec - start_time.tv_sec),
- fullpath);
- }
+ } else {
+ debug_log("this is not regular file : %s", fullpath);
+ playfail = 1;
+ }
+ while ((test_callback_done == 0) && (playfail == 0)) {
+ current_time.tv_sec = (long int)(time(NULL));
+ current_time.tv_nsec = 0;
+ if (current_time.tv_sec - start_time.tv_sec > 200) {
+ if ((++mywait)%5 == 0) {
+ debug_log("I'm waiting callback for %d seconds after play %s",
+ (int)(current_time.tv_sec - start_time.tv_sec), fullpath);
}
- sleep(2);
}
- debug_log("goto next file");
+ sleep(2);
}
- free(prev_entry);
- closedir(basedir);
+ debug_log("goto next file");
}
- else
- {
- debug_log("Cannot Open such a directory %s", g_dir_name);
- }
-
+ free(prev_entry);
+ closedir(basedir);
+ } else {
+ debug_log("Cannot Open such a directory %s", g_dir_name);
}
- else if (strncmp (cmd, "c",1) == 0)
- {
- soundparam.volume = g_volume_value;
- soundparam.loop = -1; /* loop case */
- soundparam.callback = mycallback;
- soundparam.data = NULL;
- soundparam.mem_ptr = NULL;
- soundparam.mem_size = 0;
- soundparam.filename = g_file_name;
- soundparam.volume_config = g_volume_type;
-
- if ((mm_sound_play_sound_ex (&soundparam, &handle))<0)
- debug_log ("Play EX sound cannot be played !");
-
- debug_log ("Ex sound is played Handle is [%d]", handle);
- }
- else if (strncmp (cmd, "f",1) == 0) {
- g_menu_state=CURRENT_STATUS_FILENAME;
- }
-
- else if (strncmp (cmd, "d",1) == 0) {
- g_menu_state=CURRENT_STATUS_DIRNAME;
- }
- else if (strncmp (cmd, "s",1) == 0) {
- if(mm_sound_stop_sound(handle))
- debug_log (" Cannot stop sound !!! %d ", handle);
- }
- else if (strncmp (cmd, "1",1) == 0) {
- //ap to spk
- g_print("Not supported - Set path for speaker playback\n");
- }
-
- else if (strncmp (cmd, "2",1) == 0) {
- //ap to headset
- g_print("Not supported - Set path for headset playback\n");
- }
- else if (strncmp (cmd, "3",1) == 0) {
-
- }
- else if (strncmp (cmd, "4",1) == 0) {
- //recording
- g_print("Not supported - Set path for recording with main mic\n");
- }
- else if (strncmp (cmd, "5",1) == 0) {
+ } else if (strncmp(cmd, "f", 1) == 0) {
+ g_menu_state = CURRENT_STATUS_FILENAME;
- }
- else if (strncmp (cmd, "6",1) == 0) {
- //voice call
- g_print("Not supported - Set path for voicecall\n");
- }
- else if (strncmp (cmd, "7",1) == 0) {
- //voicecall release
- g_print("Not supported - release path for voicecall\n");
- }
- else if (strncmp (cmd, "8",1) == 0) {
- //voice call
- g_print("Not supported - Set path for VT call\n");
- }
+ } else if (strncmp(cmd, "d", 1) == 0) {
+ g_menu_state = CURRENT_STATUS_DIRNAME;
- else if (strncmp (cmd, "9",1) == 0) {
- //voicecall release
- g_print("Not supported - release path for VT call\n");
- }
+ } else if (strncmp(cmd, "s", 1) == 0) {
+ if (mm_sound_stop_sound(handle))
+ debug_log(" Cannot stop sound !!! %d ", handle);
- /* -------------------------- Route Test : Starts -------------------------- */
-#if 0
- g_print("==================================================================\n");
- g_print(" Audio route APIs\n");
- g_print("==================================================================\n");
- g_print("u : Foreach Available Routes \t");
- g_print("i : Get Active Devices \n");
- g_print("o : Add Available Routes Callback \t");
- g_print("O : Remove Available Routes Callback \n");
- g_print("p : Add Active Route Callback\t");
- g_print("P : Remove Active Route Callback \n");
- g_print("{ : Get BT A2DP Status\n");
-#endif
- else if(strncmp(cmd, "z", 1) == 0) {
- if(MM_ERROR_NONE != mm_session_init(MM_SESSION_TYPE_CALL))
- {
- g_print("Call session init failed\n");
- }
- }
- else if(strncmp(cmd, "Z", 1) == 0) {
- if(MM_ERROR_NONE != mm_session_init(MM_SESSION_TYPE_VIDEOCALL))
- {
- g_print("VideoCall session init failed\n");
- }
- }
- else if(strncmp(cmd, "N", 1) == 0) {
- if(MM_ERROR_NONE != mm_session_init(MM_SESSION_TYPE_NOTIFY))
- {
- g_print("Notify session init failed\n");
- }
- }
- else if(strncmp(cmd, "n", 1) == 0) {
- if(MM_ERROR_NONE != mm_session_init(MM_SESSION_TYPE_VOIP))
- {
- g_print("VOIP session init failed\n");
- }
- }
- else if(strncmp(cmd, "v", 1) == 0) {
- if(MM_ERROR_NONE != mm_session_finish())
- {
- g_print("Call session finish failed\n");
- }
- }
-
- else if(strncmp(cmd, "L", 1) == 0) {
+ } else if (strncmp(cmd, "L", 1) == 0) {
int ret = 0;
mm_sound_device_flags_e flags = MM_SOUND_DEVICE_ALL_FLAG;
MMSoundDeviceList_t device_list;
} else {
g_print("device_list[%p], device_h[%p]\n", device_list, device_h);
do {
- dret = mm_sound_get_next_device (device_list, &device_h);
+ dret = mm_sound_get_next_device(device_list, &device_h);
if (dret) {
debug_error("failed to mm_sound_get_next_device(), dret[0x%x]\n", dret);
} else {
ret = mm_sound_get_device_type(device_h, &device_type);
- if (ret) {
+ if (ret)
debug_error("failed to mm_sound_get_device_type()");
- }
ret = mm_sound_get_device_io_direction(device_h, &io_direction);
- if (ret) {
+ if (ret)
debug_error("failed to mm_sound_get_device_io_direction()");
- }
ret = mm_sound_get_device_state(device_h, &state);
- if (ret) {
+ if (ret)
debug_error("failed to mm_sound_get_device_state()");
- }
ret = mm_sound_get_device_id(device_h, &id);
- if (ret) {
+ if (ret)
debug_error("failed to mm_sound_get_device_id()");
- }
ret = mm_sound_get_device_name(device_h, &name);
- if (ret) {
+ if (ret)
debug_error("failed to mm_sound_get_device_name()");
- }
ret = mm_sound_get_device_vendor_id(device_h, &vendor_id);
if (ret)
debug_error("failed to mm_sound_get_device_vendor_id()");
} while (dret == MM_ERROR_NONE);
do {
dret = MM_ERROR_NONE;
- dret = mm_sound_get_prev_device (device_list, &device_h);
+ dret = mm_sound_get_prev_device(device_list, &device_h);
if (dret) {
debug_error("failed to mm_sound_get_prev_device(), dret[0x%x]", dret);
} else {
ret = mm_sound_get_device_type(device_h, &device_type);
- if (ret) {
+ if (ret)
debug_error("failed to mm_sound_get_device_type()");
- }
ret = mm_sound_get_device_io_direction(device_h, &io_direction);
- if (ret) {
+ if (ret)
debug_error("failed to mm_sound_get_device_io_direction()");
- }
ret = mm_sound_get_device_state(device_h, &state);
- if (ret) {
+ if (ret)
debug_error("failed to mm_sound_get_device_state()");
- }
ret = mm_sound_get_device_id(device_h, &id);
- if (ret) {
+ if (ret)
debug_error("failed to mm_sound_get_device_id()");
- }
ret = mm_sound_get_device_name(device_h, &name);
- if (ret) {
+ if (ret)
debug_error("failed to mm_sound_get_device_name()");
- }
ret = mm_sound_get_device_vendor_id(device_h, &vendor_id);
if (ret)
debug_error("failed to mm_sound_get_device_vendor_id()");
}
} while (dret == MM_ERROR_NONE);
}
- }
- else if(strncmp(cmd, "I", 1) == 0) {
+ } else if (strncmp(cmd, "I", 1) == 0) {
int ret = 0;
MMSoundDevice_t device_h = NULL;
mm_sound_device_type_e device_type = 0;
char input_string[128];
fflush(stdin);
- g_print ("> Input id : ");
+ g_print("> Input id : ");
if (fgets(input_string, sizeof(input_string)-1, stdin)) {
input_id = atoi(input_string);
} else {
g_print("### fgets return NULL\n");
}
- }
- else if(strncmp(cmd, "C", 1) == 0) {
+ } else if (strncmp(cmd, "C", 1) == 0) {
int ret = 0;
char input_string[128];
mm_sound_device_flags_e device_flag_1 = MM_SOUND_DEVICE_ALL_FLAG;
char flag_1, flag_2, flag_3;
fflush(stdin);
- g_print ("1. IO_DIRECTION_IN_FLAG\n");
- g_print ("2. IO_DIRECTION_OUT_FLAG\n");
- g_print ("3. IO_DIRECTION_BOTH_FLAG\n");
- g_print ("4. TYPE_INTERNAL_FLAG\n");
- g_print ("5. TYPE_EXTERNAL_FLAG\n");
- g_print ("6. STATE_DEACTIVATED_FLAG\n");
- g_print ("7. STATE_ACTIVATED_FLAG\n");
- g_print ("8. ALL_FLAG\n");
+ g_print("1. IO_DIRECTION_IN_FLAG\n");
+ g_print("2. IO_DIRECTION_OUT_FLAG\n");
+ g_print("3. IO_DIRECTION_BOTH_FLAG\n");
+ g_print("4. TYPE_INTERNAL_FLAG\n");
+ g_print("5. TYPE_EXTERNAL_FLAG\n");
+ g_print("6. STATE_DEACTIVATED_FLAG\n");
+ g_print("7. STATE_ACTIVATED_FLAG\n");
+ g_print("8. ALL_FLAG\n");
g_print("> select flag numbers (total 3): (eg. 2 5 7)");
if (fgets(input_string, sizeof(input_string)-1, stdin)) {
flag_2 = input_string[2];
flag_3 = input_string[4];
- if(flag_1 == '1') { device_flag_1 = MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG; }
- else if(flag_1 == '2') { device_flag_1 = MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG; }
- else if(flag_1 == '3') { device_flag_1 = MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG; }
- else if(flag_1 == '4') { device_flag_1 = MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG; }
- else if(flag_1 == '5') { device_flag_1 = MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG; }
- else if(flag_1 == '6') { device_flag_1 = MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG; }
- else if(flag_1 == '7') { device_flag_1 = MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG; }
- else if(flag_1 == '8') { device_flag_1 = MM_SOUND_DEVICE_ALL_FLAG; }
- if(flag_2 == '1') { device_flag_2 = MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG; }
- else if(flag_2 == '2') { device_flag_2 = MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG; }
- else if(flag_2 == '3') { device_flag_2 = MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG; }
- else if(flag_2 == '4') { device_flag_2 = MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG; }
- else if(flag_2 == '5') { device_flag_2 = MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG; }
- else if(flag_2 == '6') { device_flag_2 = MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG; }
- else if(flag_2 == '7') { device_flag_2 = MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG; }
- else if(flag_2 == '8') { device_flag_2 = MM_SOUND_DEVICE_ALL_FLAG; }
- if(flag_3 == '1') { device_flag_3 = MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG; }
- else if(flag_3 == '2') { device_flag_3 = MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG; }
- else if(flag_3 == '3') { device_flag_3 = MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG; }
- else if(flag_3 == '4') { device_flag_3 = MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG; }
- else if(flag_3 == '5') { device_flag_3 = MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG; }
- else if(flag_3 == '6') { device_flag_3 = MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG; }
- else if(flag_3 == '7') { device_flag_3 = MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG; }
- else if(flag_3 == '8') { device_flag_3 = MM_SOUND_DEVICE_ALL_FLAG; }
+ if (flag_1 == '1')
+ device_flag_1 = MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG;
+ else if (flag_1 == '2')
+ device_flag_1 = MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG;
+ else if (flag_1 == '3')
+ device_flag_1 = MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG;
+ else if (flag_1 == '4')
+ device_flag_1 = MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG;
+ else if (flag_1 == '5')
+ device_flag_1 = MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG;
+ else if (flag_1 == '6')
+ device_flag_1 = MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG;
+ else if (flag_1 == '7')
+ device_flag_1 = MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG;
+ else if (flag_1 == '8')
+ device_flag_1 = MM_SOUND_DEVICE_ALL_FLAG;
+
+ if (flag_2 == '1')device_flag_2 = MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG;
+ else if (flag_2 == '2')
+ device_flag_2 = MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG;
+ else if (flag_2 == '3')
+ device_flag_2 = MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG;
+ else if (flag_2 == '4')
+ device_flag_2 = MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG;
+ else if (flag_2 == '5')
+ device_flag_2 = MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG;
+ else if (flag_2 == '6')
+ device_flag_2 = MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG;
+ else if (flag_2 == '7')
+ device_flag_2 = MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG;
+ else if (flag_2 == '8')
+ device_flag_2 = MM_SOUND_DEVICE_ALL_FLAG;
+
+ if (flag_3 == '1')
+ device_flag_3 = MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG;
+ else if (flag_3 == '2')
+ device_flag_3 = MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG;
+ else if (flag_3 == '3')
+ device_flag_3 = MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG;
+ else if (flag_3 == '4')
+ device_flag_3 = MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG;
+ else if (flag_3 == '5')
+ device_flag_3 = MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG;
+ else if (flag_3 == '6')
+ device_flag_3 = MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG;
+ else if (flag_3 == '7')
+ device_flag_3 = MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG;
+ else if (flag_3 == '8')
+ device_flag_3 = MM_SOUND_DEVICE_ALL_FLAG;
+
g_print("device_connected_callback");
ret = mm_sound_add_device_connected_callback(device_flag_1|device_flag_2|device_flag_3, device_connected_cb, NULL, &g_subs_id_device_conn);
- if (ret) {
+ if (ret)
g_print("failed to mm_sound_add_device_connected_callback(), ret[0x%x]\n", ret);
- } else {
+ else
g_print("device_flags[0x%x], callback fun[%p], subs_id[%u]\n", device_flag_1|device_flag_2|device_flag_3, device_connected_cb, g_subs_id_device_conn);
- }
} else {
- g_print ("### fgets return NULL\n");
+ g_print("### fgets return NULL\n");
}
- }
- else if(strncmp(cmd, "D", 1) == 0) {
+ } else if (strncmp(cmd, "D", 1) == 0) {
int ret = 0;
ret = mm_sound_remove_device_connected_callback(g_subs_id_device_conn);
- if (ret) {
+ if (ret)
g_print("failed to mm_sound_remove_device_connected_callback(), ret[0x%x]\n", ret);
- }
- }
- else if(strncmp(cmd, "Q", 1) == 0) {
+
+ } else if (strncmp(cmd, "Q", 1) == 0) {
int ret = 0;
char input_string[128];
mm_sound_device_flags_e device_flag_1 = MM_SOUND_DEVICE_ALL_FLAG;
char flag_1, flag_2, flag_3;
fflush(stdin);
- g_print ("1. IO_DIRECTION_IN_FLAG\n");
- g_print ("2. IO_DIRECTION_OUT_FLAG\n");
- g_print ("3. IO_DIRECTION_BOTH_FLAG\n");
- g_print ("4. TYPE_INTERNAL_FLAG\n");
- g_print ("5. TYPE_EXTERNAL_FLAG\n");
- g_print ("6. STATE_DEACTIVATED_FLAG\n");
- g_print ("7. STATE_ACTIVATED_FLAG\n");
- g_print ("8. ALL_FLAG\n");
+ g_print("1. IO_DIRECTION_IN_FLAG\n");
+ g_print("2. IO_DIRECTION_OUT_FLAG\n");
+ g_print("3. IO_DIRECTION_BOTH_FLAG\n");
+ g_print("4. TYPE_INTERNAL_FLAG\n");
+ g_print("5. TYPE_EXTERNAL_FLAG\n");
+ g_print("6. STATE_DEACTIVATED_FLAG\n");
+ g_print("7. STATE_ACTIVATED_FLAG\n");
+ g_print("8. ALL_FLAG\n");
g_print("> select flag numbers (total 3): (eg. 2 5 7)");
if (fgets(input_string, sizeof(input_string)-1, stdin)) {
flag_2 = input_string[2];
flag_3 = input_string[4];
- if(flag_1 == '1') { device_flag_1 = MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG; }
- else if(flag_1 == '2') { device_flag_1 = MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG; }
- else if(flag_1 == '3') { device_flag_1 = MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG; }
- else if(flag_1 == '4') { device_flag_1 = MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG; }
- else if(flag_1 == '5') { device_flag_1 = MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG; }
- else if(flag_1 == '6') { device_flag_1 = MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG; }
- else if(flag_1 == '7') { device_flag_1 = MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG; }
- else if(flag_1 == '8') { device_flag_1 = MM_SOUND_DEVICE_ALL_FLAG; }
- if(flag_2 == '1') { device_flag_2 = MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG; }
- else if(flag_2 == '2') { device_flag_2 = MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG; }
- else if(flag_2 == '3') { device_flag_2 = MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG; }
- else if(flag_2 == '4') { device_flag_2 = MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG; }
- else if(flag_2 == '5') { device_flag_2 = MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG; }
- else if(flag_2 == '6') { device_flag_2 = MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG; }
- else if(flag_2 == '7') { device_flag_2 = MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG; }
- else if(flag_2 == '8') { device_flag_2 = MM_SOUND_DEVICE_ALL_FLAG; }
- if(flag_3 == '1') { device_flag_3 = MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG; }
- else if(flag_3 == '2') { device_flag_3 = MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG; }
- else if(flag_3 == '3') { device_flag_3 = MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG; }
- else if(flag_3 == '4') { device_flag_3 = MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG; }
- else if(flag_3 == '5') { device_flag_3 = MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG; }
- else if(flag_3 == '6') { device_flag_3 = MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG; }
- else if(flag_3 == '7') { device_flag_3 = MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG; }
- else if(flag_3 == '8') { device_flag_3 = MM_SOUND_DEVICE_ALL_FLAG; }
+ if (flag_1 == '1')
+ device_flag_1 = MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG;
+ else if (flag_1 == '2')
+ device_flag_1 = MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG;
+ else if (flag_1 == '3')
+ device_flag_1 = MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG;
+ else if (flag_1 == '4')
+ device_flag_1 = MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG;
+ else if (flag_1 == '5')
+ device_flag_1 = MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG;
+ else if (flag_1 == '6')
+ device_flag_1 = MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG;
+ else if (flag_1 == '7')
+ device_flag_1 = MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG;
+ else if (flag_1 == '8')
+ device_flag_1 = MM_SOUND_DEVICE_ALL_FLAG;
+
+ if (flag_2 == '1')
+ device_flag_2 = MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG;
+ else if (flag_2 == '2')
+ device_flag_2 = MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG;
+ else if (flag_2 == '3')
+ device_flag_2 = MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG;
+ else if (flag_2 == '4')
+ device_flag_2 = MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG;
+ else if (flag_2 == '5')
+ device_flag_2 = MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG;
+ else if (flag_2 == '6')
+ device_flag_2 = MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG;
+ else if (flag_2 == '7')
+ device_flag_2 = MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG;
+ else if (flag_2 == '8')
+ device_flag_2 = MM_SOUND_DEVICE_ALL_FLAG;
+
+ if (flag_3 == '1')
+ device_flag_3 = MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG;
+ else if (flag_3 == '2')
+ device_flag_3 = MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG;
+ else if (flag_3 == '3')
+ device_flag_3 = MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG;
+ else if (flag_3 == '4')
+ device_flag_3 = MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG;
+ else if (flag_3 == '5')
+ device_flag_3 = MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG;
+ else if (flag_3 == '6')
+ device_flag_3 = MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG;
+ else if (flag_3 == '7')
+ device_flag_3 = MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG;
+ else if (flag_3 == '8')
+ device_flag_3 = MM_SOUND_DEVICE_ALL_FLAG;
+
g_print("add_device_state_changed");
ret = mm_sound_add_device_state_changed_callback(device_flag_1 | device_flag_2 | device_flag_3, device_state_changed_cb, NULL, &g_subs_id_device_state);
- if (ret) {
+ if (ret)
g_print("failed to mm_sound_add_device_state_changed_callback(), ret[0x%x]\n", ret);
- } else {
+ else
g_print("device_flags[0x%x], callback fun[%p], subs_id[%u]\n", device_flag_1|device_flag_2|device_flag_3, device_state_changed_cb, g_subs_id_device_state);
- }
+
} else {
- g_print ("### fgets return NULL\n");
+ g_print("### fgets return NULL\n");
}
- }
- else if(strncmp(cmd, "W", 1) == 0) {
+ } else if (strncmp(cmd, "W", 1) == 0) {
int ret = 0;
ret = mm_sound_remove_device_state_changed_callback(g_subs_id_device_state);
if (ret)
g_print("failed to mm_sound_remove_device_state_changed_callback(), ret[0x%x]\n", ret);
- }
- else if (strncmp(cmd, "x", 1) == 0) {
+ } else if (strncmp(cmd, "x", 1) == 0) {
quit_program();
}
break;
case CURRENT_STATUS_FILENAME:
input_filename(cmd);
- g_menu_state=CURRENT_STATUS_MAINMENU;
+ g_menu_state = CURRENT_STATUS_MAINMENU;
break;
case CURRENT_STATUS_DIRNAME:
input_dirname(cmd);
- g_menu_state=CURRENT_STATUS_MAINMENU;
+ g_menu_state = CURRENT_STATUS_MAINMENU;
break;
+
case CURRENT_STATUS_POSITION:
break;
+
}
- //g_timeout_add(100, timeout_menu_display, 0);
}
void volume_change_callback(volume_type_t type, unsigned int volume, void *user_data)
stdin_channel = g_io_channel_unix_new(0);
g_io_add_watch(stdin_channel, G_IO_IN, (GIOFunc)input, NULL);
- g_loop = g_main_loop_new (NULL, 1);
+ g_loop = g_main_loop_new(NULL, 1);
MMSOUND_STRNCPY(g_file_name, POWERON_FILE, MAX_STRING_LEN);
- g_print("\nThe input filename is '%s' \n\n",g_file_name);
+ g_print("\nThe input filename is '%s' \n\n", g_file_name);
/* test volume changed callback */
g_print("callback function addr :: %p\n", volume_change_callback);
g_volume_type = VOLUME_TYPE_MEDIA;
ret = mm_sound_volume_get_value(g_volume_type, &g_volume_value);
- if(ret < 0) {
+ if (ret < 0)
g_print("mm_sound_volume_get_value 0x%x\n", ret);
- }
+
mm_sound_add_volume_changed_callback(volume_change_callback, (void*) &g_volume_type, &g_subs_id_volume);
displaymenu();
- g_main_loop_run (g_loop);
+ g_main_loop_run(g_loop);
return 0;
}
-