#include "include/mm_sound_dbus.h"
#include "include/mm_sound_intf.h"
#include "include/mm_sound_focus_socket.h"
+#include "include/mm_sound_focus_private.h"
struct callback_data {
void *user_cb;
debug_fenter();
- if ((ret = mm_sound_dbus_get_event_name(event, &event_name) != MM_ERROR_NONE)) {
+ if ((ret = mm_sound_dbus_get_event_name(event, &event_name)) != MM_ERROR_NONE) {
debug_error("Failed to get event name");
return MM_ERROR_SOUND_INTERNAL;
}
debug_fenter();
- if ((ret = mm_sound_dbus_get_event_name(event, &event_name) != MM_ERROR_NONE)) {
+ if ((ret = mm_sound_dbus_get_event_name(event, &event_name)) != MM_ERROR_NONE) {
debug_error("Failed to get event name");
return MM_ERROR_SOUND_INTERNAL;
}
}
static int parse_device_variant(GVariant *v, int *device_id, const char **device_type, int *direction, int *state,
- const char **device_name, int *vendor_id, int *product_id, bool *is_running, int *stream_id, int *stream_num)
+ const char **device_name, int *vendor_id, int *product_id, gboolean *is_running, int *stream_id, int *stream_num)
{
const char *v_type;
GVariant *array_v;
int stream_id[MAX_STREAM_ON_DEVICE];
int stream_num;
int vendor_id, product_id;
- bool is_running = FALSE;
+ gboolean is_running = FALSE;
v_type = g_variant_get_type_string(params);
g_variant_get(params, "(&s&su)", &direction, &volume_type_str, &volume_level);
((mm_sound_volume_changed_wrapper_cb)(cb_data->user_cb))(direction, volume_type_str, volume_level, cb_data->user_data);
} else if (event == AUDIO_EVENT_DEVICE_CONNECTED) {
- bool is_connected = false;
+ gboolean is_connected = FALSE;
if (g_variant_type_equal(v_type, "(u(isiisiibai)b)") == FALSE) {
debug_error("Device connection changed signature not matching : %s", v_type);
g_variant_iter_next(&iter, "b", &is_connected);
((mm_sound_device_connected_wrapper_cb)(cb_data->user_cb))(device_id, device_type, direction,
- state, name, vendor_id, product_id, is_running, stream_id, stream_num, is_connected, cb_data->user_data);
- _notify_signal_handled(event, event_id, cb_data->subs_id, g_variant_new("(ib)", device_id, is_connected));
+ state, name, vendor_id, product_id, (bool)is_running, stream_id, stream_num, (bool)is_connected, cb_data->user_data);
+ _notify_signal_handled(event, event_id, cb_data->subs_id, g_variant_new("(ib)", device_id, (bool)is_connected));
} else if (event == AUDIO_EVENT_DEVICE_INFO_CHANGED) {
int changed_device_info_type = 0;
g_variant_iter_next(&iter, "i", &changed_device_info_type);
((mm_sound_device_info_changed_wrapper_cb)(cb_data->user_cb))(device_id, device_type, direction,
- state, name, vendor_id, product_id, is_running, stream_id, stream_num, changed_device_info_type, cb_data->user_data);
+ state, name, vendor_id, product_id, (bool)is_running, stream_id, stream_num, changed_device_info_type, cb_data->user_data);
} else if (event == AUDIO_EVENT_DEVICE_STATE_CHANGED) {
if (g_variant_type_equal(v_type, "(u(isiisiibai))") == FALSE) {
}
((mm_sound_device_state_changed_wrapper_cb)(cb_data->user_cb))(device_id, device_type, direction,
- state, name, vendor_id, product_id, is_running, stream_id, stream_num, cb_data->user_data);
+ state, name, vendor_id, product_id, (bool)is_running, stream_id, stream_num, cb_data->user_data);
} else if (event == AUDIO_EVENT_DEVICE_RUNNING_CHANGED) {
if (g_variant_type_equal(v_type, "(u(isiisiibai))") == FALSE) {
}
((mm_sound_device_running_changed_wrapper_cb)(cb_data->user_cb))(device_id, device_type, direction,
- state, name, vendor_id, product_id, is_running, stream_id, stream_num, cb_data->user_data);
+ state, name, vendor_id, product_id, (bool)is_running, stream_id, stream_num, cb_data->user_data);
} else if (event == AUDIO_EVENT_FOCUS_CHANGED) {
} else if (event == AUDIO_EVENT_FOCUS_WATCH) {
} else if (event == AUDIO_EVENT_TEST) {
int ended_handle = 0;
g_variant_get(params, "(i)", &ended_handle);
((mm_sound_stop_callback_wrapper_func)(cb_data->user_cb))(ended_handle, cb_data->user_data);
+ } else if (event == AUDIO_EVENT_DUCKING_STATE_CHANGED) {
+ int idx = 0;
+ int is_ducked = 0;
+
+ g_variant_get(params, "(ii)", &idx, &is_ducked);
+
+ ((mm_sound_ducking_state_changed_wrapper_cb)(cb_data->user_cb))(idx, is_ducked, cb_data->user_data);
}
}
debug_fenter();
- params = g_variant_new("(ii)", a, b);
- if (params) {
- if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_SOUND_SERVER, AUDIO_METHOD_TEST, params, &result)) != MM_ERROR_NONE) {
- debug_error("dbus test call failed");
- goto cleanup;
- }
- } else {
+ if ((params = g_variant_new("(ii)", a, b)) == NULL) {
debug_error("Construct Param for method call failed");
return MM_ERROR_SOUND_INTERNAL;
}
+ if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_SOUND_SERVER, AUDIO_METHOD_TEST, params, &result)) != MM_ERROR_NONE) {
+ debug_error("dbus test call failed");
+ g_variant_unref(result);
+ return ret;
+ }
+
if (result) {
g_variant_get(result, "(i)", &reply);
debug_log("reply : %d", reply);
*get = reply;
+ g_variant_unref(result);
} else {
debug_error("reply null");
+ ret = MM_ERROR_SOUND_INTERNAL;
}
-cleanup:
- if (result)
- g_variant_unref(result);
-
debug_fleave();
return ret;
}
int mm_sound_proxy_is_stream_on_device(int stream_id, int device_id, bool *is_on)
{
int ret = MM_ERROR_NONE;
- GVariant *params, *result;
+ GVariant *params = NULL, *result = NULL;
gboolean _is_on;
debug_fenter();
}
cleanup:
- if (params)
- g_variant_unref(params);
- if (result)
- g_variant_unref(result);
+ g_variant_unref(result);
debug_fleave();
return ret;
device_item->name, device_item->vendor_id, device_item->product_id, device_item->is_running);
device_item->stream_num = -1;
} else {
- if (device_item)
- g_free(device_item);
+ g_free(device_item);
break;
}
}
#endif /* TIZEN_TV */
cleanup:
- if (result)
- g_variant_unref(result);
+ g_variant_unref(result);
debug_fleave();
return ret;
}
cleanup:
- if (result)
- g_variant_unref(result);
+ g_variant_unref(result);
debug_fleave();
return ret;
debug_fenter();
- params = g_variant_new("(ssu)", direction, volume_type, volume_level);
- if (params) {
- if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_STREAM_MANAGER, AUDIO_METHOD_SET_VOLUME_LEVEL, params, &result)) != MM_ERROR_NONE) {
- debug_error("dbus set volume by type failed");
- goto cleanup;
- }
- } else {
+ if ((params = g_variant_new("(ssu)", direction, volume_type, volume_level)) == NULL) {
debug_error("Construct Param for method call failed");
return MM_ERROR_SOUND_INTERNAL;
}
+ if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_STREAM_MANAGER, AUDIO_METHOD_SET_VOLUME_LEVEL, params, &result)) != MM_ERROR_NONE) {
+ debug_error("dbus set volume by type failed");
+ g_variant_unref(result);
+ return ret;
+ }
+
if (result) {
g_variant_get(result, "(&s)", &reply);
debug_log("reply : %s", reply);
if (strcmp(reply, "STREAM_MANAGER_RETURN_OK"))
ret = MM_ERROR_SOUND_INTERNAL;
+ g_variant_unref(result);
} else {
debug_error("reply null");
+ ret = MM_ERROR_SOUND_INTERNAL;
}
-cleanup:
- if (result)
- g_variant_unref(result);
-
debug_fleave();
return ret;
}
else
*subs_id = cb_data->subs_id;
-
debug_fleave();
return ret;
return ret;
}
-int mm_sound_proxy_set_filter_by_type(const char *stream_type, const char *filter_name, const char *filter_parameters, const char *filter_group)
+int mm_sound_proxy_add_ducking_state_changed_callback(mm_sound_ducking_state_changed_wrapper_cb func, void* userdata, mm_sound_proxy_userdata_free freefunc, unsigned *subs_id)
{
int ret = MM_ERROR_NONE;
- char *reply = NULL;
+ struct callback_data *cb_data;
+
+ debug_fenter();
+
+ CB_DATA_NEW(cb_data, func, userdata, freefunc);
+
+ if ((ret = mm_sound_dbus_signal_subscribe_to(AUDIO_PROVIDER_STREAM_MANAGER, AUDIO_EVENT_DUCKING_STATE_CHANGED, dbus_callback, cb_data, simple_callback_data_free_func, &cb_data->subs_id)) != MM_ERROR_NONE)
+ debug_error("Add Duckding State changed callback failed");
+ else
+ *subs_id = cb_data->subs_id;
+
+ debug_fleave();
+
+ return ret;
+}
+
+int mm_sound_proxy_remove_ducking_state_changed_callback(unsigned subs_id)
+{
+ int ret = MM_ERROR_NONE;
+ debug_fenter();
+
+ if ((ret = mm_sound_dbus_signal_unsubscribe(subs_id)) != MM_ERROR_NONE)
+ debug_error("Remove Ducking State changed callback failed");
+
+ debug_fleave();
+ return ret;
+}
+
+int mm_sound_proxy_set_mute_by_type(const char *volume_type, bool mute)
+{
+ int ret = MM_ERROR_NONE;
+ char *reply = NULL, *direction = "out";
GVariant *params = NULL, *result = NULL;
debug_fenter();
- params = g_variant_new("(ssss)", filter_name, filter_parameters, filter_group, stream_type);
- if (params) {
- if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_STREAM_MANAGER, AUDIO_METHOD_SET_FILTER, params, &result)) != MM_ERROR_NONE) {
- debug_error("dbus set filter by type failed");
- goto cleanup;
- }
- } else {
- debug_error("construct param for method call failed");
+ if ((params = g_variant_new("(ssu)", direction, volume_type, (unsigned int)mute)) == NULL) {
+ debug_error("Construct Param for method call failed");
return MM_ERROR_SOUND_INTERNAL;
}
+ if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_STREAM_MANAGER, AUDIO_METHOD_SET_MUTE, params, &result)) != MM_ERROR_NONE) {
+ debug_error("dbus set mute by type failed");
+ g_variant_unref(result);
+ return ret;
+ }
+
if (result) {
- g_variant_get(result, "(&s)", &reply);
+ g_variant_get(result, "(&s)", &reply);
debug_log("reply : %s", reply);
if (strcmp(reply, "STREAM_MANAGER_RETURN_OK"))
ret = MM_ERROR_SOUND_INTERNAL;
+ g_variant_unref(result);
} else {
debug_error("reply null");
+ ret = MM_ERROR_SOUND_INTERNAL;
}
-cleanup:
- if (result)
- g_variant_unref(result);
-
debug_fleave();
return ret;
}
-int mm_sound_proxy_unset_filter_by_type(const char *stream_type)
+int mm_sound_proxy_set_filter_by_type(const char *stream_type, const char *filter_name, const char *filter_parameters, const char *filter_group)
{
int ret = MM_ERROR_NONE;
char *reply = NULL;
debug_fenter();
- params = g_variant_new("(s)", stream_type);
- if (params) {
- if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_STREAM_MANAGER, AUDIO_METHOD_UNSET_FILTER, params, &result)) != MM_ERROR_NONE) {
- debug_error("dbus unset filter by type failed");
- goto cleanup;
- }
- } else {
+ if ((params = g_variant_new("(ssss)", filter_name, filter_parameters, filter_group, stream_type)) == NULL) {
debug_error("construct param for method call failed");
return MM_ERROR_SOUND_INTERNAL;
}
+ if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_STREAM_MANAGER, AUDIO_METHOD_SET_FILTER, params, &result)) != MM_ERROR_NONE)
+ debug_error("dbus set filter by type failed");
+
+ /* stream-manager always returns a string as return value */
if (result) {
g_variant_get(result, "(&s)", &reply);
debug_log("reply : %s", reply);
if (strcmp(reply, "STREAM_MANAGER_RETURN_OK"))
ret = MM_ERROR_SOUND_INTERNAL;
+ g_variant_unref(result);
} else {
debug_error("reply null");
+ if (ret == MM_ERROR_NONE)
+ ret = MM_ERROR_SOUND_INTERNAL;
}
-cleanup:
- if (result)
- g_variant_unref(result);
-
debug_fleave();
return ret;
}
-int mm_sound_proxy_control_filter_by_type(const char *stream_type, const char *filter_name, const char *filter_controls)
+int mm_sound_proxy_unset_filter_by_type(const char *stream_type)
{
int ret = MM_ERROR_NONE;
char *reply = NULL;
debug_fenter();
- params = g_variant_new("(sss)", filter_name, filter_controls, stream_type);
- if (params) {
- if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_STREAM_MANAGER, AUDIO_METHOD_CONTROL_FILTER, params, &result)) != MM_ERROR_NONE) {
- debug_error("dbus control filter by type failed");
- goto cleanup;
- }
- } else {
+ if ((params = g_variant_new("(s)", stream_type)) == NULL) {
debug_error("construct param for method call failed");
return MM_ERROR_SOUND_INTERNAL;
}
+ if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_STREAM_MANAGER, AUDIO_METHOD_UNSET_FILTER, params, &result)) != MM_ERROR_NONE)
+ debug_error("dbus unset filter by type failed");
+
+ /* stream-manager always returns a string as return value */
if (result) {
g_variant_get(result, "(&s)", &reply);
debug_log("reply : %s", reply);
if (strcmp(reply, "STREAM_MANAGER_RETURN_OK"))
ret = MM_ERROR_SOUND_INTERNAL;
+ g_variant_unref(result);
} else {
debug_error("reply null");
+ if (ret == MM_ERROR_NONE)
+ ret = MM_ERROR_SOUND_INTERNAL;
}
-cleanup:
- if (result)
- g_variant_unref(result);
-
debug_fleave();
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 mm_sound_proxy_control_filter_by_type(const char *stream_type, const char *filter_name, const char *filter_controls)
{
int ret = MM_ERROR_NONE;
- int handle = 0;
+ char *reply = NULL;
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 ((params = g_variant_new("(sss)", filter_name, filter_controls, stream_type)) == NULL) {
+ debug_error("construct param for method call failed");
+ return MM_ERROR_SOUND_INTERNAL;
}
+ if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_STREAM_MANAGER, AUDIO_METHOD_CONTROL_FILTER, params, &result)) != MM_ERROR_NONE)
+ debug_error("dbus control filter by type failed");
+
+ /* stream-manager always returns a string as return value */
if (result) {
- g_variant_get(result, "(i)", &handle);
- debug_log("handle : %d", handle);
- *codechandle = handle;
+ g_variant_get(result, "(&s)", &reply);
+ debug_log("reply : %s", reply);
+ if (strcmp(reply, "STREAM_MANAGER_RETURN_OK"))
+ ret = MM_ERROR_SOUND_INTERNAL;
+ g_variant_unref(result);
} else {
debug_error("reply null");
+ if (ret == MM_ERROR_NONE)
+ ret = MM_ERROR_SOUND_INTERNAL;
}
-cleanup:
- if (result)
- g_variant_unref(result);
+ g_variant_unref(result);
debug_fleave();
return ret;
return MM_ERROR_INVALID_ARGUMENT;
}
- params = g_variant_new("(iiiisi)", tone, repeat, volume, client_pid, stream_type, stream_index);
- if (params) {
- if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_SOUND_SERVER, AUDIO_METHOD_PLAY_DTMF_WITH_STREAM_INFO, params, &result)) != MM_ERROR_NONE) {
- debug_error("dbus play tone failed");
- goto cleanup;
- }
- } else {
+ if ((params = g_variant_new("(iiiisi)", tone, repeat, volume, client_pid, stream_type, stream_index)) == NULL) {
debug_error("Construct Param for method call failed");
+ return MM_ERROR_SOUND_INTERNAL;
}
- if (result) {
- g_variant_get(result, "(i)", &handle);
- debug_log("handle : %d", handle);
- *codechandle = handle;
- } else {
- debug_error("reply null");
- }
-
-cleanup:
- if (result)
+ if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_SOUND_SERVER, AUDIO_METHOD_PLAY_DTMF_WITH_STREAM_INFO, params, &result)) != MM_ERROR_NONE) {
+ debug_error("dbus play tone failed");
g_variant_unref(result);
-
- debug_fleave();
- 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");
+ return ret;
}
if (result) {
g_variant_get(result, "(i)", &handle);
debug_log("handle : %d", handle);
*codechandle = handle;
+ g_variant_unref(result);
} else {
debug_error("reply null");
+ ret = MM_ERROR_SOUND_INTERNAL;
}
-cleanup:
- if (result)
- g_variant_unref(result);
-
debug_fleave();
return ret;
}
debug_fenter();
- params = g_variant_new("(siiisi)", filename, repeat, volume, client_pid, stream_type, stream_index);
- if (params) {
- if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_SOUND_SERVER, AUDIO_METHOD_PLAY_FILE_START_WITH_STREAM_INFO, params, &result)) != MM_ERROR_NONE) {
- debug_error("dbus play file failed");
- goto cleanup;
- }
- } else {
+ if ((params = g_variant_new("(siiisi)", filename, repeat, volume, client_pid, stream_type, stream_index)) == NULL) {
debug_error("Construct Param for method call failed");
+ return MM_ERROR_SOUND_INTERNAL;
+ }
+
+ if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_SOUND_SERVER, AUDIO_METHOD_PLAY_FILE_START_WITH_STREAM_INFO, params, &result)) != MM_ERROR_NONE) {
+ debug_error("dbus play file failed");
+ g_variant_unref(result);
+ return ret;
}
if (result) {
g_variant_get(result, "(i)", &handle);
debug_log("handle : %d", handle);
*codechandle = handle;
+ g_variant_unref(result);
} else {
debug_error("reply null");
+ ret = MM_ERROR_SOUND_INTERNAL;
}
-cleanup:
- if (result)
- g_variant_unref(result);
-
debug_fleave();
return ret;
-
-
}
int mm_sound_proxy_stop_sound(int handle)
debug_fenter();
- if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_SOUND_SERVER, AUDIO_METHOD_PLAY_FILE_STOP, g_variant_new("(i)", handle), &result)) != MM_ERROR_NONE) {
+ if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_SOUND_SERVER, AUDIO_METHOD_PLAY_FILE_STOP, g_variant_new("(i)", handle), &result)) != MM_ERROR_NONE)
debug_error("dbus stop file playing failed");
- goto cleanup;
- }
-cleanup:
- if (result)
- g_variant_unref(result);
-
- debug_fleave();
- 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);
+ g_variant_unref(result);
debug_fleave();
return ret;
return ret;
}
-int mm_sound_proxy_emergent_exit(int exit_pid)
+int mm_sound_proxy_register_focus(int index, const char *stream_type, int *id)
{
int ret = MM_ERROR_NONE;
- GVariant *params = NULL;
+ int pid = g_focus_sound_handle[index].focus_pid;
+ int client_fd = 0;
#ifndef TIZEN_TV
debug_fenter();
#endif
-
- params = g_variant_new("(i)", exit_pid);
- if (params) {
- if ((ret = mm_sound_dbus_emit_signal(AUDIO_PROVIDER_AUDIO_CLIENT, AUDIO_EVENT_EMERGENT_EXIT, params)) != MM_ERROR_NONE) {
-#ifndef TIZEN_TV
- debug_error("dbus emergent exit failed");
-#endif
- goto cleanup;
- }
+ ret = mm_sound_focus_socket_register(pid, stream_type, &client_fd, id);
+ if (ret) {
+ debug_error("failed to mm_sound_focus_socket_register(), ret[0x%x]", ret);
} else {
-#ifndef TIZEN_TV
- debug_error("Construct Param for emergent exit signal failed");
-#endif
- ret = MM_ERROR_SOUND_INTERNAL;
- }
-
-cleanup:
-
-#ifndef TIZEN_TV
- debug_fleave();
-#endif
- return ret;
-}
-
-/*------------------------------------------ FOCUS --------------------------------------------------*/
-#ifdef USE_FOCUS
-
-int mm_sound_proxy_get_unique_id(int *id)
-{
- int ret = MM_ERROR_NONE;
- int res = 0;
- GVariant *result = NULL;
-
- debug_fenter();
-
- if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_FOCUS_SERVER, AUDIO_METHOD_GET_UNIQUE_ID, NULL, &result)) != MM_ERROR_NONE)
- debug_error("dbus get unique id failed");
-
- if (result) {
- g_variant_get(result, "(i)", &res);
- *id = res;
- debug_msg("got unique id(%d)", *id);
- g_variant_unref(result);
+ g_focus_sound_handle[index].client_fd = client_fd;
+ g_focus_sound_handle[index].handle = *id;
}
debug_fleave();
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_unregister_focus(int index)
{
int ret = MM_ERROR_NONE;
- GVariant *params = NULL, *result = NULL;
+ int pid = g_focus_sound_handle[index].focus_pid;
+ int client_fd = g_focus_sound_handle[index].client_fd;
+ int id = g_focus_sound_handle[index].handle;
debug_fenter();
- params = g_variant_new("(iisb)", instance, id, stream_type, is_for_session);
- 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");
- } else {
- debug_error("Construct Param for method call failed");
- }
-
- if (ret != MM_ERROR_NONE)
- g_variant_get(result, "(i)", &ret);
- if (result)
- g_variant_unref(result);
+ ret = mm_sound_focus_socket_unregister(pid, client_fd, id);
+ if (ret)
+ debug_error("failed to mm_sound_focus_socket_unregister(), client_fd[%d], id[%d], ret[0x%x]", client_fd, id, ret);
debug_fleave();
return ret;
-
}
-int mm_sound_proxy_unregister_focus(int instance, int id, bool is_for_session)
+int mm_sound_proxy_set_focus_reacquisition(int index, bool reacquisition)
{
int ret = MM_ERROR_NONE;
- GVariant *params = NULL, *result = NULL;
+ int pid = g_focus_sound_handle[index].focus_pid;
+ int client_fd = g_focus_sound_handle[index].client_fd;
+ int id = g_focus_sound_handle[index].handle;
debug_fenter();
- params = g_variant_new("(iib)", instance, id, is_for_session);
- 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");
- } else {
- debug_error("Construct Param for method call failed");
- }
-
- if (ret != MM_ERROR_NONE)
- g_variant_get(result, "(i)", &ret);
- if (result)
- g_variant_unref(result);
-
- debug_fleave();
-
- return ret;
-}
-
-int mm_sound_proxy_set_focus_reacquisition(int instance, int id, bool reacquisition, bool is_for_session)
-{
- int ret = MM_ERROR_NONE;
- GVariant *params = NULL, *result = NULL;
-
- debug_fenter();
-
- params = g_variant_new("(iibb)", instance, id, reacquisition, is_for_session);
- 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");
- } else {
- debug_error("Construct Param for method call failed");
- }
-
- if (ret != MM_ERROR_NONE)
- g_variant_get(result, "(i)", &ret);
- if (result)
- g_variant_unref(result);
+ ret = mm_sound_focus_socket_set_reacquisition(pid, client_fd, id, reacquisition);
+ if (ret)
+ debug_error("failed to mm_sound_focus_socket_set_reacquisition(), ret[0x%x]", ret);
debug_fleave();
return ret;
int mm_sound_proxy_get_acquired_focus_stream_type(int focus_type, char **stream_type, int *option, char **ext_info)
{
int ret = MM_ERROR_NONE;
- GVariant *params = NULL, *result = NULL;
debug_fenter();
- if (!(params = g_variant_new("(i)", focus_type))) {
- debug_error("Construct Param for method call failed");
- return MM_ERROR_SOUND_INTERNAL;
- }
-
- if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_FOCUS_SERVER, AUDIO_METHOD_GET_ACQUIRED_FOCUS_STREAM_TYPE, params, &result)) == MM_ERROR_NONE) {
- if (result) {
- g_variant_get(result, "(sis)", stream_type, option, ext_info);
- g_variant_unref(result);
- }
- } else {
- debug_error("dbus get stream type of acquired focus failed");
- }
+ ret = mm_sound_focus_socket_get_acquired_focus_stream_type(focus_type, stream_type, option, ext_info);
+ if (ret)
+ debug_error("failed to mm_sound_focus_socket_get_acquired_focus_stream_type(), ret[0x%x]", ret);
debug_fleave();
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 index, mm_sound_focus_type_e type, int option, const char *ext_info)
{
int ret = MM_ERROR_NONE;
bool is_in_focus_cb_thread = false;
+ int pid = g_focus_sound_handle[index].focus_pid;
+ int client_fd = g_focus_sound_handle[index].client_fd;
+ int id = g_focus_sound_handle[index].handle;
debug_fenter();
- 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)))
+ 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)))
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);
- 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");
- } else {
+ if ((params = g_variant_new("(iiiis)", pid, id, type, option, ext_info ? ext_info : "")) == NULL) {
debug_error("Construct Param for method call failed");
+ return MM_ERROR_SOUND_INTERNAL;
}
- if (ret != MM_ERROR_NONE)
- g_variant_get(result, "(i)", &ret);
- if (result)
- g_variant_unref(result);
+ 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");
+
+ g_variant_unref(result);
}
debug_fleave();
+
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 index, mm_sound_focus_type_e type, int option, const char *ext_info)
{
int ret = MM_ERROR_NONE;
bool is_in_focus_cb_thread = false;
+ int pid = g_focus_sound_handle[index].focus_pid;
+ int client_fd = g_focus_sound_handle[index].client_fd;
+ int id = g_focus_sound_handle[index].handle;
debug_fenter();
- 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)))
+ 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);
} else {
GVariant *params = NULL, *result = NULL;
- params = g_variant_new("(iiiisb)", instance, id, type, option, ext_info ? ext_info : "", is_for_session);
- 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");
- } else {
+ if ((params = g_variant_new("(iiiis)", pid, id, type, option, ext_info ? ext_info : "")) == NULL) {
debug_error("Construct Param for method call failed");
+ return MM_ERROR_SOUND_INTERNAL;
}
- if (ret != MM_ERROR_NONE)
- g_variant_get(result, "(i)", &ret);
- if (result)
- g_variant_unref(result);
+ 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");
+
+ g_variant_unref(result);
}
debug_fleave();
+
return ret;
}
debug_fenter();
- params = g_variant_new("(iu)", focus_id, status);
- if (params) {
- if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_STREAM_MANAGER, AUDIO_METHOD_UPDATE_STREAM_FOCUS_STATUS, params, &result)) != MM_ERROR_NONE) {
- debug_error("dbus set volume by type failed");
- if (result) {
- g_variant_get(result, "(&s)", &reply);
- debug_log("reply : %s", reply);
- if (strcmp(reply, "STREAM_MANAGER_RETURN_OK"))
- ret = MM_ERROR_SOUND_INTERNAL;
- }
- }
- } else {
+ if ((params = g_variant_new("(iu)", focus_id, status)) == NULL) {
debug_error("Construct Param for method call failed");
return MM_ERROR_SOUND_INTERNAL;
}
- if (result)
+ if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_STREAM_MANAGER, AUDIO_METHOD_UPDATE_STREAM_FOCUS_STATUS, params, &result)) != MM_ERROR_NONE)
+ debug_error("dbus set volume by type failed");
+
+ /* stream-manager always returns a string as return value */
+ if (result) {
+ g_variant_get(result, "(&s)", &reply);
+ debug_log("reply : %s", reply);
+ if (strcmp(reply, "STREAM_MANAGER_RETURN_OK"))
+ ret = MM_ERROR_SOUND_INTERNAL;
g_variant_unref(result);
+ } else {
+ debug_error("reply null");
+ ret = MM_ERROR_SOUND_INTERNAL;
+ }
debug_fleave();
+
return ret;
}
-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_deliver_focus(int src_index, int dst_index, mm_sound_focus_type_e focus_type)
{
int ret = MM_ERROR_NONE;
- char *reply = NULL;
- GVariant *params = NULL, *result = NULL;
+ int pid = g_focus_sound_handle[src_index].focus_pid;
+ int src_client_fd = g_focus_sound_handle[src_index].client_fd;
+ int src_server_fd = g_focus_sound_handle[src_index].handle;
+ int dst_client_fd = g_focus_sound_handle[dst_index].client_fd;
+ int dst_server_fd = g_focus_sound_handle[dst_index].handle;
debug_fenter();
- params = g_variant_new("(iiii)", pid, src_id, dst_id, focus_type);
- if (params) {
- if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_FOCUS_SERVER, AUDIO_METHOD_DELIVER_FOCUS, params, &result)) != MM_ERROR_NONE) {
- debug_error("dbus deliver focus failed");
- if (result) {
- g_variant_get(result, "(&s)", &reply);
- debug_log("reply : %s", reply);
- if (strcmp(reply, "STREAM_MANAGER_RETURN_OK"))
- ret = MM_ERROR_SOUND_INTERNAL;
- }
- }
- } else {
- debug_error("Construct Param for method call failed");
- return MM_ERROR_SOUND_INTERNAL;
- }
-
- if (result)
- g_variant_unref(result);
+ ret = mm_sound_focus_socket_deliver(pid, src_client_fd, src_server_fd, dst_client_fd, dst_server_fd, focus_type);
+ if (ret)
+ debug_error("failed to mm_sound_focus_socket_deliver(), ret[0x%x]", ret);
debug_fleave();
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_add_focus_watch_callback(int index, mm_sound_focus_type_e type)
{
int ret = MM_ERROR_NONE;
- GVariant *params = NULL, *result = NULL;
+ int pid = g_focus_sound_handle[index].focus_pid;
+ int id = 0;
+ int client_fd = 0;
debug_fenter();
- params = g_variant_new("(iiibb)", instance, handle, type, is_for_session, is_for_monitor);
- 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");
+ ret = mm_sound_focus_socket_add_watch_cb(pid, type, &client_fd, &id);
+ if (ret) {
+ debug_error("failed to mm_sound_focus_socket_add_watch_cb(), ret[0x%x]", ret);
} else {
- debug_error("Construct Param for method call failed");
+ g_focus_sound_handle[index].handle = id;
+ g_focus_sound_handle[index].client_fd = client_fd;
}
- if (ret != MM_ERROR_NONE)
- g_variant_get(result, "(i)", &ret);
- if (result)
- g_variant_unref(result);
debug_fleave();
return ret;
-
}
-int mm_sound_proxy_unset_focus_watch_callback(int focus_tid, int handle, bool is_for_session)
+int mm_sound_proxy_remove_focus_watch_callback(int index)
{
int ret = MM_ERROR_NONE;
- GVariant *params = NULL, *result = NULL;
+ int pid = g_focus_sound_handle[index].focus_pid;
+ int client_fd = g_focus_sound_handle[index].client_fd;
+ int id = g_focus_sound_handle[index].handle;
debug_fenter();
- params = g_variant_new("(iib)", focus_tid, handle, is_for_session);
- 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");
- } else {
- debug_error("Construct Param for method call failed");
- }
- if (ret != MM_ERROR_NONE)
- g_variant_get(result, "(i)", &ret);
- if (result)
- g_variant_unref(result);
+ ret = mm_sound_focus_socket_remove_watch_cb(pid, client_fd, id);
+ if (ret)
+ debug_error("failed to mm_sound_focus_socket_remove_watch_cb(), ret[0x%x]", ret);
debug_fleave();
return ret;
}
-#endif /* USE_FOCUS */
-/*------------------------------------------ FOCUS --------------------------------------------------*/
-
int mm_sound_proxy_initialize(void)
{
int ret = MM_ERROR_NONE;