summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
dfd2850)
API is revised as below.
- int mm_sound_focus_is_cb_thread(bool *result)
+ int mm_sound_focus_is_cb_thread(bool *result, bool *is_for_watching)
[Version] 0.12.41
[Issue Type] Enhancement
Change-Id: Ib2cfa6b7b2425d5a37db224bb242c7c2a1651d14
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
int mm_sound_client_add_device_running_changed_callback(int device_flags, mm_sound_device_running_changed_cb func, void *userdata, unsigned int *id);
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);
int mm_sound_client_add_device_running_changed_callback(int device_flags, mm_sound_device_running_changed_cb func, void *userdata, unsigned int *id);
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);
-int mm_sound_client_is_focus_cb_thread(GThread *mine, bool *result);
+int mm_sound_client_is_focus_cb_thread(GThread *mine, bool *result, bool *is_for_watching);
int mm_sound_client_register_focus(int pid, const char *stream_type, mm_sound_focus_changed_cb callback, void* user_data, int *id);
int mm_sound_client_unregister_focus(int id);
int mm_sound_client_set_focus_reacquisition(int id, bool reacquisition);
int mm_sound_client_register_focus(int pid, const char *stream_type, mm_sound_focus_changed_cb callback, void* user_data, int *id);
int mm_sound_client_unregister_focus(int id);
int mm_sound_client_set_focus_reacquisition(int id, bool reacquisition);
FOCUS_FOR_BOTH,
} mm_sound_focus_type_e;
FOCUS_FOR_BOTH,
} mm_sound_focus_type_e;
-int mm_sound_focus_is_cb_thread(bool *result);
+int mm_sound_focus_is_cb_thread(bool *result, bool *is_for_watching);
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(const char *stream_type, mm_sound_focus_changed_cb callback, void *user_data, int *id);
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(const char *stream_type, mm_sound_focus_changed_cb callback, void *user_data, int *id);
bool auto_reacquire;
GMutex focus_lock;
GThread *focus_cb_thread;
bool auto_reacquire;
GMutex focus_lock;
GThread *focus_cb_thread;
+ GThread *focus_watch_cb_thread;
GMainLoop *focus_loop;
mm_sound_focus_changed_cb focus_callback;
mm_sound_focus_changed_watch_cb watch_callback;
GMainLoop *focus_loop;
mm_sound_focus_changed_cb focus_callback;
mm_sound_focus_changed_watch_cb watch_callback;
int focus_find_index_by_handle(int handle);
int focus_watch_find_index_by_handle(int handle);
int focus_find_index_by_handle(int handle);
int focus_watch_find_index_by_handle(int handle);
-int focus_init_context(int index);
-void focus_deinit_context(int index);
+int focus_init_context(int index, bool is_for_watching);
+void focus_deinit_context(int index, bool is_for_watching);
void focus_init_callback(int index, bool is_for_watching);
void focus_deinit_callback(int index, bool is_for_watching);
void focus_init_callback(int index, bool is_for_watching);
void focus_deinit_callback(int index, bool is_for_watching);
-int mm_sound_client_is_focus_cb_thread(GThread *mine, bool *result)
+int mm_sound_client_is_focus_cb_thread(GThread *mine, bool *result, bool *is_for_watching)
{
int ret = MM_ERROR_NONE;
int i = 0;
{
int ret = MM_ERROR_NONE;
int i = 0;
continue;
if (g_focus_sound_handle[i].focus_cb_thread == mine) {
*result = true;
continue;
if (g_focus_sound_handle[i].focus_cb_thread == mine) {
*result = true;
+ if (is_for_watching)
+ *is_for_watching = false;
+ break;
+ }
+ if (g_focus_sound_handle[i].focus_watch_cb_thread == mine) {
+ *result = true;
+ if (is_for_watching)
+ *is_for_watching = true;
ret = mm_sound_proxy_register_focus(index, stream_type, id);
if (ret == MM_ERROR_NONE) {
debug_msg("Success to register focus, client_fd[%d], id[%d]", g_focus_sound_handle[index].client_fd, *id);
ret = mm_sound_proxy_register_focus(index, stream_type, id);
if (ret == MM_ERROR_NONE) {
debug_msg("Success to register focus, client_fd[%d], id[%d]", g_focus_sound_handle[index].client_fd, *id);
- if (focus_init_context(index)) {
+ if (focus_init_context(index, false)) {
ret = MM_ERROR_SOUND_INTERNAL;
goto cleanup;
}
ret = MM_ERROR_SOUND_INTERNAL;
goto cleanup;
}
g_focus_sound_handle[index].client_fd = 0;
g_focus_sound_handle[index].handle = 0;
g_focus_sound_handle[index].is_used = false;
g_focus_sound_handle[index].client_fd = 0;
g_focus_sound_handle[index].handle = 0;
g_focus_sound_handle[index].is_used = false;
- focus_deinit_context(index);
+ focus_deinit_context(index, false);
cleanup:
MMSOUND_LEAVE_CRITICAL_SECTION(&g_index_mutex);
cleanup:
MMSOUND_LEAVE_CRITICAL_SECTION(&g_index_mutex);
- ret = mm_sound_client_is_focus_cb_thread(g_thread_self(), &result);
+ ret = mm_sound_client_is_focus_cb_thread(g_thread_self(), &result, NULL);
if (ret) {
debug_error("mm_sound_client_is_focus_cb_thread failed");
goto cleanup;
if (ret) {
debug_error("mm_sound_client_is_focus_cb_thread failed");
goto cleanup;
if (ret == MM_ERROR_NONE) {
*id = g_focus_sound_handle[index].handle;
debug_msg("Success to add watch focus cb, id(%d)", *id);
if (ret == MM_ERROR_NONE) {
*id = g_focus_sound_handle[index].handle;
debug_msg("Success to add watch focus cb, id(%d)", *id);
- if (focus_init_context(index)) {
+ if (focus_init_context(index, true)) {
ret = MM_ERROR_SOUND_INTERNAL;
goto cleanup;
}
ret = MM_ERROR_SOUND_INTERNAL;
goto cleanup;
}
g_focus_sound_handle[index].focus_pid = 0;
g_focus_sound_handle[index].client_fd = 0;
g_focus_sound_handle[index].handle = 0;
g_focus_sound_handle[index].focus_pid = 0;
g_focus_sound_handle[index].client_fd = 0;
g_focus_sound_handle[index].handle = 0;
- focus_deinit_context(index);
+ focus_deinit_context(index, true);
cleanup:
MMSOUND_LEAVE_CRITICAL_SECTION(&g_index_mutex);
cleanup:
MMSOUND_LEAVE_CRITICAL_SECTION(&g_index_mutex);
{ \
int ret = MM_ERROR_NONE; \
bool result = false; \
{ \
int ret = MM_ERROR_NONE; \
bool result = false; \
- ret = mm_sound_client_is_focus_cb_thread(x_thread, &result); \
+ ret = mm_sound_client_is_focus_cb_thread(x_thread, &result, NULL); \
if (ret) \
return ret; \
if (result) { \
if (ret) \
return ret; \
if (result) { \
-int mm_sound_focus_is_cb_thread(bool *result)
+int mm_sound_focus_is_cb_thread(bool *result, bool *is_for_watching)
{
int ret = MM_ERROR_NONE;
debug_fenter();
{
int ret = MM_ERROR_NONE;
debug_fenter();
- ret = mm_sound_client_is_focus_cb_thread(g_thread_self(), result);
+ if (result == NULL) {
+ debug_error("argument is not valid");
+ return MM_ERROR_INVALID_ARGUMENT;
+ }
+
+ ret = mm_sound_client_is_focus_cb_thread(g_thread_self(), result, is_for_watching);
if (!ret) {
if (*result)
debug_msg("it might be called in the thread of focus callback");
if (!ret) {
if (*result)
debug_msg("it might be called in the thread of focus callback");
+ if (is_for_watching && *is_for_watching)
+ debug_msg("it's in the focus watch callback");
return MM_ERROR_INVALID_ARGUMENT;
}
return MM_ERROR_INVALID_ARGUMENT;
}
- mm_sound_client_is_focus_cb_thread(g_thread_self(), &result);
+ mm_sound_client_is_focus_cb_thread(g_thread_self(), &result, NULL);
if (!result) {
if ((ret = mm_sound_client_unregister_focus(id)))
debug_error("Could not unregister focus, ret = %x", ret);
if (!result) {
if ((ret = mm_sound_client_unregister_focus(id)))
debug_error("Could not unregister focus, ret = %x", ret);
- mm_sound_client_is_focus_cb_thread(g_thread_self(), &result);
+ mm_sound_client_is_focus_cb_thread(g_thread_self(), &result, NULL);
if (!result) {
if ((ret = mm_sound_client_unset_focus_watch_callback(id)))
debug_error("Could not unset focus watch callback, id(%d), ret[0x%x]", id, ret);
if (!result) {
if ((ret = mm_sound_client_unset_focus_watch_callback(id)))
debug_error("Could not unset focus watch callback, id(%d), ret[0x%x]", id, ret);
}
#define LOOP_RUNNING_WAIT_TIME_MS 2500
}
#define LOOP_RUNNING_WAIT_TIME_MS 2500
-int focus_init_context(int index)
+int focus_init_context(int index, bool is_for_watching)
{
int ret = MM_ERROR_NONE;
GMainContext *focus_context;
{
int ret = MM_ERROR_NONE;
GMainContext *focus_context;
+ GThread **focus_cb_thread = NULL;
+ char *focus_cb_thread_name;
- g_focus_sound_handle[index].focus_cb_thread = g_thread_new("focus-cb-thread",
+ if (is_for_watching) {
+ focus_cb_thread = &g_focus_sound_handle[index].focus_watch_cb_thread;
+ focus_cb_thread_name = "focus-watch-cb-thread";
+ } else {
+ focus_cb_thread = &g_focus_sound_handle[index].focus_cb_thread;
+ focus_cb_thread_name = "focus-cb-thread";
+ }
+
+ *focus_cb_thread = g_thread_new(focus_cb_thread_name,
_focus_thread_func,
g_focus_sound_handle[index].focus_loop);
_focus_thread_func,
g_focus_sound_handle[index].focus_loop);
- if (g_focus_sound_handle[index].focus_cb_thread == NULL) {
+ if (*focus_cb_thread == NULL) {
debug_error("could not create thread..");
goto ERROR;
}
debug_error("could not create thread..");
goto ERROR;
}
- debug_warning("focus cb thread[%p] with mainloop[%p] is created for index(%d)",
- g_focus_sound_handle[index].focus_cb_thread, g_focus_sound_handle[index].focus_loop, index);
+ debug_warning("focus cb thread[%p] with mainloop[%p] is created for index(%d), is_for_watching(%d)",
+ *focus_cb_thread, g_focus_sound_handle[index].focus_loop, index, is_for_watching);
if ((ret = _focus_loop_is_running_timed_wait(g_focus_sound_handle[index].focus_loop, LOOP_RUNNING_WAIT_TIME_MS))) {
debug_error("failed to _focus_loop_is_running_timed_wait(), ret[0x%x]", ret);
if ((ret = _focus_loop_is_running_timed_wait(g_focus_sound_handle[index].focus_loop, LOOP_RUNNING_WAIT_TIME_MS))) {
debug_error("failed to _focus_loop_is_running_timed_wait(), ret[0x%x]", ret);
ERROR:
if (g_focus_sound_handle[index].focus_loop) {
ERROR:
if (g_focus_sound_handle[index].focus_loop) {
- if (g_focus_sound_handle[index].focus_cb_thread) {
+ if (*focus_cb_thread) {
g_main_loop_quit(g_focus_sound_handle[index].focus_loop);
g_main_loop_quit(g_focus_sound_handle[index].focus_loop);
- g_thread_join(g_focus_sound_handle[index].focus_cb_thread);
- debug_warning("after thread join, thread[%p], mainloop[%p] for index(%d)",
- g_focus_sound_handle[index].focus_cb_thread, g_focus_sound_handle[index].focus_loop, index);
- g_focus_sound_handle[index].focus_cb_thread = NULL;
+ g_thread_join(*focus_cb_thread);
+ debug_warning("after thread join, thread[%p], mainloop[%p] for index(%d), is_for_watching(%d)",
+ *focus_cb_thread, g_focus_sound_handle[index].focus_loop, index, is_for_watching);
+ *focus_cb_thread = NULL;
}
g_main_loop_unref(g_focus_sound_handle[index].focus_loop);
g_focus_sound_handle[index].focus_loop = NULL;
}
g_main_loop_unref(g_focus_sound_handle[index].focus_loop);
g_focus_sound_handle[index].focus_loop = NULL;
return MM_ERROR_SOUND_INTERNAL;
}
return MM_ERROR_SOUND_INTERNAL;
}
-void focus_deinit_context(int index)
+void focus_deinit_context(int index, bool is_for_watching)
+ GThread **focus_cb_thread = NULL;
+
debug_fenter();
if (index < 0 || index >= FOCUS_HANDLE_MAX) {
debug_fenter();
if (index < 0 || index >= FOCUS_HANDLE_MAX) {
- if (!g_focus_sound_handle[index].focus_loop || !g_focus_sound_handle[index].focus_cb_thread) {
- debug_error("focus_loop[%p] or focus_cb_thread[%p] is null",
- g_focus_sound_handle[index].focus_loop, g_focus_sound_handle[index].focus_cb_thread);
+ if (!g_focus_sound_handle[index].focus_loop ||
+ (!is_for_watching && !g_focus_sound_handle[index].focus_cb_thread) ||
+ (is_for_watching && !g_focus_sound_handle[index].focus_watch_cb_thread)) {
+ debug_error("focus_loop[%p] or focus_cb_thread[%p] or focus_watch_cb_thread[%p] is null",
+ g_focus_sound_handle[index].focus_loop, g_focus_sound_handle[index].focus_cb_thread,
+ g_focus_sound_handle[index].focus_watch_cb_thread);
return;
}
g_main_loop_quit(g_focus_sound_handle[index].focus_loop);
return;
}
g_main_loop_quit(g_focus_sound_handle[index].focus_loop);
- g_thread_join(g_focus_sound_handle[index].focus_cb_thread);
- debug_warning("after thread join, thread[%p], mainloop[%p] for index(%d)",
- g_focus_sound_handle[index].focus_cb_thread, g_focus_sound_handle[index].focus_loop, index);
+
+ if (is_for_watching)
+ focus_cb_thread = &g_focus_sound_handle[index].focus_watch_cb_thread;
+ else
+ focus_cb_thread = &g_focus_sound_handle[index].focus_cb_thread;
+ g_thread_join(*focus_cb_thread);
+
+ debug_warning("after thread join, thread[%p], mainloop[%p] for index(%d), is_for_watching(%d)",
+ *focus_cb_thread, g_focus_sound_handle[index].focus_loop, index, is_for_watching);
g_main_loop_unref(g_focus_sound_handle[index].focus_loop);
g_focus_sound_handle[index].focus_loop = NULL;
g_main_loop_unref(g_focus_sound_handle[index].focus_loop);
g_focus_sound_handle[index].focus_loop = NULL;
- g_focus_sound_handle[index].focus_cb_thread = NULL;
+ *focus_cb_thread = NULL;
- mm_sound_client_is_focus_cb_thread(g_thread_self(), &is_in_focus_cb_thread);
+ mm_sound_client_is_focus_cb_thread(g_thread_self(), &is_in_focus_cb_thread, NULL);
if (!is_in_focus_cb_thread) {
if ((ret = mm_sound_focus_socket_acquire(pid, client_fd, id,
type, option, ext_info ? ext_info : "", true)))
if (!is_in_focus_cb_thread) {
if ((ret = mm_sound_focus_socket_acquire(pid, client_fd, id,
type, option, ext_info ? ext_info : "", true)))
- mm_sound_client_is_focus_cb_thread(g_thread_self(), &is_in_focus_cb_thread);
+ mm_sound_client_is_focus_cb_thread(g_thread_self(), &is_in_focus_cb_thread, NULL);
if (!is_in_focus_cb_thread) {
if ((ret = mm_sound_focus_socket_release(pid, client_fd, id, type, option, ext_info ? ext_info : "", true)))
debug_error("failed to mm_sound_focus_socket_release(), ret[0x%x]", ret);
if (!is_in_focus_cb_thread) {
if ((ret = mm_sound_focus_socket_release(pid, client_fd, id, type, option, ext_info ? ext_info : "", true)))
debug_error("failed to mm_sound_focus_socket_release(), ret[0x%x]", ret);
Name: libmm-sound
Summary: MMSound Package contains client lib and sound_server binary
Name: libmm-sound
Summary: MMSound Package contains client lib and sound_server binary
Release: 0
Group: System/Libraries
License: Apache-2.0
Release: 0
Group: System/Libraries
License: Apache-2.0