int endtime = 0;
int fd_FOCUS_R = -1;
int fd_FOCUS = -1;
- int ret = -1;
+ unsigned int ret;
struct pollfd pfd;
int pret = 0;
int pollingTimeout = 2500; /* NOTE : This is temporary code, because of Deadlock issues. If you fix that issue, remove this comment */
int flag_for_taken_index = 0;
int taken_pid = 0;
int taken_hid = 0;
+ int ret_handle = -1;
+ bool auto_reacquire = true;
bool taken_by_session = false;
focus_cb_data cb_data;
debug_error("read error\n");
goto fail;
}
+ ret_handle = (int)(ret & 0x0000ffff);
+ auto_reacquire = (bool)((ret >> 16) & 0xf);
}
g_free(filename2);
filename2 = NULL;
}
//debug_log("[RETCB] Return value 0x%x\n", buf);
- /* update victim node */
- taken_pid = (command == FOCUS_COMMAND_RELEASE) ? assaulter_param->pid : 0;
- taken_hid = (command == FOCUS_COMMAND_RELEASE) ? assaulter_param->handle_id : 0;
- taken_by_session = (command == FOCUS_COMMAND_RELEASE) ? assaulter_param->is_for_session : false;
- flag_for_taken_index = (command == FOCUS_COMMAND_RELEASE) ? assaulter_param->request_type & victim_node->status : assaulter_param->request_type;
- for (i = 0; i < NUM_OF_STREAM_IO_TYPE; i++) {
- if (flag_for_taken_index & (i+1)) {
- 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)))) {
- /* skip */
- debug_error("skip updating victim node");
- continue;
+ if (auto_reacquire) {
+ /* update victim node */
+ 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;
+ }
+
+ for (i = 0; i < NUM_OF_STREAM_IO_TYPE; i++) {
+ if (flag_for_taken_index & (i+1)) {
+ 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)))) {
+ /* skip */
+ debug_error("skip updating victim node");
+ continue;
+ }
+ UPDATE_FOCUS_TAKEN_INFO(victim_node, taken_pid, taken_hid, taken_by_session);
}
- UPDATE_FOCUS_TAKEN_INFO(victim_node, taken_pid, taken_hid, taken_by_session);
}
}
- if(ret == victim_node->handle_id) {
- /* return from client is success, ret will be its handle_id */
+ if (ret_handle == victim_node->handle_id) {
+ /* return from client is success, ret_handle will be its handle_id */
victim_node->status = (command == FOCUS_COMMAND_RELEASE) ? (victim_node->status & ~(cb_data.type)) : (victim_node->status | cb_data.type);
} else {
victim_node->status = FOCUS_STATUS_DEACTIVATED;
GPollFD* g_poll_fd;
GSource* focus_src;
bool is_used;
+ bool auto_reacquire;
GMutex focus_lock;
mm_sound_focus_changed_cb focus_callback;
mm_sound_focus_changed_watch_cb watch_callback;
int rett = 0;
int tmpfd = -1;
- int buf = 0;
+ unsigned int buf = 0;
char *filename2 = g_strdup_printf("/tmp/FOCUS.%d.%dr", g_focus_sound_handle[focus_index].focus_tid, cb_data.handle);
tmpfd = open(filename2, O_WRONLY | O_NONBLOCK);
if (tmpfd < 0) {
g_mutex_unlock(&g_focus_sound_handle[focus_index].focus_lock);
return FALSE;
}
- buf = cb_data.handle;
+ buf = (unsigned int)((0x0000ffff & cb_data.handle) |(g_focus_sound_handle[focus_index].auto_reacquire << 16));
rett = write(tmpfd, &buf, sizeof(buf));
close(tmpfd);
g_free(filename2);
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_client_dbus_register_focus(id, pid, stream_type, callback, is_for_session, user_data);
return ret;
}
+int mm_sound_client_set_focus_reacquisition(int id, bool reacquisition)
+{
+ int ret = MM_ERROR_NONE;
+ int index = -1;
+
+ debug_fenter();
+
+ index = _focus_find_index_by_handle(id);
+ if (index == -1) {
+ debug_error("Could not find index");
+ return MM_ERROR_INVALID_ARGUMENT;
+ }
+
+ g_focus_sound_handle[index].auto_reacquire = reacquisition;
+
+ debug_fleave();
+
+ return ret;
+}
+
+int mm_sound_client_get_focus_reacquisition(int id, bool *reacquisition)
+{
+ int ret = MM_ERROR_NONE;
+ int index = -1;
+
+ debug_fenter();
+
+ if (!reacquisition) {
+ debug_error("Invalid parameter");
+ return MM_ERROR_INVALID_ARGUMENT;
+ }
+
+ index = _focus_find_index_by_handle(id);
+ if (index == -1) {
+ debug_error("Could not find index");
+ return MM_ERROR_INVALID_ARGUMENT;
+ }
+
+ *reacquisition = g_focus_sound_handle[index].auto_reacquire;
+
+ debug_fleave();
+
+ return ret;
+}
+
int mm_sound_client_acquire_focus(int id, mm_sound_focus_type_e type, const char *option)
{
int ret = MM_ERROR_NONE;
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");
{
case CURRENT_STATUS_MAINMENU:
#ifdef USE_FOCUS
- if(strncmp(cmd, "DS", 2) ==0) {
+ 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\n", ret);
debug_log("id: %u, callback:%p\n", g_subscribe_id2, __mm_sound_signal_cb2);
}
- else if(strncmp(cmd, "DU", 2) ==0) {
+ else if(strncmp(cmd, "DU", 2) == 0) {
mm_sound_unsubscribe_signal(g_subscribe_id1);
debug_log("unsubscribe_signal for id[%d]\n", g_subscribe_id1);
mm_sound_unsubscribe_signal(g_subscribe_id2);
debug_log("unsubscribe_signal for id[%d]\n", g_subscribe_id2);
}
- else if(strncmp(cmd, "SS", 2) ==0) {
+ else if(strncmp(cmd, "SS", 2) == 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\n", ret);
g_print (" -- get value of RELEASE_INTERNAL_FOCUS : %d\n", value);
}
- else if(strncmp(cmd, "GU", 2) ==0) {
+ else if(strncmp(cmd, "GU", 2) == 0) {
int id = 0;
ret = mm_sound_focus_get_id(&id);
if(ret < 0)
debug_log("id : %d\n", id);
}
- else if(strncmp(cmd, "SF", 2) ==0) {
+ else if(strncmp(cmd, "SF", 2) == 0) {
int ret = 0;
char input_string[128];
char flag_1, flag_2;
}
}
- else if(strncmp(cmd, "FFS", 3) ==0) {
+ else if(strncmp(cmd, "FFS", 3) == 0) {
int ret = 0;
char input_string[128];
char flag_1, flag_2;
}
}
- else if(strncmp(cmd, "UF", 2) ==0) {
+ else if(strncmp(cmd, "UF", 2) == 0) {
int ret = 0;
char input_string[128];
char flag_1;
}
}
- else if(strncmp(cmd, "AF", 2) ==0) {
+ 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)) {
+ g_print ("### fgets return NULL\n");
+ }
+ 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 if(strncmp(cmd, "AF", 2) == 0) {
int ret = 0;
char input_string[128];
char flag_1, flag_2;
}
}
- else if(strncmp(cmd, "RF", 2) ==0) {
+ else if(strncmp(cmd, "RF", 2) == 0) {
int ret = 0;
char input_string[128];
char flag_1, flag_2;
}
}
- else if(strncmp(cmd, "WFS", 3) ==0) {
+ else if(strncmp(cmd, "WFS", 3) == 0) {
int ret = 0;
char input_string[128];
char flag_1;
}
}
- else if(strncmp(cmd, "WS", 2) ==0) {
+ else if(strncmp(cmd, "WS", 2) == 0) {
int ret = 0;
char input_string[128];
char flag_1;
}
}
- else if(strncmp(cmd, "WU", 2) ==0) {
+ else if(strncmp(cmd, "WU", 2) == 0) {
int ret = 0;
ret = mm_sound_unset_focus_watch_callback(g_focus_watch_index);
if (ret) {
}
}
- else if(strncmp(cmd, "z", 1) ==0) {
+ 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) {
+ 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) {
+ 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) {
+ 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) {
+ 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, "V", 1) ==0) {
+ else if(strncmp(cmd, "V", 1) == 0) {
int value;
if(vconf_get_int(SOUND_STATUS_KEY, &value)) {
g_print("Can not get %s\n", SOUND_STATUS_KEY);
}
}
- 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 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;
}
}
- 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) {
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;
}
}
- else if(strncmp(cmd, "W", 1) ==0) {
+ else if(strncmp(cmd, "W", 1) == 0) {
int ret = 0;
ret = mm_sound_remove_device_information_changed_callback(g_subs_id_device_info);
if (ret) {