int ret = MM_ERROR_NONE;
sigset_t old_mask, all_mask;
- debug_error("Got signal : signo(%d)", signo);
+ debug_warning("Got signal : signo(%d)", signo);
/* signal block */
break;
}
- debug_error("signal handling end");
+ debug_warning("signal handling end");
}
int mm_sound_client_initialize(void)
break;
}
- debug_error("volume type (%d) converted to stream type (%s)", volume_type, stream_type);
+ debug_msg("volume type (%d) converted to stream type (%s)", volume_type, stream_type);
}
int ret = MM_ERROR_NONE;
debug_fenter();
- debug_error("focus signal received, value = %d", value);
+ debug_msg("focus signal received, value = %d", value);
if (value == 1) {
ret = mm_sound_proxy_clear_focus(getpid());
return true;
if ((mask & MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG) && (direction & MM_SOUND_DEVICE_IO_DIRECTION_OUT))
return true;
- if ((mask & MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG) && (direction & MM_SOUND_DEVICE_IO_DIRECTION_BOTH))
+ if ((mask & MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG) && (direction == MM_SOUND_DEVICE_IO_DIRECTION_BOTH))
return true;
return false;
static gpointer _focus_thread_func(gpointer data)
{
- debug_log(">>> thread func..ID of this thread(%u)\n", (unsigned int)pthread_self());
- g_main_loop_run(g_focus_loop);
- debug_log("<<< quit thread func..\n");
+ unsigned int thread_id = (unsigned int)pthread_self();
+ debug_warning(">>> thread func..ID of this thread(%u), mainloop(%p)", thread_id, g_focus_loop);
+ if (g_focus_loop)
+ g_main_loop_run(g_focus_loop);
+
+ debug_warning("<<< quit thread func..(%u), mainloop(%p)", thread_id, g_focus_loop);
return NULL;
}
tid = g_focus_sound_handle[focus_index].focus_tid;
if (changed_state != -1) {
- debug_error("Got and start CB : TID(%d), handle(%d), type(%d), state(%d,(DEACTIVATED(0)/ACTIVATED(1)), trigger(%s)", tid, cb_data.handle, cb_data.type, cb_data.state, cb_data.stream_type);
+ debug_msg("Got and start CB : TID(%d), handle(%d), type(%d), state(%d,(DEACTIVATED(0)/ACTIVATED(1)), trigger(%s)", tid, cb_data.handle, cb_data.type, cb_data.state, cb_data.stream_type);
if (g_focus_sound_handle[focus_index].focus_callback == NULL) {
debug_error("callback is null..");
g_mutex_unlock(&g_focus_sound_handle[focus_index].focus_lock);
return FALSE;
}
- debug_error("[CALLBACK(%p) START]",g_focus_sound_handle[focus_index].focus_callback);
+ debug_msg("[CALLBACK(%p) START]",g_focus_sound_handle[focus_index].focus_callback);
(g_focus_sound_handle[focus_index].focus_callback)(cb_data.handle, cb_data.type, cb_data.state, cb_data.stream_type, cb_data.option, cb_data.ext_info, g_focus_sound_handle[focus_index].user_data);
- debug_error("[CALLBACK END]");
+ debug_msg("[CALLBACK END]");
if (g_focus_session_interrupt_info.user_cb) {
- debug_error("sending session interrupt callback(%p)", g_focus_session_interrupt_info.user_cb);
+ debug_msg("sending session interrupt callback(%p)", g_focus_session_interrupt_info.user_cb);
(g_focus_session_interrupt_info.user_cb)(cb_data.state, cb_data.stream_type, false, g_focus_session_interrupt_info.user_data);
}
}
if (tmpfd < 0) {
char str_error[256];
strerror_r(errno, str_error, sizeof(str_error));
- debug_error("[RETCB][Failed(May Server Close First)]tid(%d) fd(%d) %s errno=%d(%s)\n", tid, tmpfd, filename2, errno, str_error);
+ debug_warning("[RETCB][Failed(May Server Close First)]tid(%d) fd(%d) %s errno=%d(%s)\n", tid, tmpfd, filename2, errno, str_error);
g_free(filename2);
g_mutex_unlock(&g_focus_sound_handle[focus_index].focus_lock);
return FALSE;
return FALSE;
}
- debug_error("lock focus_lock = %p", &g_focus_sound_handle[focus_index].focus_lock);
+ if (!g_focus_sound_handle[focus_index].is_used) {
+ debug_warning("unsetting watch calllback has been already requested");
+ goto SKIP_CB_AND_RET;
+ }
+
+ debug_msg("lock focus_lock = %p", &g_focus_sound_handle[focus_index].focus_lock);
g_mutex_lock(&g_focus_sound_handle[focus_index].focus_lock);
tid = g_focus_sound_handle[focus_index].focus_tid;
- debug_error("Got and start CB : TID(%d), handle(%d), type(%d), state(%d,(DEACTIVATED(0)/ACTIVATED(1)), trigger(%s)", tid, cb_data.handle, cb_data.type, cb_data.state, cb_data.stream_type);
+ debug_msg("Got and start CB : TID(%d), handle(%d), type(%d), state(%d,(DEACTIVATED(0)/ACTIVATED(1)), trigger(%s)", tid, cb_data.handle, cb_data.type, cb_data.state, cb_data.stream_type);
if (g_focus_sound_handle[focus_index].watch_callback == NULL) {
debug_msg("callback is null..");
(g_focus_sound_handle[focus_index].watch_callback)(cb_data.handle, cb_data.type, cb_data.state, cb_data.stream_type, cb_data.ext_info, g_focus_sound_handle[focus_index].user_data);
debug_msg("[CALLBACK END]");
if (g_focus_session_interrupt_info.user_cb) {
- debug_error("sending session interrupt callback(%p)", g_focus_session_interrupt_info.user_cb);
+ debug_msg("sending session interrupt callback(%p)", g_focus_session_interrupt_info.user_cb);
(g_focus_session_interrupt_info.user_cb)(cb_data.state, cb_data.stream_type, true, g_focus_session_interrupt_info.user_data);
}
}
+SKIP_CB_AND_RET:
#ifdef CONFIG_ENABLE_RETCB
{
int rett = 0;
if (tmpfd < 0) {
char str_error[256];
strerror_r(errno, str_error, sizeof(str_error));
- debug_error("[RETCB][Failed(May Server Close First)]tid(%d) fd(%d) %s errno=%d(%s)\n", tid, tmpfd, filename2, errno, str_error);
+ debug_warning("[RETCB][Failed(May Server Close First)]tid(%d) fd(%d) %s errno=%d(%s)\n", tid, tmpfd, filename2, errno, str_error);
g_free(filename2);
g_mutex_unlock(&g_focus_sound_handle[focus_index].focus_lock);
return FALSE;
#endif
}
- debug_error("unlock focus_lock = %p", &g_focus_sound_handle[focus_index].focus_lock);
- g_mutex_unlock(&g_focus_sound_handle[focus_index].focus_lock);
+ if (g_focus_sound_handle[focus_index].is_used) {
+ debug_msg("unlock focus_lock = %p", &g_focus_sound_handle[focus_index].focus_lock);
+ g_mutex_unlock(&g_focus_sound_handle[focus_index].focus_lock);
+ }
debug_fleave();
-
return TRUE;
}
if (g_focus_sound_handle[index].focus_fd == -1) {
debug_error("Open fail : index(%d), file open error(%d)", index, errno);
} else {
- debug_log("Open sucess : index(%d), filename(%s), fd(%d)", index, filename, g_focus_sound_handle[index].focus_fd);
+ debug_log("Open success : index(%d), filename(%s), fd(%d)", index, filename, g_focus_sound_handle[index].focus_fd);
}
g_free(filename);
filename = NULL;
debug_error("Close fail : index(%d)", index);
} else {
close(g_focus_sound_handle[index].focus_fd);
- debug_log("Close Sucess : index(%d)", index);
+ debug_log("Close Success : index(%d)", index);
}
if (is_for_watching) {
GMainContext* focus_context = g_main_context_new ();
g_focus_loop = g_main_loop_new (focus_context, FALSE);
g_main_context_unref(focus_context);
- g_focus_thread = g_thread_new("focus-callback-thread", _focus_thread_func, NULL);
+ if (g_focus_loop == NULL) {
+ debug_error("could not create mainloop..");
+ ret = MM_ERROR_SOUND_INTERNAL;
+ goto cleanup;
+ }
+
+ g_focus_thread = g_thread_new("focus-cb-thread", _focus_thread_func, NULL);
if (g_focus_thread == NULL) {
- debug_error ("could not create thread..");
+ debug_error("could not create thread..");
g_main_loop_unref(g_focus_loop);
- g_focus_sound_handle[index].is_used = false;
ret = MM_ERROR_SOUND_INTERNAL;
goto cleanup;
}
+ } else {
+ debug_warning("focus thread(%p) with mainloop(%p) exists, skip thread creation",
+ g_focus_thread, g_focus_loop);
}
} else {
debug_error("[Client] Error occurred : 0x%x \n",ret);
- g_focus_sound_handle[index].is_used = false;
goto cleanup;
}
_focus_init_callback(index, false);
cleanup:
+
+ if (ret) {
+ g_focus_sound_handle[index].is_used = false;
+ }
+
MMSOUND_LEAVE_CRITICAL_SECTION(&g_index_mutex);
debug_fleave();
} else if (!result) {
ret = mm_sound_proxy_set_foucs_reacquisition(instance, id, reacquisition);
if (ret == MM_ERROR_NONE) {
- debug_msg("[Client] Success to set focus reacquisition\n");
+ debug_msg("[Client] Success to set focus reacquisition to [%d]\n", reacquisition);
} else {
debug_error("[Client] Error occurred : 0x%x \n",ret);
goto cleanup;
}
} else {
- debug_warning("[Client] Inside the focus cb thread, bypassing dbus method call");
+ debug_warning("[Client] Inside the focus cb thread, set focus reacquisition to [%d]\n", reacquisition);
}
g_focus_sound_handle[index].auto_reacquire = reacquisition;
GMainContext* focus_context = g_main_context_new ();
g_focus_loop = g_main_loop_new (focus_context, FALSE);
g_main_context_unref(focus_context);
- g_focus_thread = g_thread_new("focus-callback-thread", _focus_thread_func, NULL);
+ if (g_focus_loop == NULL) {
+ debug_error("could not create mainloop..");
+ ret = MM_ERROR_SOUND_INTERNAL;
+ goto cleanup;
+ }
+
+ g_focus_thread = g_thread_new("focus-cb-thread", _focus_thread_func, NULL);
if (g_focus_thread == NULL) {
debug_error ("could not create thread..");
g_main_loop_unref(g_focus_loop);
ret = MM_ERROR_SOUND_INTERNAL;
goto cleanup;
}
+ } else {
+ debug_warning("focus thread(%p) with mainloop(%p) exists, skip thread creation",
+ g_focus_thread, g_focus_loop);
}
} else {
debug_error("[Client] Error occurred : 0x%x",ret);
g_mutex_lock(&g_focus_sound_handle[index].focus_lock);
+ 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);
if (ret == MM_ERROR_NONE)
g_focus_sound_handle[index].focus_fd = 0;
g_focus_sound_handle[index].focus_tid = 0;
g_focus_sound_handle[index].handle = 0;
- g_focus_sound_handle[index].is_used = false;
cleanup:
MMSOUND_LEAVE_CRITICAL_SECTION(&g_index_mutex);
debug_fleave();