int testmode;
} server_arg;
-static int getOption(int argc, char **argv, server_arg *arg);
+static int get_option(int argc, char **argv, server_arg *arg);
static int usage(int argc, char **argv);
static struct sigaction sigint_action; /* Backup pointer of SIGINT handler */
action.sa_flags = 0;
sigemptyset(&action.sa_mask);
- if (getOption(argc, argv, &serveropt))
+ if (get_option(argc, argv, &serveropt))
return 1;
debug_warning("focus_server [%d] init \n", getpid());
return 0;
}
-static int getOption(int argc, char **argv, server_arg *arg)
+static int get_option(int argc, char **argv, server_arg *arg)
{
int c;
static struct option long_options[] = {
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_uniq_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, mm_sound_focus_changed_cb callback, bool is_for_session, void* user_data);
int mm_sound_client_unregister_focus(int id);
int mm_sound_client_acquire_focus(int id, mm_sound_focus_type_e type, const char *option);
} mm_sound_focus_type_e;
int mm_sound_focus_get_id(int *id);
+int mm_sound_focus_is_cb_thread(bool *result);
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, const char *additional_info, void *user_data);
int mm_sound_register_focus(int id, const char *stream_type, mm_sound_focus_changed_cb callback, void *user_data);
EXPORT_API
int mm_sound_volume_get_step(volume_type_t type, int *step)
{
- return MM_ERROR_SOUND_NOT_SUPPORTED_OPERATION;
+ return MM_ERROR_NOT_SUPPORT_API;
}
EXPORT_API
return ret;
}
+int mm_sound_client_is_focus_cb_thread(GThread *mine, bool *result)
+{
+ int ret = MM_ERROR_NONE;
+
+ if (!mine || !result)
+ ret = MM_ERROR_INVALID_ARGUMENT;
+ else {
+ if (mine == g_focus_thread)
+ *result = true;
+ else
+ *result = false;
+ }
+
+ return ret;
+}
+
int mm_sound_client_register_focus(int id, int pid, const char *stream_type, mm_sound_focus_changed_cb callback, bool is_for_session, void* user_data)
{
int ret = MM_ERROR_NONE;
int ret = MM_ERROR_NONE;
int instance;
int index = -1;
+
debug_fenter();
index = _focus_find_index_by_handle(id);
int mm_sound_client_dbus_is_route_available(mm_sound_route route, bool *is_available)
{
- int ret = MM_ERROR_NONE;
-
- debug_fenter();
- ret = MM_ERROR_SOUND_NOT_SUPPORTED_OPERATION;
- debug_fleave();
-
- return ret;
+ return MM_ERROR_NOT_SUPPORT_API;
}
int mm_sound_client_dbus_foreach_available_route_cb(mm_sound_available_route_cb avail_cb, void *user_data)
{
- int ret = MM_ERROR_NONE;
-
- debug_fenter();
- ret = MM_ERROR_SOUND_NOT_SUPPORTED_OPERATION;
- debug_fleave();
-
- return ret;
+ return MM_ERROR_NOT_SUPPORT_API;
}
int mm_sound_client_dbus_set_active_route(mm_sound_route route, bool need_broadcast)
{
- int ret = MM_ERROR_NONE;
-
- debug_fenter();
- ret = MM_ERROR_SOUND_NOT_SUPPORTED_OPERATION;
- debug_fleave();
-
- return ret;
+ return MM_ERROR_NOT_SUPPORT_API;
}
int mm_sound_client_dbus_get_active_device(mm_sound_device_in *device_in, mm_sound_device_out *device_out)
{
- int ret = MM_ERROR_NONE;
-
- debug_fenter();
- ret = MM_ERROR_SOUND_NOT_SUPPORTED_OPERATION;
- debug_fleave();
-
- return ret;
+ return MM_ERROR_NOT_SUPPORT_API;
}
int mm_sound_client_dbus_add_play_sound_end_callback(mm_sound_stop_callback_wrapper_func stop_cb, void* userdata, unsigned int *subs_id)
int mm_sound_client_dbus_add_active_device_changed_callback(const char *name, mm_sound_active_device_changed_cb func, void* user_data)
{
- int ret = MM_ERROR_NONE;
-
- debug_fenter();
- ret = MM_ERROR_SOUND_NOT_SUPPORTED_OPERATION;
- debug_fleave();
-
- return ret;
+ return MM_ERROR_NOT_SUPPORT_API;
}
int mm_sound_client_dbus_remove_active_device_changed_callback(const char *name)
{
- int ret = MM_ERROR_NONE;
-
- debug_fenter();
- ret = MM_ERROR_SOUND_NOT_SUPPORTED_OPERATION;
- debug_fleave();
-
- return ret;
+ return MM_ERROR_NOT_SUPPORT_API;
}
int mm_sound_client_dbus_add_available_route_changed_callback(mm_sound_available_route_changed_cb func, void* user_data)
{
- int ret = MM_ERROR_NONE;
-
- debug_fenter();
- ret = MM_ERROR_SOUND_NOT_SUPPORTED_OPERATION;
- debug_fleave();
-
- return ret;
+ return MM_ERROR_NOT_SUPPORT_API;
}
int mm_sound_client_dbus_remove_available_route_changed_callback(void)
{
- int ret = MM_ERROR_NONE;
-
- debug_fenter();
- ret = MM_ERROR_SOUND_NOT_SUPPORTED_OPERATION;
- debug_fleave();
-
- return ret;
+ return MM_ERROR_NOT_SUPPORT_API;
}
int mm_sound_client_dbus_set_sound_path_for_active_device(mm_sound_device_out device_out, mm_sound_device_in device_in)
{
- int ret = MM_ERROR_NONE;
-
- debug_fenter();
- ret = MM_ERROR_SOUND_NOT_SUPPORTED_OPERATION;
- debug_fleave();
-
- return ret;
+ return MM_ERROR_NOT_SUPPORT_API;
}
int mm_sound_client_dbus_set_active_route_auto(void)
{
- int ret = MM_ERROR_NONE;
-
- debug_fenter();
- ret = MM_ERROR_SOUND_NOT_SUPPORTED_OPERATION;
- debug_fleave();
-
- return ret;
+ return MM_ERROR_NOT_SUPPORT_API;
}
/*------------------------------------------ FOCUS --------------------------------------------------*/
#include "include/mm_sound_focus.h"
#include "focus_server/include/mm_sound_mgr_focus.h"
+#define RETURN_ERROR_IF_FOCUS_CB_THREAD(x_thread) \
+{ \
+ int ret = MM_ERROR_NONE; \
+ bool result = false; \
+ ret = mm_sound_client_is_focus_cb_thread(x_thread, &result); \
+ if (ret) \
+ return ret; \
+ else if (result) { \
+ debug_error("it might be called in the thread of focus callback, it is not allowed\n"); \
+ return MM_ERROR_SOUND_INVALID_OPERATION; \
+ } \
+} \
+
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;
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]\n", ret);
debug_fenter();
+ RETURN_ERROR_IF_FOCUS_CB_THREAD(g_thread_self());
+
ret = mm_sound_client_get_unique_id(id);
if (ret) {
debug_error("Failed to mm_sound_client_get_unique_id(), ret[0x%x]\n", ret);
}
EXPORT_API
+int mm_sound_focus_is_cb_thread(bool *result)
+{
+ int ret = MM_ERROR_NONE;
+
+ debug_fenter();
+
+ ret = mm_sound_client_is_focus_cb_thread(g_thread_self(), result);
+ if (!ret) {
+ if (*result)
+ debug_error("it might be called in the thread of focus callback, it is not allowed\n");
+ }
+
+ debug_fleave();
+
+ return ret;
+}
+
+EXPORT_API
int mm_sound_register_focus(int id, 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\n");
return MM_ERROR_INVALID_ARGUMENT;
debug_fenter();
+ RETURN_ERROR_IF_FOCUS_CB_THREAD(g_thread_self());
+
if (id < 0 || callback == NULL) {
debug_error("argument is not valid\n");
return MM_ERROR_INVALID_ARGUMENT;
return ret;
}
-
EXPORT_API
int mm_sound_unregister_focus(int id)
{
debug_fenter();
+ RETURN_ERROR_IF_FOCUS_CB_THREAD(g_thread_self());
+
if (id < 0) {
debug_error("argument is not valid\n");
return MM_ERROR_INVALID_ARGUMENT;
debug_fenter();
+ RETURN_ERROR_IF_FOCUS_CB_THREAD(g_thread_self());
+
if (id < 0) {
debug_error("argument is not valid\n");
return MM_ERROR_INVALID_ARGUMENT;
debug_fenter();
+ RETURN_ERROR_IF_FOCUS_CB_THREAD(g_thread_self());
+
if (id < 0) {
debug_error("argument is not valid\n");
return MM_ERROR_INVALID_ARGUMENT;
debug_fenter();
+ RETURN_ERROR_IF_FOCUS_CB_THREAD(g_thread_self());
+
if (callback == NULL || id == NULL) {
debug_error("argument is not valid\n");
return MM_ERROR_INVALID_ARGUMENT;
debug_fenter();
+ RETURN_ERROR_IF_FOCUS_CB_THREAD(g_thread_self());
+
if (callback == NULL || id == NULL) {
debug_error("argument is not valid\n");
return MM_ERROR_INVALID_ARGUMENT;
debug_fenter();
+ RETURN_ERROR_IF_FOCUS_CB_THREAD(g_thread_self());
+
ret = mm_sound_client_unset_focus_watch_callback(id);
if (ret) {
debug_error("Could not unset focus watch callback, id(%d), ret = %x\n", id, ret);
Name: libmm-sound
Summary: MMSound Package contains client lib and sound_server binary
-Version: 0.9.270
+Version: 0.9.271
Release: 0
Group: System/Libraries
License: Apache-2.0