#include <stdint.h>
#include <glib.h>
+#ifdef TIZEN_TV
+#include <vconf.h>
+#endif
+
#include <mm_error.h>
#include <mm_debug.h>
#include "include/mm_sound_common.h"
#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;
}
return MM_ERROR_SOUND_INTERNAL;
}
- if ((ret = mm_sound_dbus_emit_signal(AUDIO_PROVIDER_AUDIO_CLIENT, AUDIO_EVENT_CLIENT_SUBSCRIBED, params))) {
+ if ((ret = mm_sound_dbus_emit_signal(AUDIO_PROVIDER_AUDIO_CLIENT, AUDIO_EVENT_CLIENT_SUBSCRIBED, params)))
debug_error("dbus send signal for client subscribed failed");
- }
debug_fleave();
return ret;
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;
}
return MM_ERROR_SOUND_INTERNAL;
}
- if ((ret = mm_sound_dbus_emit_signal(AUDIO_PROVIDER_AUDIO_CLIENT, AUDIO_EVENT_CLIENT_HANDLED, params))) {
+ if ((ret = mm_sound_dbus_emit_signal(AUDIO_PROVIDER_AUDIO_CLIENT, AUDIO_EVENT_CLIENT_HANDLED, params)))
debug_error("dbus send signal for client handled failed");
- }
debug_fleave();
return ret;
}
+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, gboolean *is_running, int *stream_id, int *stream_num)
+{
+ const char *v_type;
+ GVariant *array_v;
+ GVariantIter iter, array_iter;
+ int i = 0;
+ int ret = MM_ERROR_NONE;
+
+ if (v == NULL) {
+ debug_error("Variant NULL");
+ return MM_ERROR_NONE;
+ }
+
+ v_type = g_variant_get_type_string(v);
+ if (g_variant_type_equal(v_type, "(isiisiibai)") == FALSE) {
+ debug_error("device variant type not matching '%s'", v_type);
+ return MM_ERROR_NONE;
+ }
+
+ g_variant_iter_init(&iter, v);
+ g_variant_iter_next(&iter, "i", device_id);
+ g_variant_iter_next(&iter, "&s", device_type);
+ g_variant_iter_next(&iter, "i", direction);
+ g_variant_iter_next(&iter, "i", state);
+ g_variant_iter_next(&iter, "&s", device_name);
+ g_variant_iter_next(&iter, "i", vendor_id);
+ g_variant_iter_next(&iter, "i", product_id);
+ g_variant_iter_next(&iter, "b", is_running);
+
+ array_v = g_variant_iter_next_value(&iter);
+ *stream_num = g_variant_iter_init(&array_iter, array_v);
+ if (*stream_num > MAX_STREAM_ON_DEVICE) {
+ debug_error("too many streams on device %d", *stream_num);
+ ret = MM_ERROR_SOUND_INTERNAL;
+ goto finish;
+ }
+
+ while (g_variant_iter_loop(&array_iter, "i", &stream_id[i++])) ;
+finish:
+ g_variant_unref(array_v);
+
+ return ret;
+}
+
/* This callback unmarshall general-formed paramters to subject specific parameters,
* and call proper callback */
static void dbus_callback(audio_event_t event, GVariant *params, void *userdata)
{
struct callback_data *cb_data = (struct callback_data*) userdata;
uint32_t event_id;
+ const char *name = NULL, *device_type = NULL;
+ int device_id, direction, state;
+ const gchar *v_type;
+ GVariantIter iter;
+ GVariant *device_v;
+ int stream_id[MAX_STREAM_ON_DEVICE];
+ int stream_num;
+ int vendor_id, product_id;
+ gboolean is_running = FALSE;
+
+ v_type = g_variant_get_type_string(params);
if (event == AUDIO_EVENT_VOLUME_CHANGED) {
char *volume_type_str = NULL, *direction = NULL;
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) {
- const char *name = NULL, *device_type = NULL;
gboolean is_connected = FALSE;
- int device_id, io_direction, state;
- g_variant_get(params, "(u(i&sii&s)b)", &event_id, &device_id, &device_type, &io_direction,
- &state, &name, &is_connected);
- ((mm_sound_device_connected_wrapper_cb)(cb_data->user_cb))(device_id, device_type, io_direction, state, name, is_connected, cb_data->user_data);
- _notify_signal_handled(event, event_id, cb_data->subs_id, g_variant_new("(ib)", device_id, is_connected));
+ if (g_variant_type_equal(v_type, "(u(isiisiibai)b)") == FALSE) {
+ debug_error("Device connection changed signature not matching : %s", v_type);
+ return ;
+ }
+ g_variant_iter_init(&iter, params);
+ g_variant_iter_next(&iter, "u", &event_id);
+ device_v = g_variant_iter_next_value(&iter);
+ if (parse_device_variant(device_v, &device_id, &device_type, &direction, &state,
+ &name, &vendor_id, &product_id, &is_running, stream_id, &stream_num) < 0) {
+ debug_error("Failed to parse device variant");
+ return ;
+ }
+ 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, (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) {
- const char *name = NULL, *device_type = NULL;
int changed_device_info_type = 0;
- int device_id, io_direction, state;
- g_variant_get(params, "(u(i&sii&s)i)", &event_id, &device_id, &device_type, &io_direction,
- &state, &name, &changed_device_info_type);
- ((mm_sound_device_info_changed_wrapper_cb)(cb_data->user_cb))(device_id, device_type, io_direction, state, name, changed_device_info_type, cb_data->user_data);
+ if (g_variant_type_equal(v_type, "(u(isiisiibai)i)") == FALSE) {
+ debug_error("Device information changed signature not matching : %s", v_type);
+ return ;
+ }
+
+ g_variant_iter_init(&iter, params);
+ g_variant_iter_next(&iter, "u", &event_id);
+ device_v = g_variant_iter_next_value(&iter);
+ if (parse_device_variant(device_v, &device_id, &device_type, &direction, &state,
+ &name, &vendor_id, &product_id, &is_running, stream_id, &stream_num) < 0) {
+ debug_error("Failed to parse device variant");
+ return ;
+ }
+ 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, (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) {
+ debug_error("Device state changed signature not matching : %s", v_type);
+ return ;
+ }
+
+ g_variant_iter_init(&iter, params);
+ g_variant_iter_next(&iter, "u", &event_id);
+ device_v = g_variant_iter_next_value(&iter);
+ if (parse_device_variant(device_v, &device_id, &device_type, &direction, &state,
+ &name, &vendor_id, &product_id, &is_running, stream_id, &stream_num) < 0) {
+ debug_error("Failed to parse device variant");
+ return ;
+ }
+
+ ((mm_sound_device_state_changed_wrapper_cb)(cb_data->user_cb))(device_id, device_type, direction,
+ 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) {
+ debug_error("Device state changed signature not matching : %s", v_type);
+ return ;
+ }
+
+ g_variant_iter_init(&iter, params);
+ g_variant_iter_next(&iter, "u", &event_id);
+ device_v = g_variant_iter_next_value(&iter);
+ if (parse_device_variant(device_v, &device_id, &device_type, &direction, &state,
+ &name, &vendor_id, &product_id, &is_running, stream_id, &stream_num) < 0) {
+ debug_error("Failed to parse device variant");
+ return ;
+ }
+
+ ((mm_sound_device_running_changed_wrapper_cb)(cb_data->user_cb))(device_id, device_type, direction,
+ 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);
}
}
int ret = MM_ERROR_NONE;
debug_fenter();
- if ((ret = mm_sound_dbus_signal_unsubscribe(subs_id)) != MM_ERROR_NONE) {
+ if ((ret = mm_sound_dbus_signal_unsubscribe(subs_id)) != MM_ERROR_NONE)
debug_error("remove test callback failed");
- }
debug_fleave();
return ret;
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;
+ }
+
+ 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 = NULL, *result = NULL;
+ gboolean _is_on;
+
+ debug_fenter();
+
+ if (!is_on) {
+ debug_error("Invalid Parameter, is_on null");
+ return MM_ERROR_INVALID_ARGUMENT;
+ }
+
+ if ((params = g_variant_new("(ii)", stream_id, device_id)) == NULL) {
+ debug_error("Construct Param for query is stream on device failed");
+ return MM_ERROR_SOUND_INTERNAL;
+ }
+
+ if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_DEVICE_MANAGER, AUDIO_METHOD_IS_STREAM_ON_DEVICE, params, &result)) != MM_ERROR_NONE) {
+ debug_error("is stream on device failed");
+ goto cleanup;
+ }
+
+ if (result) {
+ g_variant_get(result, "(b)", &_is_on);
+ debug_log("is_on : %d", _is_on);
+ *is_on = (bool)_is_on;
+ } else {
+ debug_error("reply null");
+ ret = MM_ERROR_SOUND_INTERNAL;
}
cleanup:
- if (result)
- g_variant_unref(result);
+ g_variant_unref(result);
debug_fleave();
return ret;
}
+#ifdef TIZEN_TV
+#define _VCONF_KEY_SOUND_SPEAKER_SELECTION "file/private/sound/feature/SpeakerSelection"
+#define _AUDIO_TV_OUTPUT_BT_HEADSET 5
+
+static mm_sound_device_t* _get_tv_bt_device(void)
+{
+ int speaker_value = 0;
+ mm_sound_device_t* device_item = NULL;
+
+ if (vconf_get_int(_VCONF_KEY_SOUND_SPEAKER_SELECTION, &speaker_value) == VCONF_ERROR) {
+ debug_error("vconf_get_int(%s) failed..", _VCONF_KEY_SOUND_SPEAKER_SELECTION);
+ return NULL;
+ }
+
+ debug_warning("speaker selection value = %d", speaker_value);
+ if (speaker_value != _AUDIO_TV_OUTPUT_BT_HEADSET)
+ return NULL;
+
+ device_item = g_malloc0(sizeof(mm_sound_device_t));
+ if (!device_item)
+ return NULL;
+
+ MMSOUND_STRNCPY(device_item->name, "BluetoothMedia", MAX_DEVICE_NAME_NUM);
+ MMSOUND_STRNCPY(device_item->type, "bt-a2dp", MAX_DEVICE_TYPE_STR_LEN);
+ device_item->id = 99;
+ device_item->io_direction = DEVICE_IO_DIRECTION_OUT;
+ device_item->state = DEVICE_STATE_ACTIVATED;
+ device_item->vendor_id = -1;
+ device_item->product_id = -1;
+ device_item->stream_num = -1;
+
+ return device_item;
+}
+#endif /* TIZEN_TV */
+
int mm_sound_proxy_get_current_connected_device_list(int device_flags, GList** device_list)
{
int ret = MM_ERROR_NONE;
g_variant_iter_init(&iter, child);
while (1) {
device_item = g_malloc0(sizeof(mm_sound_device_t));
- if (device_item && g_variant_iter_loop(&iter, "(i&sii&s)", &device_item->id, &device_type_tmp, &device_item->io_direction, &device_item->state, &device_name_tmp)) {
+ if (device_item && g_variant_iter_loop(&iter, "(i&sii&siib)",
+ &device_item->id, &device_type_tmp, &device_item->io_direction, &device_item->state,
+ &device_name_tmp, &device_item->vendor_id, &device_item->product_id, &device_item->is_running)) {
MMSOUND_STRNCPY(device_item->name, device_name_tmp, MAX_DEVICE_NAME_NUM);
MMSOUND_STRNCPY(device_item->type, device_type_tmp, MAX_DEVICE_TYPE_STR_LEN);
*device_list = g_list_append(*device_list, device_item);
- debug_log("Added device id(%d) type(%17s) direction(%d) state(%d) name(%s)", device_item->id, device_item->type,device_item->io_direction, device_item->state, device_item->name);
+ debug_log("Added device id(%d) type(%17s) direction(%d) state(%d) name(%s) vendor-id(%04x) product-id(%04x) is_running(%d)",
+ device_item->id, device_item->type, device_item->io_direction, device_item->state,
+ 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;
}
}
+
+#ifdef TIZEN_TV
+ device_item = _get_tv_bt_device();
+ if (device_item) {
+ *device_list = g_list_append(*device_list, device_item);
+ debug_msg("Added TV bt device id(%d) type(%17s) direction(%d) state(%d) name(%s) vendor-id(%04x) product-id(%04x)",
+ device_item->id, device_item->type, device_item->io_direction, device_item->state,
+ device_item->name, device_item->vendor_id, device_item->product_id);
+ }
+#endif /* TIZEN_TV */
+
cleanup:
- if (result)
- g_variant_unref(result);
+ g_variant_unref(result);
debug_fleave();
return ret;
}
-int mm_sound_proxy_add_device_connected_callback(int device_flags, mm_sound_device_connected_wrapper_cb func, void *userdata, mm_sound_proxy_userdata_free freefunc, unsigned *subs_id)
+int mm_sound_proxy_get_device_by_id(int device_id, mm_sound_device_t **device)
+{
+ int ret = MM_ERROR_NONE;
+ GVariant *params = NULL, *result = NULL;
+ mm_sound_device_t* device_item = NULL;
+ const gchar *device_name_tmp = NULL, *device_type_tmp = NULL;
+
+ debug_fenter();
+
+ if (!device || device_id < 1) {
+ debug_error("Invalid Parameter, device null or improper device id");
+ return MM_ERROR_INVALID_ARGUMENT;
+ }
+
+ if ((params = g_variant_new("(i)", device_id)) == NULL) {
+ debug_error("Construct Param for get device by id failed");
+ return MM_ERROR_SOUND_INTERNAL;
+ }
+
+ if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_DEVICE_MANAGER, AUDIO_METHOD_GET_DEVICE_BY_ID, params, &result)) != MM_ERROR_NONE) {
+ debug_error("get device by id failed");
+ ret = MM_ERROR_SOUND_NO_DATA;
+ goto cleanup;
+ }
+
+ if (result) {
+ if ((device_item = g_malloc0(sizeof(mm_sound_device_t))) == NULL) {
+ debug_error("Alloc device handle failed");
+ ret = MM_ERROR_SOUND_INTERNAL;
+ goto cleanup;
+ }
+
+ g_variant_get(result, "(i&sii&sii)",
+ &device_item->id, &device_type_tmp, &device_item->io_direction,
+ &device_item->state, &device_name_tmp,
+ &device_item->vendor_id, &device_item->product_id);
+ MMSOUND_STRNCPY(device_item->name, device_name_tmp, MAX_DEVICE_NAME_NUM);
+ MMSOUND_STRNCPY(device_item->type, device_type_tmp, MAX_DEVICE_TYPE_STR_LEN);
+ debug_log("Get device id(%d) type(%17s) direction(%d) state(%d) name(%s) vendor-id(%04x) product-id(%04x)",
+ device_item->id, device_item->type, device_item->io_direction,
+ device_item->state, device_item->name,
+ device_item->vendor_id, device_item->product_id);
+ device_item->stream_num = -1;
+ *device = device_item;
+ } else {
+ debug_error("reply null");
+ ret = MM_ERROR_SOUND_INTERNAL;
+ }
+
+cleanup:
+ g_variant_unref(result);
+
+ debug_fleave();
+ return ret;
+}
+
+int mm_sound_proxy_add_device_connected_callback(mm_sound_device_connected_wrapper_cb func, void *userdata, mm_sound_proxy_userdata_free freefunc, unsigned *subs_id)
{
int ret = MM_ERROR_NONE;
struct callback_data *cb_data;
return ret;
}
-int mm_sound_proxy_add_device_info_changed_callback(int device_flags, mm_sound_device_info_changed_wrapper_cb func, void* userdata, mm_sound_proxy_userdata_free freefunc, unsigned *subs_id)
+int mm_sound_proxy_add_device_info_changed_callback(mm_sound_device_info_changed_wrapper_cb func, void* userdata, mm_sound_proxy_userdata_free freefunc, unsigned *subs_id)
{
int ret = MM_ERROR_NONE;
struct callback_data *cb_data;
int ret = MM_ERROR_NONE;
debug_fenter();
- if ((ret = mm_sound_dbus_signal_unsubscribe(subs_id)) != MM_ERROR_NONE) {
+ if ((ret = mm_sound_dbus_signal_unsubscribe(subs_id)) != MM_ERROR_NONE)
debug_error("remove device info changed callback failed");
- }
+
+ debug_fleave();
+ return ret;
+}
+
+int mm_sound_proxy_add_device_state_changed_callback(mm_sound_device_state_changed_wrapper_cb func, void* userdata, mm_sound_proxy_userdata_free freefunc, unsigned *subs_id)
+{
+ int ret = MM_ERROR_NONE;
+ 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_DEVICE_MANAGER, AUDIO_EVENT_DEVICE_STATE_CHANGED, dbus_callback, cb_data, simple_callback_data_free_func, &cb_data->subs_id)) != MM_ERROR_NONE)
+ debug_error("Add device state changed callback failed");
+ else
+ *subs_id = cb_data->subs_id;
+
+ debug_fleave();
+ return ret;
+}
+
+int mm_sound_proxy_remove_device_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 device state changed callback failed");
+
+ debug_fleave();
+ return ret;
+}
+
+int mm_sound_proxy_add_device_running_changed_callback(mm_sound_device_running_changed_wrapper_cb func, void* userdata, mm_sound_proxy_userdata_free freefunc, unsigned *subs_id)
+{
+ int ret = MM_ERROR_NONE;
+ 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_DEVICE_MANAGER, AUDIO_EVENT_DEVICE_RUNNING_CHANGED, dbus_callback, cb_data, simple_callback_data_free_func, &cb_data->subs_id)) != MM_ERROR_NONE)
+ debug_error("Add device running changed callback failed");
+ else
+ *subs_id = cb_data->subs_id;
+
+ debug_fleave();
+ return ret;
+}
+
+int mm_sound_proxy_remove_device_running_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 device running changed callback failed");
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_ERROR"))
+ 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;
int ret = MM_ERROR_NONE;
debug_fenter();
- if ((ret = mm_sound_dbus_signal_unsubscribe(subs_id)) != MM_ERROR_NONE) {
+ if ((ret = mm_sound_dbus_signal_unsubscribe(subs_id)) != MM_ERROR_NONE)
debug_error("Remove Volume changed callback failed");
- }
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_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;
- int handle = 0;
- GVariant *params = NULL, *result = NULL;
- gboolean _enable_session = enable_session;
+ struct callback_data *cb_data;
- if (!codechandle) {
- debug_error("Param for play is null");
- return MM_ERROR_INVALID_ARGUMENT;
- }
+ 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();
- 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 {
+ 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();
+
+ 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, "(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");
+ ret = MM_ERROR_SOUND_INTERNAL;
}
-cleanup:
- if (result)
+ debug_fleave();
+ 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 ret = MM_ERROR_NONE;
+ char *reply = NULL;
+ GVariant *params = NULL, *result = NULL;
+
+ debug_fenter();
+
+ 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;
+ }
debug_fleave();
return ret;
}
-int mm_sound_proxy_play_tone_with_stream_info(int client_pid, int tone, char *stream_type, int stream_index, int volume, int repeat, int *codechandle)
+int mm_sound_proxy_unset_filter_by_type(const char *stream_type)
{
int ret = MM_ERROR_NONE;
- int handle = 0;
+ char *reply = NULL;
GVariant *params = NULL, *result = NULL;
debug_fenter();
- if (!codechandle) {
- debug_error("Param for play is null");
- return MM_ERROR_INVALID_ARGUMENT;
+ if ((params = g_variant_new("(s)", stream_type)) == NULL) {
+ debug_error("construct param for method call failed");
+ return MM_ERROR_SOUND_INTERNAL;
}
- 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;
- }
+ 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("Construct Param for method call failed");
+ debug_error("reply null");
+ if (ret == MM_ERROR_NONE)
+ ret = MM_ERROR_SOUND_INTERNAL;
+ }
+
+ 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 ret = MM_ERROR_NONE;
+ char *reply = NULL;
+ GVariant *params = NULL, *result = NULL;
+
+ debug_fenter();
+
+ 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;
}
-int mm_sound_proxy_play_sound(const char* filename, int tone, int repeat, int volume, int volume_config,
- int priority, int session_type, int session_options, int client_pid, int handle_route,
- bool enable_session, int *codechandle, char *stream_type, int stream_index)
+int mm_sound_proxy_play_tone_with_stream_info(int client_pid, int tone, char *stream_type, int stream_index, int volume, int repeat, int *codechandle)
{
int ret = MM_ERROR_NONE;
int handle = 0;
GVariant *params = NULL, *result = NULL;
- gboolean _enable_session = enable_session;
- if (!filename || !codechandle) {
+ debug_fenter();
+
+ if (!codechandle) {
debug_error("Param for play is null");
return MM_ERROR_INVALID_ARGUMENT;
}
- debug_fenter();
-
- params = g_variant_new("(siiiiiiiiibsi)", filename, tone, repeat, volume,
- volume_config, priority, session_type, session_options, client_pid, handle_route, _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 {
+ 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 ((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);
+ 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_play_sound_with_stream_info(const char* filename, int repeat, int volume,
- int priority, int client_pid, int handle_route, int *codechandle, char *stream_type, int stream_index)
+ int client_pid, int *codechandle, char *stream_type, int stream_index)
{
int ret = MM_ERROR_NONE;
int handle = 0;
debug_fenter();
- params = g_variant_new("(siiiiisi)", filename, repeat, volume,
- priority, client_pid, handle_route, 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;
int ret = MM_ERROR_NONE;
debug_fenter();
- if ((ret = mm_sound_dbus_signal_unsubscribe(subs_id)) != MM_ERROR_NONE) {
+ if ((ret = mm_sound_dbus_signal_unsubscribe(subs_id)) != MM_ERROR_NONE)
debug_error("Remove Play File End callback failed");
- }
debug_fleave();
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();
-
- 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) {
- debug_error("dbus emergent exit failed");
- goto cleanup;
- }
+#endif
+ 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 {
- debug_error("Construct Param for emergent exit signal failed");
- ret = MM_ERROR_SOUND_INTERNAL;
+ g_focus_sound_handle[index].client_fd = client_fd;
+ g_focus_sound_handle[index].handle = *id;
}
-cleanup:
-
debug_fleave();
+
return ret;
}
-/*------------------------------------------ FOCUS --------------------------------------------------*/
-#ifdef USE_FOCUS
-
-int mm_sound_proxy_get_unique_id(int *id)
+int mm_sound_proxy_unregister_focus(int index)
{
int ret = MM_ERROR_NONE;
- int res = 0;
- GVariant *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();
- 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);
- }
+ 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_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_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("(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_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_unregister_focus(int instance, int id, bool is_for_session)
+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();
- 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);
+ 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_set_foucs_reacquisition(int instance, int id, bool reacquisition)
+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;
- GVariant *params = NULL, *result = NULL;
+ 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();
- params = g_variant_new("(iib)", instance, id, reacquisition);
- 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");
- }
+ 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 {
- debug_error("Construct Param for method call failed");
- }
+ GVariant *params = NULL, *result = NULL;
+
+ 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_sound_dbus_method_call_to(AUDIO_PROVIDER_FOCUS_SERVER, AUDIO_METHOD_ACQUIRE_FOCUS, params, &result)) != MM_ERROR_NONE)
+ debug_error("dbus acquire focus 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_get_acquired_focus_stream_type(int focus_type, char **stream_type, int *option, char **ext_info)
+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;
- GVariant *params = NULL, *result = NULL;
+ 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();
- if (!(params = g_variant_new("(i)", focus_type))) {
- debug_error("Construct Param for method call failed");
- return MM_ERROR_SOUND_INTERNAL;
- }
+ 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;
- 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);
+ 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;
}
- } else {
- debug_error("dbus get stream type of acquired focus failed");
+
+ 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;
}
-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_update_stream_focus_status(int focus_id, unsigned int status)
{
int ret = MM_ERROR_NONE;
+ char *reply = NULL;
GVariant *params = NULL, *result = NULL;
debug_fenter();
- 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("(iu)", focus_id, status)) == 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)
+ 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_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_deliver_focus(int src_index, int dst_index, mm_sound_focus_type_e focus_type)
{
int ret = MM_ERROR_NONE;
- 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("(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 {
- 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_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, mm_sound_focus_changed_watch_cb callback, bool is_for_session, 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("(iiib)", instance, handle, type, is_for_session);
- 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;