libmmfsound_la_SOURCES = mm_sound.c \
mm_sound_client.c \
- mm_sound_client_dbus.c \
+ mm_sound_proxy.c \
mm_sound_device.c \
mm_sound_pa_client.c
if USE_FOCUS
libmmfsoundcommon_la_SOURCES = mm_ipc.c \
mm_sound_utils.c \
+ mm_sound_dbus.c \
mm_source.c
#libmmfsoundcommon_la_DEPENDENCIES = $(libdir)/libmmfcommon.la
libmmfsoundcommon_la_CFLAGS = -I$(srcdir)/../include \
$(MMCOMMON_CFLAGS) \
+ $(GLIB2_CFLAGS) \
+ $(GIO_CFLAGS) \
$(VCONF_CFLAGS)
libmmfsoundcommon_la_LIBADD = $(MMCOMMON_LIBS) \
+ $(GLIB2_LIBS) \
+ $(GIO_LIBS) \
$(VCONF_LIBS)
#libmmfsound_la_LDFLAGS = -version-info 1:0:1
--- /dev/null
+
+#include <gio/gio.h>
+#include <glib.h>
+#include <stdlib.h>
+
+#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"
+
+#define INTERFACE_DBUS "org.freedesktop.DBus.Properties"
+#define SIGNAL_PROP_CHANGED "PropertiesChanged"
+#define METHOD_GET "Get"
+#define METHOD_SET "Set"
+
+struct callback_data {
+ mm_sound_dbus_callback user_cb;
+ void *user_data;
+ mm_sound_dbus_userdata_free free_func;
+};
+
+struct dbus_path {
+ char *bus_name;
+ char *object;
+ char *interface;
+};
+
+const struct dbus_path g_paths[AUDIO_PROVIDER_MAX] = {
+ [AUDIO_PROVIDER_SOUND_SERVER] = {
+ .bus_name = "org.tizen.SoundServer",
+ .object = "/org/tizen/SoundServer1",
+ .interface ="org.tizen.SoundServer1"
+ },
+ [AUDIO_PROVIDER_FOCUS_SERVER] = {
+ .bus_name = "org.tizen.FocusServer",
+ .object = "/org/tizen/FocusServer1",
+ .interface = "org.tizen.FocusServer1"
+ },
+ [AUDIO_PROVIDER_DEVICE_MANAGER] = {
+ .bus_name = "org.pulseaudio.Server",
+ .object = "/org/pulseaudio/DeviceManager",
+ .interface = "org.pulseaudio.DeviceManager"
+ },
+ [AUDIO_PROVIDER_STREAM_MANAGER] = {
+ .bus_name = "org.pulseaudio.Server",
+ .object = "/org/pulseaudio/StreamManager",
+ .interface = "org.pulseaudio.StreamManager"
+ },
+ [AUDIO_PROVIDER_AUDIO_CLIENT] = {
+ .bus_name = "org.tizen.AudioClient",
+ .object = "/org/tizen/AudioClient1",
+ .interface = "org.tizen.AudioClient1"
+ }
+};
+
+const mm_sound_dbus_method_info_t g_methods[AUDIO_METHOD_MAX] = {
+ [AUDIO_METHOD_TEST] = {
+ .name = "MethodTest1",
+ },
+ [AUDIO_METHOD_PLAY_FILE_START] = {
+ .name = "PlayFileStart",
+ },
+ [AUDIO_METHOD_PLAY_FILE_START_WITH_STREAM_INFO] = {
+ .name = "PlayFileStartWithStreamInfo",
+ },
+ [AUDIO_METHOD_PLAY_FILE_STOP] = {
+ .name = "PlayFileStop",
+ },
+ [AUDIO_METHOD_PLAY_DTMF] = {
+ .name = "PlayDTMF",
+ },
+ [AUDIO_METHOD_PLAY_DTMF_WITH_STREAM_INFO] = {
+ .name = "PlayDTMFWithStreamInfo",
+ },
+ [AUDIO_METHOD_CLEAR_FOCUS] = {
+ .name = "ClearFocus",
+ },
+ [AUDIO_METHOD_SET_VOLUME_LEVEL] = {
+ .name = "SetVolumeLevel",
+ },
+ [AUDIO_METHOD_GET_CONNECTED_DEVICE_LIST] = {
+ .name = "GetConnectedDeviceList",
+ },
+ [AUDIO_METHOD_GET_UNIQUE_ID] = {
+ .name = "GetUniqueId",
+ },
+ [AUDIO_METHOD_REGISTER_FOCUS] = {
+ .name = "RegisterFocus",
+ },
+ [AUDIO_METHOD_UNREGISTER_FOCUS] = {
+ .name = "UnregisterFocus",
+ },
+ [AUDIO_METHOD_SET_FOCUS_REACQUISITION] = {
+ .name = "SetFocusReacquisition",
+ },
+ [AUDIO_METHOD_GET_ACQUIRED_FOCUS_STREAM_TYPE] = {
+ .name = "GetAcquiredFocusStreamType",
+ },
+ [AUDIO_METHOD_ACQUIRE_FOCUS] = {
+ .name = "AcquireFocus",
+ },
+ [AUDIO_METHOD_RELEASE_FOCUS] = {
+ .name = "ReleaseFocus",
+ },
+ [AUDIO_METHOD_WATCH_FOCUS] = {
+ .name = "WatchFocus",
+ },
+ [AUDIO_METHOD_UNWATCH_FOCUS] = {
+ .name = "UnwatchFocus",
+ },
+ [AUDIO_METHOD_EMERGENT_EXIT_FOCUS] = {
+ .name = "EmergentExitFocus",
+ },
+};
+
+const mm_sound_dbus_signal_info_t g_events[AUDIO_EVENT_MAX] = {
+ [AUDIO_EVENT_TEST] = {
+ .name = "SignalTest1",
+ },
+ [AUDIO_EVENT_PLAY_FILE_END] = {
+ .name = "PlayFileEnd",
+ },
+ [AUDIO_EVENT_VOLUME_CHANGED] = {
+ .name = "VolumeChanged",
+ },
+ [AUDIO_EVENT_DEVICE_CONNECTED] = {
+ .name = "DeviceConnected",
+ },
+ [AUDIO_EVENT_DEVICE_INFO_CHANGED] = {
+ .name = "DeviceInfoChanged",
+ },
+ [AUDIO_EVENT_FOCUS_CHANGED] = {
+ .name = "FocusChanged",
+ },
+ [AUDIO_EVENT_FOCUS_WATCH] = {
+ .name = "FocusWatch",
+ }
+};
+
+/* Only For error types which is currently being used in server-side */
+static const GDBusErrorEntry mm_sound_error_entries[] =
+{
+ {MM_ERROR_OUT_OF_MEMORY, "org.tizen.multimedia.OutOfMemory"},
+ {MM_ERROR_OUT_OF_STORAGE, "org.tizen.multimedia.OutOfStorage"},
+ {MM_ERROR_INVALID_ARGUMENT, "org.tizen.multimedia.InvalidArgument"},
+ {MM_ERROR_POLICY_INTERNAL, "org.tizen.multimedia.PolicyInternal"},
+ {MM_ERROR_NOT_SUPPORT_API, "org.tizen.multimedia.NotSupportAPI"},
+ {MM_ERROR_POLICY_BLOCKED, "org.tizen.multimedia.PolicyBlocked"},
+ {MM_ERROR_END_OF_FILE, "org.tizen.multimedia.EndOfFile"},
+ {MM_ERROR_COMMON_OUT_OF_RANGE, "org.tizen.multimedia.common.OutOfRange"},
+ {MM_ERROR_COMMON_UNKNOWN, "org.tizen.multimedia.common.Unknown"},
+ {MM_ERROR_COMMON_NO_FREE_SPACE, "org.tizen.multimedia.common.NoFreeSpace"},
+ {MM_ERROR_SOUND_INTERNAL, "org.tizen.multimedia.audio.Internal"},
+ {MM_ERROR_SOUND_INVALID_STATE, "org.tizen.multimedia.audio.InvalidState"},
+ {MM_ERROR_SOUND_NO_FREE_SPACE, "org.tizen.multimedia.audio.NoFreeSpace"},
+ {MM_ERROR_SOUND_UNSUPPORTED_MEDIA_TYPE, "org.tizen.multimedia.audio.UnsupportedMediaType"},
+ {MM_ERROR_SOUND_INVALID_POINTER, "org.tizen.multimedia.audio.InvalidPointer"},
+ {MM_ERROR_SOUND_INVALID_FILE, "org.tizen.multimedia.audio.InvalidFile"},
+ {MM_ERROR_SOUND_FILE_NOT_FOUND, "org.tizen.multimedia.audio.FileNotFound"},
+ {MM_ERROR_SOUND_NO_DATA, "org.tizen.multimedia.audio.NoData"},
+ {MM_ERROR_SOUND_INVALID_PATH, "org.tizen.multimedia.audio.InvalidPath"},
+};
+
+
+/******************************************************************************************
+ Wrapper Functions of GDbus
+******************************************************************************************/
+
+static int _parse_error_msg(char *full_err_msg, char **err_name, char **err_msg)
+{
+ char *save_p, *domain, *_err_name, *_err_msg;
+
+ if (!(domain = strtok_r(full_err_msg, ":", &save_p))) {
+ debug_error("get domain failed");
+ return -1;
+ }
+ if (!(_err_name = strtok_r(NULL, ":", &save_p))) {
+ debug_error("get err name failed");
+ return -1;
+ }
+ if (!(_err_msg = strtok_r(NULL, ":", &save_p))) {
+ debug_error("get err msg failed");
+ return -1;
+ }
+
+ *err_name = _err_name;
+ *err_msg = _err_msg;
+
+ return 0;
+}
+
+static int _convert_error_name(const char *err_name)
+{
+ int i = 0;
+
+ for (i = 0; i < G_N_ELEMENTS(mm_sound_error_entries); i++) {
+ if (!strcmp(mm_sound_error_entries[i].dbus_error_name, err_name)) {
+ return mm_sound_error_entries[i].error_code;
+ }
+ }
+
+ return MM_ERROR_COMMON_UNKNOWN;
+}
+
+static int _dbus_method_call(GDBusConnection* conn, const char* bus_name, const char* object, const char* intf,
+ const char* method, GVariant* args, GVariant** result)
+{
+ int ret = MM_ERROR_NONE;
+ GError *err = NULL;
+ GVariant* dbus_reply = NULL;
+
+ if (!conn || !object || !intf || !method) {
+ debug_error("Invalid Argument");
+ if (!conn)
+ debug_error("conn null");
+ if (!object)
+ debug_error("object null");
+ if (!intf)
+ debug_error("intf null");
+ if (!method)
+ debug_error("method null");
+ return MM_ERROR_INVALID_ARGUMENT;
+ }
+
+ debug_log("Dbus call with obj'%s' intf'%s' method'%s'", object, intf, method);
+
+ dbus_reply = g_dbus_connection_call_sync(conn, bus_name, object , intf,
+ method, args ,
+ NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err );
+
+ if (!dbus_reply) {
+ char *err_name = NULL, *err_msg = NULL;
+ debug_log("Method Call '%s.%s' Failed, %s", intf, method, err->message);
+
+ if (_parse_error_msg(err->message, &err_name, &err_msg) < 0) {
+ debug_error("failed to parse error message");
+ g_error_free(err);
+ return MM_ERROR_SOUND_INTERNAL;
+ }
+ ret = _convert_error_name(err_name);
+ g_error_free(err);
+ }
+
+ debug_log("Method Call '%s.%s' Success", intf, method);
+ *result = dbus_reply;
+
+ return ret;
+}
+
+#if 0
+static int _dbus_set_property(GDBusConnection* conn, const char* bus_name, const char* object, const char* intf,
+ const char* prop, GVariant* args, GVariant** result)
+{
+ int ret = MM_ERROR_NONE;
+
+ if (!conn || !object || !intf || !prop) {
+ debug_error("Invalid Argument");
+ return MM_ERROR_INVALID_ARGUMENT;
+ }
+
+ debug_log("Dbus set property with obj'%s' intf'%s' prop'%s'", object, intf, prop);
+
+ if ((ret = _dbus_method_call(conn, bus_name, object, INTERFACE_DBUS, METHOD_SET,
+ g_variant_new("(ssv)", intf, prop, args), result)) != MM_ERROR_NONE) {
+ debug_error("Dbus call for set property failed");
+ }
+
+ return ret;
+}
+
+static int _dbus_get_property(GDBusConnection *conn, const char* bus_name, const char* object_name,
+ const char* intf_name, const char* prop, GVariant** result)
+{
+ int ret = MM_ERROR_NONE;
+
+ if (!conn || !object_name || !intf_name || !prop) {
+ debug_error("Invalid Argument");
+ return MM_ERROR_INVALID_ARGUMENT;
+ }
+
+ debug_log("Dbus get property with obj'%s' intf'%s' prop'%s'", object_name, intf_name, prop);
+
+ if ((ret = _dbus_method_call(conn,
+ bus_name, object_name, INTERFACE_DBUS, METHOD_GET,
+ g_variant_new("(ss)", intf_name, prop), result)) != MM_ERROR_NONE) {
+ debug_error("Dbus call for get property failed");
+ }
+
+ return ret;
+}
+#endif
+
+static int _dbus_subscribe_signal(GDBusConnection *conn, const char* object_name, const char* intf_name,
+ const char* signal_name, GDBusSignalCallback signal_cb, guint *subscribe_id, void* userdata, GDestroyNotify freefunc)
+{
+ guint subs_id = 0;
+
+ if (!conn || !object_name || !intf_name || !signal_name || !signal_cb) {
+ debug_error("Invalid Argument");
+ return MM_ERROR_INVALID_ARGUMENT;
+ }
+
+ debug_log("Dbus subscirbe signal with Obj'%s' Intf'%s' sig'%s'", object_name, intf_name, signal_name);
+
+ subs_id = g_dbus_connection_signal_subscribe(conn, NULL, intf_name, signal_name, object_name, \
+ NULL , G_DBUS_SIGNAL_FLAGS_NONE , signal_cb, userdata, NULL );
+
+ if (!subs_id) {
+ debug_error ("g_dbus_connection_signal_subscribe() failed ");
+ return MM_ERROR_SOUND_INTERNAL;
+ }
+ if (subscribe_id)
+ *subscribe_id = subs_id;
+
+ return MM_ERROR_NONE;
+}
+
+static void _dbus_unsubscribe_signal(GDBusConnection *conn, guint subs_id)
+{
+ if (!conn || !subs_id) {
+ debug_error("Invalid Argument");
+ return;
+ }
+
+ g_dbus_connection_signal_unsubscribe(conn, subs_id);
+}
+
+static GDBusConnection* _dbus_get_connection(GBusType bustype)
+{
+ static GDBusConnection *conn_system = NULL;
+ static GDBusConnection *conn_session = NULL;
+
+ if (bustype == G_BUS_TYPE_SYSTEM) {
+ if (conn_system) {
+ debug_log("Already connected to system bus");
+ } else {
+ debug_log("Get new connection on system bus");
+ conn_system = g_bus_get_sync(bustype, NULL, NULL);
+ }
+ return conn_system;
+ } else if (bustype == G_BUS_TYPE_SESSION) {
+ if (conn_session) {
+ debug_log("Already connected to session bus");
+ } else {
+ debug_log("Get new connection on session bus");
+ conn_session = g_bus_get_sync(bustype, NULL, NULL);
+ }
+ return conn_session;
+ } else {
+ debug_error("Invalid bus type");
+ return NULL;
+ }
+
+}
+
+#if 0
+static void _dbus_disconnect(GDBusConnection* conn)
+{
+ debug_fenter ();
+ g_object_unref(conn);
+ debug_fleave ();
+}
+#endif
+
+/******************************************************************************************
+ Simple Functions For Communicate with Sound-Server
+******************************************************************************************/
+
+EXPORT_API
+int mm_sound_dbus_method_call_to(audio_provider_t provider, audio_method_t method_type, GVariant *args, GVariant **result)
+{
+ int ret = MM_ERROR_NONE;
+ GDBusConnection *conn = NULL;
+
+ if (method_type < 0 || method_type >= AUDIO_METHOD_MAX) {
+ debug_error("Invalid method type : %d", method_type);
+ return MM_ERROR_INVALID_ARGUMENT;
+ }
+ if (provider < 0 || provider >= AUDIO_PROVIDER_MAX) {
+ debug_error("Invalid provider : %d", provider);
+ return MM_ERROR_INVALID_ARGUMENT;
+ }
+
+ if (!(conn = _dbus_get_connection(G_BUS_TYPE_SYSTEM))) {
+ debug_error("Get Dbus Connection Error");
+ return MM_ERROR_SOUND_INTERNAL;
+ }
+
+ if((ret = _dbus_method_call(conn, g_paths[provider].bus_name,
+ g_paths[provider].object,
+ g_paths[provider].interface,
+ g_methods[method_type].name,
+ args, result)) != MM_ERROR_NONE) {
+ debug_error("Dbus Call on Client Error");
+ }
+
+ return ret;
+}
+
+/* This callback only transform signal-callback to dbus non-related form (mm_sound_dbus_callback) */
+static void _dbus_signal_callback(GDBusConnection *connection,
+ const gchar *sender_name,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *signal_name,
+ GVariant *params,
+ gpointer userdata)
+{
+ struct callback_data *cb_data = (struct callback_data*) userdata;
+
+ debug_log("Signal(%s.%s) Received , Let's call Wrapper-Callback", interface_name, signal_name);
+
+ if (!strcmp(signal_name, g_events[AUDIO_EVENT_VOLUME_CHANGED].name)) {
+ (cb_data->user_cb)(AUDIO_EVENT_VOLUME_CHANGED, params, cb_data->user_data);
+ } else if (!strcmp(signal_name, g_events[AUDIO_EVENT_DEVICE_CONNECTED].name)) {
+ (cb_data->user_cb)(AUDIO_EVENT_DEVICE_CONNECTED, params, cb_data->user_data);
+ } else if (!strcmp(signal_name, g_events[AUDIO_EVENT_DEVICE_INFO_CHANGED].name)) {
+ (cb_data->user_cb)(AUDIO_EVENT_DEVICE_INFO_CHANGED, params, cb_data->user_data);
+ } else if (!strcmp(signal_name, g_events[AUDIO_EVENT_FOCUS_CHANGED].name)) {
+ (cb_data->user_cb)(AUDIO_EVENT_FOCUS_CHANGED, params, cb_data->user_data);
+ } else if (!strcmp(signal_name, g_events[AUDIO_EVENT_FOCUS_WATCH].name)) {
+ (cb_data->user_cb)(AUDIO_EVENT_FOCUS_WATCH, params, cb_data->user_data);
+ } else if (!strcmp(signal_name, g_events[AUDIO_EVENT_PLAY_FILE_END].name)) {
+ (cb_data->user_cb)(AUDIO_EVENT_PLAY_FILE_END, params, cb_data->user_data);
+ }
+}
+
+static void callback_data_free_func(gpointer data)
+{
+ struct callback_data *cb_data = (struct callback_data *) data;
+
+ cb_data->free_func(cb_data->user_data);
+ g_free(cb_data);
+}
+
+EXPORT_API
+int mm_sound_dbus_signal_subscribe_to(audio_provider_t provider, audio_event_t event, mm_sound_dbus_callback callback, void *userdata, mm_sound_dbus_userdata_free freefunc, unsigned *subs_id)
+{
+ GDBusConnection *conn = NULL;
+ guint _subs_id = 0;
+ struct callback_data *cb_data = NULL;
+
+ if (!callback) {
+ debug_error("Callback is Null");
+ return MM_ERROR_INVALID_ARGUMENT;
+ }
+
+ if (event < 0 || event >= AUDIO_EVENT_MAX) {
+ debug_error("Wrong event Type : %d", event);
+ return MM_ERROR_INVALID_ARGUMENT;
+ }
+
+ if (provider < 0 || provider >= AUDIO_PROVIDER_MAX) {
+ debug_error("Invalid provider : %d", provider);
+ return MM_ERROR_INVALID_ARGUMENT;
+ }
+
+ if (!(conn = _dbus_get_connection(G_BUS_TYPE_SYSTEM))) {
+ debug_error("Get Dbus Connection Error");
+ return MM_ERROR_SOUND_INTERNAL;
+ }
+
+ cb_data = (struct callback_data*) g_malloc0(sizeof(struct callback_data));
+ cb_data->user_cb = callback;
+ cb_data->user_data = userdata;
+ cb_data->free_func = freefunc;
+
+ if(_dbus_subscribe_signal(conn, g_paths[provider].object, g_paths[provider].interface, g_events[event].name,
+ _dbus_signal_callback, &_subs_id, cb_data, callback_data_free_func) != MM_ERROR_NONE) {
+ debug_error("Dbus Subscribe on Client Error");
+ goto fail;
+ }
+ if (subs_id)
+ *subs_id = (unsigned int)_subs_id;
+
+ return MM_ERROR_NONE;
+
+fail:
+ if (cb_data)
+ free(cb_data);
+ return MM_ERROR_SOUND_INTERNAL;
+}
+
+EXPORT_API
+int mm_sound_dbus_signal_unsubscribe(unsigned int subs_id)
+{
+ GDBusConnection *conn = NULL;
+
+ if (!(conn = _dbus_get_connection(G_BUS_TYPE_SYSTEM))) {
+ debug_error("Get Dbus Connection Error");
+ return MM_ERROR_SOUND_INTERNAL;
+ }
+
+ _dbus_unsubscribe_signal(conn, (guint) subs_id);
+
+ return MM_ERROR_NONE;
+}
+
+EXPORT_API
+int mm_sound_dbus_emit_signal(audio_provider_t provider, audio_event_t event, GVariant *param)
+{
+ GDBusConnection *conn;
+ GError *err = NULL;
+ gboolean dbus_ret;
+ int ret = MM_ERROR_NONE;
+
+ if (event < 0 || event >= AUDIO_EVENT_MAX) {
+ debug_error ("invalid argument, event_type(%d)", event);
+ ret = MM_ERROR_INVALID_ARGUMENT;
+ goto end;
+ }
+
+ if (!(conn = _dbus_get_connection(G_BUS_TYPE_SYSTEM))) {
+ debug_error("Get Dbus Connection Error");
+ ret = MM_ERROR_SOUND_INTERNAL;
+ goto end;
+ }
+
+ dbus_ret = g_dbus_connection_emit_signal (conn,
+ g_paths[provider].bus_name, g_paths[provider].object,
+ g_paths[provider].interface, g_events[event].name,
+ param, &err);
+ if (!dbus_ret) {
+ debug_error ("g_dbus_connection_emit_signal() error (%s)", err->message);
+ ret = MM_ERROR_SOUND_INTERNAL;
+ }
+
+end:
+ debug_msg ("emit signal for [%s] %s", g_events[event].name, (ret == MM_ERROR_NONE ? "success" : "failed") );
+ return ret;
+}
+
#include "../include/mm_sound_stream.h"
-int mm_sound_mgr_focus_dbus_send_signal_freeze (char* command, int pid);
-
int __mm_sound_mgr_focus_dbus_get_stream_list(stream_list_t* stream_list);
int MMSoundMgrFocusDbusInit(void);
#ifndef __MM_SOUND_MGR_FOCUS_IPC_H__
#define __MM_SOUND_MGR_FOCUS_IPC_H__
-#include "../../include/mm_sound_msg.h"
+#include <stdbool.h>
#ifdef SUPPORT_CONTAINER
#include "include/mm_sound_mgr_focus_dbus.h"
#include "include/mm_sound_mgr_focus_ipc.h"
+#include "../include/mm_sound_dbus.h"
#define BUS_NAME_FOCUS_SERVER "org.tizen.FocusServer"
/* TODO : generate introspection xml automatically, with these value include argument and reply */
/* TODO : argument check with these information */
/* TODO : divide object and interface with features (ex. play, path, device, focus, asm) */
-struct mm_sound_mgr_focus_dbus_method methods[METHOD_CALL_MAX] = {
- [METHOD_CALL_GET_UNIQUE_ID] = {
+mm_sound_dbus_method_intf_t methods[AUDIO_METHOD_MAX] = {
+ [AUDIO_METHOD_GET_UNIQUE_ID] = {
.info = {
.name = "GetUniqueId",
},
.handler = handle_method_get_unique_id
},
- [METHOD_CALL_REGISTER_FOCUS] = {
+ [AUDIO_METHOD_REGISTER_FOCUS] = {
.info = {
.name = "RegisterFocus",
},
.handler = handle_method_register_focus
},
- [METHOD_CALL_UNREGISTER_FOCUS] = {
+ [AUDIO_METHOD_UNREGISTER_FOCUS] = {
.info = {
.name = "UnregisterFocus",
},
.handler = handle_method_unregister_focus
},
- [METHOD_CALL_SET_FOCUS_REACQUISITION] = {
+ [AUDIO_METHOD_SET_FOCUS_REACQUISITION] = {
.info = {
.name = "SetFocusReacquisition",
},
.handler = handle_method_set_focus_reacquisition
},
- [METHOD_CALL_GET_ACQUIRED_FOCUS_STREAM_TYPE] = {
+ [AUDIO_METHOD_GET_ACQUIRED_FOCUS_STREAM_TYPE] = {
.info = {
.name = "GetAcquiredFocusStreamType",
},
.handler = handle_method_get_acquired_focus_stream_type
},
- [METHOD_CALL_ACQUIRE_FOCUS] = {
+ [AUDIO_METHOD_ACQUIRE_FOCUS] = {
.info = {
.name = "AcquireFocus",
},
.handler = handle_method_acquire_focus
},
- [METHOD_CALL_RELEASE_FOCUS] = {
+ [AUDIO_METHOD_RELEASE_FOCUS] = {
.info = {
.name = "ReleaseFocus",
},
.handler = handle_method_release_focus
},
- [METHOD_CALL_WATCH_FOCUS] = {
+ [AUDIO_METHOD_WATCH_FOCUS] = {
.info = {
.name = "WatchFocus",
},
.handler = handle_method_watch_focus
},
- [METHOD_CALL_UNWATCH_FOCUS] = {
+ [AUDIO_METHOD_UNWATCH_FOCUS] = {
.info = {
.name = "UnwatchFocus",
},
.handler = handle_method_unwatch_focus
},
- [METHOD_CALL_EMERGENT_EXIT_FOCUS] = {
+ [AUDIO_METHOD_EMERGENT_EXIT_FOCUS] = {
.info = {
.name = "EmergentExitFocus",
},
},
};
-
-struct mm_sound_mgr_focus_dbus_signal signals[SIGNAL_MAX] = {
- [SIGNAL_TEST] = {
- .info = {
- .name = "SignalTest1",
- },
- },
- [SIGNAL_FOCUS_CHANGED] = {
- .info = {
- .name = "FocusChanged",
- },
- },
- [SIGNAL_FOCUS_WATCH] = {
- .info = {
- .name = "FocusWatch",
- },
- }
-};
-
-
static GDBusNodeInfo *introspection_data = NULL;
guint focus_server_owner_id ;
}
debug_log("Method Call, obj : %s, intf : %s, method : %s", object_path, interface_name, method_name);
- for (method_idx = METHOD_CALL_GET_UNIQUE_ID; method_idx < METHOD_CALL_MAX; method_idx++) {
+ for (method_idx = AUDIO_METHOD_GET_UNIQUE_ID; method_idx < AUDIO_METHOD_MAX; method_idx++) {
if (!g_strcmp0(method_name, methods[method_idx].info.name)) {
methods[method_idx].handler(invocation);
}
#include "include/mm_sound_mgr_focus_dbus.h"
#include "../include/mm_sound_common.h"
-#include "../include/mm_sound_msg.h"
#include "include/mm_sound_mgr_focus.h"
#include <mm_error.h>
#include <mm_debug.h>
+++ /dev/null
-
-
-#ifndef __MM_SOUND_CLIENT_DBUS_H__
-#define __MM_SOUND_CLIENT_DBUS_H__
-
-#include "mm_sound_private.h"
-#include "mm_sound_device.h"
-#ifdef USE_FOCUS
-#include "mm_sound_focus.h"
-#endif
-#include "include/mm_sound_client.h"
-
-int mm_sound_client_dbus_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_client_dbus_play_tone_with_stream_info(int client_pid, int tone, char *stream_type, int stream_id, int volume, int repeat, int *codechandle);
-int mm_sound_client_dbus_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_client_dbus_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 mm_sound_client_dbus_stop_sound(int handle);
-int mm_sound_client_dbus_clear_focus(int pid); // Not original focus feature, only for cleaning up tone/wav player internal focus usage.
-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_remove_play_sound_end_callback(unsigned int subs_id);
-int mm_sound_client_dbus_get_current_connected_device_list(int device_flags, GList** device_list);
-int mm_sound_client_dbus_add_device_connected_callback(int device_flags, mm_sound_device_connected_wrapper_cb func, void* user_data, unsigned int *subs_id);
-int mm_sound_client_dbus_remove_device_connected_callback(unsigned int subs_id);
-int mm_sound_client_dbus_add_device_info_changed_callback(int device_flags, mm_sound_device_info_changed_wrapper_cb func, void* user_data, unsigned int *subs_id);
-int mm_sound_client_dbus_remove_device_info_changed_callback(unsigned int subs_id);
-int mm_sound_client_dbus_set_volume_by_type(const char *volume_type, const unsigned int volume_level);
-int mm_sound_client_dbus_add_volume_changed_callback(mm_sound_volume_changed_wrapper_cb func, void* user_data, unsigned int *subs_id);
-int mm_sound_client_dbus_remove_volume_changed_callback(unsigned int subs_id);
-
-#ifdef USE_FOCUS
-int mm_sound_client_dbus_get_unique_id(int *id);
-int mm_sound_client_dbus_register_focus(int id, int instance, const char *stream_type, mm_sound_focus_changed_cb callback, bool is_for_session, void* user_data);
-int mm_sound_client_dbus_unregister_focus(int instance, int id, bool is_for_session);
-int mm_sound_client_dbus_set_foucs_reacquisition(int instance, int id, bool reacquisition);
-int mm_sound_client_dbus_get_acquired_focus_stream_type(int focus_type, char **stream_type, char **additional_info);
-int mm_sound_client_dbus_acquire_focus(int instance, int id, mm_sound_focus_type_e type, const char *option, bool is_for_session);
-int mm_sound_client_dbus_release_focus(int instance, int id, mm_sound_focus_type_e type, const char *option, bool is_for_session);
-int mm_sound_client_dbus_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 *user_data);
-int mm_sound_client_dbus_unset_focus_watch_callback(int focus_tid, int handle, bool is_for_session);
-int mm_sound_client_dbus_emergent_exit_focus(int exit_pid);
-#endif
-
-int mm_sound_client_dbus_add_test_callback(mm_sound_test_cb func, void* user_data, unsigned int *subs_id);
-int mm_sound_client_dbus_remove_test_callback(unsigned int subs_id);
-int mm_sound_client_dbus_test(int a, int b, int* get);
-
-int mm_sound_client_dbus_initialize(void);
-int mm_sound_client_dbus_finalize(void);
-
-#endif /* __MM_SOUND_CLIENT_DBUS_H__ */
--- /dev/null
+/*
+ * libmm-sound
+ *
+ * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Seungbae Shin <seungbae.shin@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * @file mm_sound_dbus.h
+ * @brief Internal dbus utility library for audio module.
+ * @date
+ * @version Release
+ *
+ * Internal dbus utility library for audio module.
+ * Audio modules can use dbus simply without using dbus library directly.
+ */
+
+#ifndef __MM_SOUND_DBUS_H__
+#define __MM_SOUND_DBUS_H__
+
+#include <gio/gio.h>
+#include "include/mm_sound_intf.h"
+
+typedef void (*mm_sound_dbus_callback)(audio_event_t event, GVariant *param, void *userdata);
+typedef void (*mm_sound_dbus_userdata_free) (void *data);
+
+int mm_sound_dbus_method_call_to(audio_provider_t provider, audio_method_t method_type, GVariant *args, GVariant **result);
+int mm_sound_dbus_signal_subscribe_to(audio_provider_t provider, audio_event_t event, mm_sound_dbus_callback callback, void *userdata, mm_sound_dbus_userdata_free freefunc, unsigned *subs_id);
+int mm_sound_dbus_signal_unsubscribe(unsigned subs_id);
+int mm_sound_dbus_emit_signal(audio_provider_t provider, audio_event_t event, GVariant *param);
+
+typedef void (*dbus_method_handler)(GDBusMethodInvocation *invocation);
+typedef int (*dbus_signal_sender)(GDBusConnection *conn, GVariant *parameter);
+
+typedef struct mm_sound_dbus_method_info{
+ const char* name;
+ /*
+ const char* argument;
+ const char* reply;
+ */
+} mm_sound_dbus_method_info_t;
+
+typedef struct mm_sound_dbus_signal_info{
+ const char* name;
+ const char* argument;
+} mm_sound_dbus_signal_info_t;
+
+typedef struct mm_sound_dbus_method_intf {
+ struct mm_sound_dbus_method_info info;
+ dbus_method_handler handler;
+} mm_sound_dbus_method_intf_t;
+
+typedef struct mm_sound_dbus_signal_intf {
+ struct mm_sound_dbus_signal_info info;
+ dbus_signal_sender sender;
+} mm_sound_dbus_signal_intf_t;
+
+#endif /* __MM_SOUND_DBUS_H__ */
#define __MM_SOUND_DEVICE_H__
#include <glib.h>
+#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
--- /dev/null
+/*
+ * libmm-sound
+ *
+ * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Seungbae Shin <seungbae.shin@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * @file mm_sound_intf.h
+ * @brief Internal audio interfaces for audio module.
+ * @date
+ * @version Release
+ *
+ * Internal audio interfaces for audio module.
+ * Client or Service providers can request(or handle) services,
+ * or be notified events.
+ */
+
+#ifndef __MM_SOUND_INTF_H__
+#define __MM_SOUND_INTF_H__
+
+/* audio service(methods, signals) providers */
+typedef enum audio_provider {
+ AUDIO_PROVIDER_SOUND_SERVER,
+ AUDIO_PROVIDER_DEVICE_MANAGER,
+ AUDIO_PROVIDER_STREAM_MANAGER,
+ AUDIO_PROVIDER_FOCUS_SERVER,
+ AUDIO_PROVIDER_AUDIO_CLIENT,
+ AUDIO_PROVIDER_MAX
+} audio_provider_t;
+
+typedef enum audio_method {
+ AUDIO_METHOD_TEST,
+ AUDIO_METHOD_PLAY_FILE_START,
+ AUDIO_METHOD_PLAY_FILE_START_WITH_STREAM_INFO,
+ AUDIO_METHOD_PLAY_FILE_STOP,
+ AUDIO_METHOD_PLAY_DTMF,
+ AUDIO_METHOD_PLAY_DTMF_WITH_STREAM_INFO,
+ AUDIO_METHOD_CLEAR_FOCUS, // Not original focus feature, only for tone/wav player internal focus usage.
+ AUDIO_METHOD_GET_BT_A2DP_STATUS,
+ AUDIO_METHOD_SET_PATH_FOR_ACTIVE_DEVICE,
+ AUDIO_METHOD_GET_CONNECTED_DEVICE_LIST,
+ AUDIO_METHOD_GET_AUDIO_PATH,
+ AUDIO_METHOD_SET_VOLUME_LEVEL,
+
+ AUDIO_METHOD_GET_UNIQUE_ID,
+ AUDIO_METHOD_REGISTER_FOCUS,
+ AUDIO_METHOD_UNREGISTER_FOCUS,
+ AUDIO_METHOD_SET_FOCUS_REACQUISITION,
+ AUDIO_METHOD_GET_ACQUIRED_FOCUS_STREAM_TYPE,
+ AUDIO_METHOD_ACQUIRE_FOCUS,
+ AUDIO_METHOD_RELEASE_FOCUS,
+ AUDIO_METHOD_WATCH_FOCUS,
+ AUDIO_METHOD_UNWATCH_FOCUS,
+ AUDIO_METHOD_EMERGENT_EXIT_FOCUS,
+
+ AUDIO_METHOD_MAX
+} audio_method_t;
+
+typedef enum audio_event {
+ AUDIO_EVENT_TEST,
+ AUDIO_EVENT_PLAY_FILE_END,
+ AUDIO_EVENT_VOLUME_CHANGED,
+ AUDIO_EVENT_DEVICE_CONNECTED,
+ AUDIO_EVENT_DEVICE_INFO_CHANGED,
+ AUDIO_EVENT_FOCUS_CHANGED,
+ AUDIO_EVENT_FOCUS_WATCH,
+ AUDIO_EVENT_MAX
+} audio_event_t;
+
+#endif /* __MM_SOUND_INTF_H__ */
+++ /dev/null
-/*
- * libmm-sound
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Seungbae Shin <seungbae.shin@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef __MM_SOUND_MSG_H__
-#define __MM_SOUND_MSG_H__
-
-#include <sys/time.h>
-#include <unistd.h>
-#include <mm_ipc.h>
-
-#define KEY_BASE_PATH "/tmp"
-#define RCV_MSG 0x21 /* rcv key */
-#define SND_MSG 0x24 /* snd key */
-#define CB_MSG 0x64 /* cb key */
-#define RCV_CB_MSG 0x41 /* cb rcv key */
-#define SND_CB_MSG 0x44 /* cb snd key */
-
-#define MEMTYPE_SUPPORT_MAX (1024 * 1024) /* 1MB */
-
-enum {
- MM_SOUND_MSG_REQ_FILE = 1,
- MM_SOUND_MSG_REQ_MEMORY = 2,
- MM_SOUND_MSG_REQ_STOP = 3,
- MM_SOUND_MSG_RES_FILE = 4,
- MM_SOUND_MSG_RES_MEMORY = 5,
- MM_SOUND_MSG_RES_STOP = 6,
- MM_SOUND_MSG_INF_STOP_CB = 7,
- MM_SOUND_MSG_RES_ERROR = 8,
- MM_SOUND_MSG_INF_DESTROY_CB = 9,
-#ifdef PULSE_CLIENT
- MM_SOUND_MSG_REQ_GET_AUDIO_ROUTE = 16,
- MM_SOUND_MSG_RES_GET_AUDIO_ROUTE = 17,
- MM_SOUND_MSG_REQ_SET_AUDIO_ROUTE = 18,
- MM_SOUND_MSG_RES_SET_AUDIO_ROUTE = 19,
-#endif // PULSE_CLIENT
- MM_SOUND_MSG_REQ_IS_BT_A2DP_ON = 20,
- MM_SOUND_MSG_RES_IS_BT_A2DP_ON = 21,
- MM_SOUND_MSG_REQ_DTMF = 22,
- MM_SOUND_MSG_RES_DTMF = 23,
- MM_SOUND_MSG_REQ_IS_ROUTE_AVAILABLE,
- MM_SOUND_MSG_RES_IS_ROUTE_AVAILABLE,
- MM_SOUND_MSG_REQ_FOREACH_AVAILABLE_ROUTE_CB,
- MM_SOUND_MSG_RES_FOREACH_AVAILABLE_ROUTE_CB,
- MM_SOUND_MSG_INF_FOREACH_AVAILABLE_ROUTE_CB,
- MM_SOUND_MSG_REQ_SET_ACTIVE_ROUTE,
- MM_SOUND_MSG_RES_SET_ACTIVE_ROUTE,
- MM_SOUND_MSG_REQ_SET_ACTIVE_ROUTE_AUTO,
- MM_SOUND_MSG_RES_SET_ACTIVE_ROUTE_AUTO,
- MM_SOUND_MSG_REQ_GET_ACTIVE_DEVICE,
- MM_SOUND_MSG_RES_GET_ACTIVE_DEVICE,
- MM_SOUND_MSG_REQ_ADD_ACTIVE_DEVICE_CB,
- MM_SOUND_MSG_RES_ADD_ACTIVE_DEVICE_CB,
- MM_SOUND_MSG_REQ_REMOVE_ACTIVE_DEVICE_CB,
- MM_SOUND_MSG_RES_REMOVE_ACTIVE_DEVICE_CB,
- MM_SOUND_MSG_INF_ACTIVE_DEVICE_CB,
- MM_SOUND_MSG_REQ_ADD_AVAILABLE_ROUTE_CB,
- MM_SOUND_MSG_RES_ADD_AVAILABLE_ROUTE_CB,
- MM_SOUND_MSG_REQ_REMOVE_AVAILABLE_ROUTE_CB,
- MM_SOUND_MSG_RES_REMOVE_AVAILABLE_ROUTE_CB,
- MM_SOUND_MSG_INF_AVAILABLE_ROUTE_CB,
- MM_SOUND_MSG_REQ_ADD_VOLUME_CB,
- MM_SOUND_MSG_RES_ADD_VOLUME_CB,
- MM_SOUND_MSG_REQ_REMOVE_VOLUME_CB,
- MM_SOUND_MSG_RES_REMOVE_VOLUME_CB,
- MM_SOUND_MSG_INF_VOLUME_CB,
- MM_SOUND_MSG_REQ_SET_PATH_FOR_ACTIVE_DEVICE,
- MM_SOUND_MSG_RES_SET_PATH_FOR_ACTIVE_DEVICE,
- MM_SOUND_MSG_REQ_GET_AUDIO_PATH,
- MM_SOUND_MSG_RES_GET_AUDIO_PATH,
- MM_SOUND_MSG_REQ_ADD_DEVICE_CONNECTED_CB,
- MM_SOUND_MSG_RES_ADD_DEVICE_CONNECTED_CB,
- MM_SOUND_MSG_REQ_REMOVE_DEVICE_CONNECTED_CB,
- MM_SOUND_MSG_RES_REMOVE_DEVICE_CONNECTED_CB,
- MM_SOUND_MSG_INF_DEVICE_CONNECTED_CB,
- MM_SOUND_MSG_REQ_ADD_DEVICE_INFO_CHANGED_CB,
- MM_SOUND_MSG_RES_ADD_DEVICE_INFO_CHANGED_CB,
- MM_SOUND_MSG_REQ_REMOVE_DEVICE_INFO_CHANGED_CB,
- MM_SOUND_MSG_RES_REMOVE_DEVICE_INFO_CHANGED_CB,
- MM_SOUND_MSG_INF_DEVICE_INFO_CHANGED_CB,
- MM_SOUND_MSG_REQ_GET_CONNECTED_DEVICE_LIST,
- MM_SOUND_MSG_RES_GET_CONNECTED_DEVICE_LIST,
-#ifdef USE_FOCUS
- MM_SOUND_MSG_REQ_REGISTER_FOCUS,
- MM_SOUND_MSG_RES_REGISTER_FOCUS,
- MM_SOUND_MSG_REQ_UNREGISTER_FOCUS,
- MM_SOUND_MSG_RES_UNREGISTER_FOCUS,
- MM_SOUND_MSG_REQ_ACQUIRE_FOCUS,
- MM_SOUND_MSG_RES_ACQUIRE_FOCUS,
- MM_SOUND_MSG_REQ_RELEASE_FOCUS,
- MM_SOUND_MSG_RES_RELEASE_FOCUS,
- MM_SOUND_MSG_INF_FOCUS_CHANGED_CB,
- MM_SOUND_MSG_REQ_SET_FOCUS_WATCH_CB,
- MM_SOUND_MSG_RES_SET_FOCUS_WATCH_CB,
- MM_SOUND_MSG_REQ_UNSET_FOCUS_WATCH_CB,
- MM_SOUND_MSG_RES_UNSET_FOCUS_WATCH_CB,
- MM_SOUND_MSG_INF_FOCUS_WATCH_CB,
-#endif
-};
-
-
-/* TODO : make this general , can be used in other IPC not only dbus */
-enum {
- METHOD_CALL_TEST,
- METHOD_CALL_PLAY_FILE_START,
- METHOD_CALL_PLAY_FILE_START_WITH_STREAM_INFO,
- METHOD_CALL_PLAY_FILE_STOP,
- METHOD_CALL_PLAY_DTMF,
- METHOD_CALL_PLAY_DTMF_WITH_STREAM_INFO,
- METHOD_CALL_CLEAR_FOCUS, // Not original focus feature, only for tone/wav player internal focus usage.
- METHOD_CALL_GET_BT_A2DP_STATUS,
- METHOD_CALL_SET_PATH_FOR_ACTIVE_DEVICE,
- METHOD_CALL_GET_CONNECTED_DEVICE_LIST,
- METHOD_CALL_GET_AUDIO_PATH,
- METHOD_CALL_SET_VOLUME_LEVEL,
-
- METHOD_CALL_GET_UNIQUE_ID,
- METHOD_CALL_REGISTER_FOCUS,
- METHOD_CALL_UNREGISTER_FOCUS,
- METHOD_CALL_SET_FOCUS_REACQUISITION,
- METHOD_CALL_GET_ACQUIRED_FOCUS_STREAM_TYPE,
- METHOD_CALL_ACQUIRE_FOCUS,
- METHOD_CALL_RELEASE_FOCUS,
- METHOD_CALL_WATCH_FOCUS,
- METHOD_CALL_UNWATCH_FOCUS,
- METHOD_CALL_EMERGENT_EXIT_FOCUS,
-
- METHOD_CALL_MAX,
-};
-
-
-typedef enum sound_server_signal {
- SIGNAL_TEST,
- SIGNAL_PLAY_FILE_END,
- SIGNAL_VOLUME_CHANGED,
- SIGNAL_DEVICE_CONNECTED,
- SIGNAL_DEVICE_INFO_CHANGED,
- SIGNAL_FOCUS_CHANGED,
- SIGNAL_FOCUS_WATCH,
- SIGNAL_MAX
-} sound_server_signal_t;
-
-typedef enum pulseaudio_property {
- PULSEAUDIO_PROP_AUDIO_BALANCE,
- PULSEAUDIO_PROP_MONO_AUDIO,
- PULSEAUDIO_PROP_MUTE_ALL,
- PULSEAUDIO_PROP_MAX
-} pulseaudio_property_t;
-
-struct mm_sound_dbus_method_info{
- const char* name;
- /*
- const char* argument;
- const char* reply;
- */
-};
-
-struct mm_sound_dbus_signal_info{
- const char* name;
- const char* argument;
-};
-
-struct pulseaudio_dbus_property_info {
- const char* name;
-};
-
-#define DSIZE sizeof(mm_ipc_msg_t)-sizeof(long) /* data size for rcv & snd */
-
-#endif /* __MM_SOUND_MSG_H__ */
-
--- /dev/null
+/*
+ * libmm-sound
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Seungbae Shin <seungbae.shin@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * @file mm_sound_proxy.h
+ * @brief Client-Side proxy interface for audio module.
+ * @date
+ * @version Release
+ *
+ * Client-Side proxy interface for audio module.
+ */
+
+#ifndef __MM_SOUND_PROXY_H__
+#define __MM_SOUND_PROXY_H__
+
+#include "mm_sound_private.h"
+#include "mm_sound_device.h"
+#ifdef USE_FOCUS
+#include "mm_sound_focus.h"
+#endif
+#include "include/mm_sound_client.h"
+
+typedef void (*mm_sound_proxy_userdata_free) (void *data);
+
+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_play_tone_with_stream_info(int client_pid, int tone, char *stream_type, int stream_id, int volume, int repeat, int *codechandle);
+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_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 mm_sound_proxy_stop_sound(int handle);
+int mm_sound_proxy_clear_focus(int pid); // Not original focus feature, only for cleaning up tone/wav player internal focus usage.
+int mm_sound_proxy_add_play_sound_end_callback(mm_sound_stop_callback_wrapper_func func, void* userdata, mm_sound_proxy_userdata_free freefunc, unsigned *subs_id);
+int mm_sound_proxy_remove_play_sound_end_callback(unsigned subs_id);
+int mm_sound_proxy_get_current_connected_device_list(int device_flags, GList** device_list);
+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_remove_device_connected_callback(unsigned subs_id);
+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_remove_device_info_changed_callback(unsigned subs_id);
+int mm_sound_proxy_set_volume_by_type(const char *volume_type, const unsigned volume_level);
+int mm_sound_proxy_add_volume_changed_callback(mm_sound_volume_changed_wrapper_cb func, void* userdata, mm_sound_proxy_userdata_free freefunc, unsigned *subs_id);
+int mm_sound_proxy_remove_volume_changed_callback(unsigned subs_id);
+
+#ifdef USE_FOCUS
+int mm_sound_proxy_get_unique_id(int *id);
+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* user_data);
+int mm_sound_proxy_unregister_focus(int instance, int id, bool is_for_session);
+int mm_sound_proxy_set_foucs_reacquisition(int instance, int id, bool reacquisition);
+int mm_sound_proxy_get_acquired_focus_stream_type(int focus_type, char **stream_type, char **additional_info);
+int mm_sound_proxy_acquire_focus(int instance, int id, mm_sound_focus_type_e type, const char *option, bool is_for_session);
+int mm_sound_proxy_release_focus(int instance, int id, mm_sound_focus_type_e type, const char *option, bool is_for_session);
+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 *user_data);
+int mm_sound_proxy_unset_focus_watch_callback(int focus_tid, int handle, bool is_for_session);
+int mm_sound_proxy_emergent_exit_focus(int exit_pid);
+#endif
+
+int mm_sound_proxy_add_test_callback(mm_sound_test_cb func, void *userdata, mm_sound_proxy_userdata_free freefunc, unsigned *subs_id);
+int mm_sound_proxy_remove_test_callback(unsigned subs_id);
+int mm_sound_proxy_test(int a, int b, int* get);
+
+int mm_sound_proxy_initialize(void);
+int mm_sound_proxy_finalize(void);
+
+#endif /* __MM_SOUND_PROXY_H__ */
//#include <glib.h>
#include "include/mm_sound.h"
-#include "include/mm_sound_msg.h"
#include "include/mm_sound_client.h"
-#include "include/mm_sound_client_dbus.h"
+#include "include/mm_sound_proxy.h"
#include "include/mm_sound_common.h"
#include "include/mm_sound_device.h"
+#include "include/mm_sound_stream.h"
#ifdef USE_FOCUS
#include "include/mm_sound_focus.h"
#endif
struct sigaction FOCUS_sys_old_action;
struct sigaction FOCUS_xcpu_old_action;
-typedef struct {
+struct callback_data {
void *user_cb;
void *user_data;
- int mask;
+ void *extra_data;
guint subs_id;
-} client_cb_data_t;
+};
+
+#define GET_CB_DATA(_cb_data, _func, _userdata, _extradata) \
+ do { \
+ _cb_data = (struct callback_data*) g_malloc0(sizeof(struct callback_data)); \
+ _cb_data->user_cb = _func; \
+ _cb_data->user_data = _userdata; \
+ _cb_data->extra_data = _extradata; \
+ } while (0)
+
typedef struct {
int focus_tid;
void* user_data;
} focus_session_interrupt_info_t;
+typedef struct {
+ /* handle to watch end of playing */
+ int watching_handle;
+ /* subscription id to unsubscribe when handle ended */
+ unsigned subs_id;
+} play_sound_end_callback_data_t;
+
typedef gboolean (*focus_gLoopPollHandler_t)(gpointer d);
GThread *g_focus_thread;
for (index = 0; index < FOCUS_HANDLE_MAX; index++) {
if (g_focus_sound_handle[index].is_used == true && g_focus_sound_handle[index].focus_tid == exit_pid) {
- ret = mm_sound_client_dbus_emergent_exit_focus(exit_pid);
+ ret = mm_sound_proxy_emergent_exit_focus(exit_pid);
break;
}
}
int ret = MM_ERROR_NONE;
debug_fenter();
- mm_sound_client_dbus_initialize();
+ mm_sound_proxy_initialize();
#ifdef USE_FOCUS
debug_fenter();
- ret = mm_sound_client_dbus_finalize();
+ ret = mm_sound_proxy_finalize();
#ifdef USE_FOCUS
exit_pid = getpid();
for (index = 0; index < FOCUS_HANDLE_MAX; index++) {
if (g_focus_sound_handle[index].is_used == true && g_focus_sound_handle[index].focus_tid == exit_pid) {
- mm_sound_client_dbus_emergent_exit_focus(exit_pid);
+ mm_sound_proxy_emergent_exit_focus(exit_pid);
}
}
debug_error("focus signal received, value = %d", value);
if (value == 1) {
- ret = mm_sound_client_dbus_clear_focus(getpid());
+ ret = mm_sound_proxy_clear_focus(getpid());
if (ret)
debug_error("clear focus failed ret = 0x%x", ret);
mm_sound_unsubscribe_signal(g_focus_signal_handle);
/* Send req memory */
mm_sound_convert_volume_type_to_stream_type(volume_type, stream_type);
- ret = mm_sound_client_dbus_play_tone(number, time, volume, volume_config,
+ ret = mm_sound_proxy_play_tone(number, time, volume, volume_config,
session_type, session_options, getpid(), enable_session, handle, stream_type, -1);
if (enable_session && !g_focus_signal_handle) {
debug_fenter();
- ret = mm_sound_client_dbus_play_tone_with_stream_info(getpid(), tone, stream_type, stream_id, volume, duration, handle);
+ ret = mm_sound_proxy_play_tone_with_stream_info(getpid(), tone, stream_type, stream_id, volume, duration, handle);
debug_fleave();
return ret;
}
-void _mm_sound_stop_callback_wrapper_func(int ended_handle, void *userdata)
+static void _mm_sound_stop_callback_wrapper_func(int ended_handle, void *userdata)
{
- client_cb_data_t *cb_data = (client_cb_data_t*) userdata;
+ struct callback_data *cb_data = (struct callback_data*) userdata;
+ play_sound_end_callback_data_t *end_cb_data = (play_sound_end_callback_data_t*) cb_data->extra_data;
debug_log("[Wrapper CB][Play Stop] ended_handle : %d", ended_handle);
debug_warning("stop callback data null");
return;
}
- if (ended_handle == cb_data->mask) {
+ if (ended_handle == end_cb_data->watching_handle) {
debug_log("Interested playing handle end : %d", ended_handle);
((mm_sound_stop_callback_func)(cb_data->user_cb))(cb_data->user_data, ended_handle);
- if (mm_sound_client_dbus_remove_play_sound_end_callback(cb_data->subs_id) != MM_ERROR_NONE)
+ if (mm_sound_proxy_remove_play_sound_end_callback(end_cb_data->subs_id) != MM_ERROR_NONE)
debug_error("mm_sound_client_dbus_remove_play_file_end_callback failed");
} else {
debug_log("Not interested playing handle : %d", ended_handle);
}
}
+static void play_end_callback_data_free_func(void *data)
+{
+ struct callback_data *cb_data = (struct callback_data*) data;
+ play_sound_end_callback_data_t *end_cb_data = (play_sound_end_callback_data_t*) cb_data->extra_data;
+
+ g_free(end_cb_data);
+}
+
int mm_sound_client_play_sound(MMSoundPlayParam *param, int tone, int *handle)
{
int ret = MM_ERROR_NONE;
// int instance = -1; /* instance is unique to communicate with server : client message queue filter type */
int volume_type = MM_SOUND_VOLUME_CONFIG_TYPE(param->volume_config);
char stream_type[MM_SOUND_STREAM_TYPE_LEN] = {0, };
- client_cb_data_t *cb_data = NULL;
+ struct callback_data *cb_data = NULL;
+ play_sound_end_callback_data_t *end_cb_data;
debug_fenter();
}
mm_sound_convert_volume_type_to_stream_type(volume_type, stream_type);
- ret = mm_sound_client_dbus_play_sound(param->filename, tone, param->loop, param->volume, param->volume_config,
+ ret = mm_sound_proxy_play_sound(param->filename, tone, param->loop, param->volume, param->volume_config,
param->priority, session_type, session_options, getpid(), param->handle_route,
!param->skip_session, handle, stream_type, -1);
if (ret != MM_ERROR_NONE) {
goto failed;
}
if (param->callback) {
- cb_data = g_malloc0(sizeof(client_cb_data_t));
- cb_data->user_cb = param->callback;
- cb_data->user_data = param->data;
- cb_data->mask = *handle;
+ end_cb_data = (play_sound_end_callback_data_t *) g_malloc0(sizeof(play_sound_end_callback_data_t));
+ end_cb_data->watching_handle = *handle;
+ GET_CB_DATA(cb_data, param->callback, param->data, end_cb_data);
- ret = mm_sound_client_dbus_add_play_sound_end_callback(_mm_sound_stop_callback_wrapper_func, cb_data, &cb_data->subs_id);
+ ret = mm_sound_proxy_add_play_sound_end_callback(_mm_sound_stop_callback_wrapper_func, cb_data, play_end_callback_data_free_func, &end_cb_data->subs_id);
if (ret != MM_ERROR_NONE) {
debug_error("Add callback for play sound(%d) Failed", *handle);
}
int mm_sound_client_play_sound_with_stream_info(MMSoundPlayParam *param, int *handle, char* stream_type, int stream_id)
{
int ret = MM_ERROR_NONE;
- client_cb_data_t *cb_data = NULL;
+ struct callback_data *cb_data = NULL;
+ play_sound_end_callback_data_t *end_cb_data;
- ret = mm_sound_client_dbus_play_sound_with_stream_info(param->filename, param->loop, param->volume,
+ ret = mm_sound_proxy_play_sound_with_stream_info(param->filename, param->loop, param->volume,
param->priority, getpid(), param->handle_route, handle, stream_type, stream_id);
if (ret != MM_ERROR_NONE) {
debug_error("Play Sound Failed");
goto failed;
}
if (param->callback) {
- cb_data = g_malloc0(sizeof(client_cb_data_t));
- cb_data->user_cb = param->callback;
- cb_data->user_data = param->data;
- cb_data->mask = *handle;
+ end_cb_data = (play_sound_end_callback_data_t *) g_malloc0(sizeof(play_sound_end_callback_data_t));
+ end_cb_data->watching_handle = *handle;
+ GET_CB_DATA(cb_data, param->callback, param->data, end_cb_data);
- ret = mm_sound_client_dbus_add_play_sound_end_callback(_mm_sound_stop_callback_wrapper_func, cb_data, &cb_data->subs_id);
+ ret = mm_sound_proxy_add_play_sound_end_callback(_mm_sound_stop_callback_wrapper_func, cb_data, play_end_callback_data_free_func, &end_cb_data->subs_id);
if (ret != MM_ERROR_NONE) {
debug_error("Add callback for play sound(%d) Failed", *handle);
}
return ret;
}
- ret = mm_sound_client_dbus_stop_sound(handle);
+ ret = mm_sound_proxy_stop_sound(handle);
debug_fleave();
return ret;
goto failed;
}
- if ((ret = mm_sound_client_dbus_get_current_connected_device_list(device_flags, &device_list->list)) != MM_ERROR_NONE) {
+ if ((ret = mm_sound_proxy_get_current_connected_device_list(device_flags, &device_list->list)) != MM_ERROR_NONE) {
debug_error("[Client] failed to get current connected device list with dbus, ret[0x%x]", ret);
goto failed;
}
return ret;
}
-void _mm_sound_device_connected_callback_wrapper_func(int device_id, const char *device_type, int io_direction, int state, const char *name, gboolean is_connected, void *userdata)
+static bool is_device_match_flags(const char *device_type, int io_direction, int state, int device_flags)
+{
+ int io_direction_flag = device_flags & DEVICE_IO_DIRECTION_FLAGS;
+ int state_flag = device_flags & DEVICE_STATE_FLAGS;
+ int type_flag = device_flags & DEVICE_TYPE_FLAGS;
+ char builtin_prefix[] = "builtin";
+
+ if (device_flags == DEVICE_ALL_FLAG)
+ return TRUE;
+
+ switch (io_direction_flag) {
+ case DEVICE_IO_DIRECTION_IN_FLAG:
+ if (io_direction != DEVICE_IO_DIRECTION_IN)
+ return FALSE;
+ case DEVICE_IO_DIRECTION_OUT_FLAG:
+ if (io_direction != DEVICE_IO_DIRECTION_OUT)
+ return FALSE;
+ case DEVICE_IO_DIRECTION_BOTH_FLAG:
+ if (io_direction != DEVICE_IO_DIRECTION_BOTH)
+ return FALSE;
+ default:
+ break;
+ }
+
+ switch (state_flag) {
+ case DEVICE_STATE_DEACTIVATED_FLAG:
+ if (state != DEVICE_STATE_DEACTIVATED)
+ return FALSE;
+ case DEVICE_STATE_ACTIVATED_FLAG:
+ if (state != DEVICE_STATE_ACTIVATED)
+ return FALSE;
+ default:
+ break;
+ }
+
+ switch (type_flag) {
+ case DEVICE_TYPE_INTERNAL_FLAG:
+ if (strncmp(device_type, builtin_prefix, strlen(builtin_prefix)) != 0)
+ return FALSE;
+ case DEVICE_TYPE_EXTERNAL_FLAG:
+ if (strncmp(device_type, builtin_prefix, strlen(builtin_prefix)) == 0)
+ return FALSE;
+ default:
+ break;
+ }
+
+ return TRUE;
+}
+
+static void _mm_sound_device_connected_callback_wrapper_func(int device_id, const char *device_type, int io_direction, int state, const char *name, gboolean is_connected, void *userdata)
{
mm_sound_device_t device_h;
- client_cb_data_t *cb_data = (client_cb_data_t*) userdata;
+ struct callback_data *cb_data = (struct callback_data*) userdata;
+ int device_flags = (int) cb_data->extra_data;
debug_log("[Wrapper CB][Device Connnected] device_id : %d, device_type : %s, direction : %d, state : %d, name : %s, is_connected : %d",
device_id, device_type, io_direction, state, name, is_connected);
debug_warning("device connected changed callback data null");
return;
}
+ if (!is_device_match_flags(device_type, io_direction, state, device_flags))
+ return;
device_h.id = device_id;
device_h.io_direction = io_direction;
((mm_sound_device_connected_cb)(cb_data->user_cb))(&device_h, is_connected, cb_data->user_data);
}
-int mm_sound_client_add_device_connected_callback(int device_flags, mm_sound_device_connected_cb func, void* user_data, unsigned int *subs_id)
+int mm_sound_client_add_device_connected_callback(int device_flags, mm_sound_device_connected_cb func, void* userdata, unsigned int *subs_id)
{
int ret = MM_ERROR_NONE;
- client_cb_data_t *cb_data = NULL;
+ struct callback_data *cb_data = NULL;
debug_fenter();
- cb_data = g_malloc0(sizeof(client_cb_data_t));
- cb_data->user_cb = func;
- cb_data->user_data = user_data;
+ GET_CB_DATA(cb_data, func, userdata, (void*) device_flags);
- ret = mm_sound_client_dbus_add_device_connected_callback(device_flags, _mm_sound_device_connected_callback_wrapper_func, cb_data, subs_id);
+ ret = mm_sound_proxy_add_device_connected_callback(device_flags, _mm_sound_device_connected_callback_wrapper_func, cb_data, g_free, subs_id);
debug_fleave();
return ret;
int ret = MM_ERROR_NONE;
debug_fenter();
- ret = mm_sound_client_dbus_remove_device_connected_callback(subs_id);
+ ret = mm_sound_proxy_remove_device_connected_callback(subs_id);
debug_fleave();
return ret;
static void _mm_sound_device_info_changed_callback_wrapper_func(int device_id, const char *device_type, int io_direction, int state, const char *name, int changed_device_info_type, void *userdata)
{
mm_sound_device_t device_h;
- client_cb_data_t *cb_data = (client_cb_data_t*) userdata;
+ struct callback_data *cb_data = (struct callback_data*) userdata;
+ int device_flags = (int) cb_data->extra_data;
debug_log("[Wrapper CB][Device Info Changed] device_id : %d, device_type : %s, direction : %d, state : %d, name : %s, changed_info_type : %d",
device_id, device_type, io_direction, state, name, changed_device_info_type);
debug_warning("device info changed callback data null");
return;
}
+ if (!is_device_match_flags(device_type, io_direction, state, device_flags))
+ return;
device_h.id = device_id;
device_h.io_direction = io_direction;
int mm_sound_client_add_device_info_changed_callback(int device_flags, mm_sound_device_info_changed_cb func, void *userdata, unsigned int *subs_id)
{
int ret = MM_ERROR_NONE;
- client_cb_data_t *cb_data = (client_cb_data_t*) userdata;
+ struct callback_data *cb_data = (struct callback_data*) userdata;
debug_fenter();
- cb_data = g_malloc0(sizeof(client_cb_data_t));
- cb_data->user_cb = func;
- cb_data->user_data = userdata;
+ GET_CB_DATA(cb_data, func, userdata, (void *) device_flags);
- ret = mm_sound_client_dbus_add_device_info_changed_callback(device_flags, _mm_sound_device_info_changed_callback_wrapper_func, cb_data, subs_id);
+ ret = mm_sound_proxy_add_device_info_changed_callback(device_flags, _mm_sound_device_info_changed_callback_wrapper_func, cb_data, g_free, subs_id);
debug_fleave();
return ret;
int ret = MM_ERROR_NONE;
debug_fenter();
- ret = mm_sound_client_dbus_remove_device_info_changed_callback(subs_id);
+ ret = mm_sound_proxy_remove_device_info_changed_callback(subs_id);
debug_fleave();
return ret;
goto failed;
}
- ret = mm_sound_client_dbus_set_volume_by_type(type_str, volume_level);
+ ret = mm_sound_proxy_set_volume_by_type(type_str, volume_level);
failed:
debug_fleave();
static void _mm_sound_volume_changed_callback_wrapper_func(const char *direction, const char *volume_type_str, int volume_level, void *userdata)
{
volume_type_t volume_type = 0;
- client_cb_data_t *cb_data = (client_cb_data_t*) userdata;
+ struct callback_data *cb_data = (struct callback_data *) userdata;
debug_log("[Wrapper CB][Volume Changed] direction : %s, volume_type : %s, volume_level : %d", direction, volume_type_str, volume_level);
((mm_sound_volume_changed_cb)(cb_data->user_cb))(volume_type, volume_level, cb_data->user_data);
}
-int mm_sound_client_add_volume_changed_callback(mm_sound_volume_changed_cb func, void* user_data, unsigned int *subs_id)
+int mm_sound_client_add_volume_changed_callback(mm_sound_volume_changed_cb func, void* userdata, unsigned int *subs_id)
{
int ret = MM_ERROR_NONE;
- client_cb_data_t *cb_data = NULL;
+ struct callback_data *cb_data = NULL;
debug_fenter();
- cb_data = g_malloc0(sizeof(client_cb_data_t));
- cb_data->user_cb = func;
- cb_data->user_data = user_data;
+ GET_CB_DATA(cb_data, func, userdata, NULL);
- ret = mm_sound_client_dbus_add_volume_changed_callback(_mm_sound_volume_changed_callback_wrapper_func, cb_data, subs_id);
+ ret = mm_sound_proxy_add_volume_changed_callback(_mm_sound_volume_changed_callback_wrapper_func, cb_data, g_free, subs_id);
debug_fleave();
int ret = MM_ERROR_NONE;
debug_fenter();
- ret = mm_sound_client_dbus_remove_volume_changed_callback(subs_id);
+ ret = mm_sound_proxy_remove_volume_changed_callback(subs_id);
debug_fleave();
return ret;
if (!id)
ret = MM_ERROR_INVALID_ARGUMENT;
else
- ret = mm_sound_client_dbus_get_unique_id(id);
+ ret = mm_sound_proxy_get_unique_id(id);
debug_fleave();
MMSOUND_LEAVE_CRITICAL_SECTION(&g_id_mutex);
g_focus_sound_handle[index].is_for_session = is_for_session;
g_focus_sound_handle[index].auto_reacquire = true;
- ret = mm_sound_client_dbus_register_focus(id, pid, stream_type, callback, is_for_session, user_data);
+ ret = mm_sound_proxy_register_focus(id, pid, stream_type, callback, is_for_session, user_data);
if (ret == MM_ERROR_NONE) {
debug_msg("[Client] Success to register focus\n");
}
}
- ret = mm_sound_client_dbus_unregister_focus(instance, id, g_focus_sound_handle[index].is_for_session);
+ ret = mm_sound_proxy_unregister_focus(instance, id, g_focus_sound_handle[index].is_for_session);
if (ret == MM_ERROR_NONE)
debug_msg("[Client] Success to unregister focus\n");
debug_error("[Client] mm_sound_client_is_focus_cb_thread failed");
goto cleanup;
} else if (!result) {
- ret = mm_sound_client_dbus_set_foucs_reacquisition(instance, id, reacquisition);
+ ret = mm_sound_proxy_set_foucs_reacquisition(instance, id, reacquisition);
if (ret == MM_ERROR_NONE) {
debug_msg("[Client] Success to set focus reacquisition\n");
} else {
debug_fenter();
- ret = mm_sound_client_dbus_get_acquired_focus_stream_type(focus_type, stream_type, additional_info);
+ ret = mm_sound_proxy_get_acquired_focus_stream_type(focus_type, stream_type, additional_info);
if (ret == MM_ERROR_NONE)
debug_msg("[Client] Success to get stream type of acquired focus, stream_type(%s), additional_info(%s)\n", *stream_type, *additional_info);
else
}
instance = g_focus_sound_handle[index].focus_tid;
- ret = mm_sound_client_dbus_acquire_focus(instance, id, type, option, g_focus_sound_handle[index].is_for_session);
+ ret = mm_sound_proxy_acquire_focus(instance, id, type, option, g_focus_sound_handle[index].is_for_session);
if (ret == MM_ERROR_NONE)
debug_msg("[Client] Success to acquire focus\n");
}
instance = g_focus_sound_handle[index].focus_tid;
- ret = mm_sound_client_dbus_release_focus(instance, id, type, option, g_focus_sound_handle[index].is_for_session);
+ ret = mm_sound_proxy_release_focus(instance, id, type, option, g_focus_sound_handle[index].is_for_session);
if (ret == MM_ERROR_NONE)
debug_msg("[Client] Success to release focus\n");
instance = pid;
- ret = mm_sound_client_dbus_get_unique_id(id);
+ ret = mm_sound_proxy_get_unique_id(id);
if (ret)
return ret;
g_focus_sound_handle[index].user_data = user_data;
g_focus_sound_handle[index].is_for_session = is_for_session;
- ret = mm_sound_client_dbus_set_focus_watch_callback(pid, g_focus_sound_handle[index].handle, focus_type, callback, is_for_session, user_data);
+ ret = mm_sound_proxy_set_focus_watch_callback(pid, g_focus_sound_handle[index].handle, focus_type, callback, is_for_session, user_data);
if (ret == MM_ERROR_NONE) {
debug_msg("[Client] Success to watch focus");
g_mutex_lock(&g_focus_sound_handle[index].focus_lock);
- ret = mm_sound_client_dbus_unset_focus_watch_callback(g_focus_sound_handle[index].focus_tid, g_focus_sound_handle[index].handle, g_focus_sound_handle[index].is_for_session);
+ ret = mm_sound_proxy_unset_focus_watch_callback(g_focus_sound_handle[index].focus_tid, g_focus_sound_handle[index].handle, g_focus_sound_handle[index].is_for_session);
if (ret == MM_ERROR_NONE)
debug_msg("[Client] Success to unwatch focus\n");
debug_fenter();
- ret = mm_sound_client_dbus_add_test_callback(func, user_data, subs_id);
+ ret = mm_sound_proxy_add_test_callback(func, user_data, g_free, subs_id);
debug_fleave();
return ret;
int ret = MM_ERROR_NONE;
debug_fenter();
- ret = mm_sound_client_dbus_remove_test_callback(subs_id);
+ ret = mm_sound_proxy_remove_test_callback(subs_id);
debug_fleave();
return ret;
debug_fenter();
- ret = mm_sound_client_dbus_test(a, b, getv);
+ ret = mm_sound_proxy_test(a, b, getv);
debug_log("%d * %d -> result : %d", a, b, *getv);
debug_fleave();
+++ /dev/null
-#include <gio/gio.h>
-#include <glib.h>
-#include <poll.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <signal.h>
-
-#include <mm_error.h>
-#include <mm_debug.h>
-
-#include "include/mm_sound_client_dbus.h"
-#include "include/mm_sound_device.h"
-#include "include/mm_sound_msg.h"
-#include "include/mm_sound_common.h"
-
-#ifdef USE_SECURITY
-#include <security-server.h>
-#define COOKIE_SIZE 20
-#endif
-
-#define BUS_NAME_PULSEAUDIO "org.pulseaudio.Server"
-#define OBJECT_PULSE_MODULE_DEVICE_MANAGER "/org/pulseaudio/DeviceManager"
-#define INTERFACE_PULSE_MODULE_DEVICE_MANAGER "org.pulseaudio.DeviceManager"
-#define OBJECT_PULSE_MODULE_STREAM_MANAGER "/org/pulseaudio/StreamManager"
-#define INTERFACE_PULSE_MODULE_STREAM_MANAGER "org.pulseaudio.StreamManager"
-
-#define BUS_NAME_SOUND_SERVER "org.tizen.SoundServer"
-#define OBJECT_SOUND_SERVER "/org/tizen/SoundServer1"
-#define INTERFACE_SOUND_SERVER "org.tizen.SoundServer1"
-
-#define BUS_NAME_FOCUS_SERVER "org.tizen.FocusServer"
-#define OBJECT_FOCUS_SERVER "/org/tizen/FocusServer1"
-#define INTERFACE_FOCUS_SERVER "org.tizen.FocusServer1"
-
-#define INTERFACE_DBUS "org.freedesktop.DBus.Properties"
-#define SIGNAL_PROP_CHANGED "PropertiesChanged"
-#define METHOD_GET "Get"
-#define METHOD_SET "Set"
-#define DBUS_NAME_MAX 32
-#define DBUS_SIGNATURE_MAX 32
-#define ERR_MSG_MAX 100
-
-#define CODEC_HANDLE_MAX 256
-enum {
- DBUS_TO_SOUND_SERVER,
- DBUS_TO_PULSE_MODULE_DEVICE_MANAGER,
- DBUS_TO_PULSE_MODULE_STREAM_MANAGER,
- DBUS_TO_FOCUS_SERVER,
-};
-
-struct user_callback {
- int sig_type;
- void *cb;
- void *userdata;
- int mask;
-};
-
-guint g_dbus_prop_subs_ids[PULSEAUDIO_PROP_MAX];
-
-const struct mm_sound_dbus_method_info g_methods[METHOD_CALL_MAX] = {
- [METHOD_CALL_TEST] = {
- .name = "MethodTest1",
- },
- [METHOD_CALL_PLAY_FILE_START] = {
- .name = "PlayFileStart",
- },
- [METHOD_CALL_PLAY_FILE_START_WITH_STREAM_INFO] = {
- .name = "PlayFileStartWithStreamInfo",
- },
- [METHOD_CALL_PLAY_FILE_STOP] = {
- .name = "PlayFileStop",
- },
- [METHOD_CALL_PLAY_DTMF] = {
- .name = "PlayDTMF",
- },
- [METHOD_CALL_PLAY_DTMF_WITH_STREAM_INFO] = {
- .name = "PlayDTMFWithStreamInfo",
- },
- [METHOD_CALL_CLEAR_FOCUS] = {
- .name = "ClearFocus",
- },
- [METHOD_CALL_SET_VOLUME_LEVEL] = {
- .name = "SetVolumeLevel",
- },
- [METHOD_CALL_GET_CONNECTED_DEVICE_LIST] = {
- .name = "GetConnectedDeviceList",
- },
- [METHOD_CALL_GET_UNIQUE_ID] = {
- .name = "GetUniqueId",
- },
- [METHOD_CALL_REGISTER_FOCUS] = {
- .name = "RegisterFocus",
- },
- [METHOD_CALL_UNREGISTER_FOCUS] = {
- .name = "UnregisterFocus",
- },
- [METHOD_CALL_SET_FOCUS_REACQUISITION] = {
- .name = "SetFocusReacquisition",
- },
- [METHOD_CALL_GET_ACQUIRED_FOCUS_STREAM_TYPE] = {
- .name = "GetAcquiredFocusStreamType",
- },
- [METHOD_CALL_ACQUIRE_FOCUS] = {
- .name = "AcquireFocus",
- },
- [METHOD_CALL_RELEASE_FOCUS] = {
- .name = "ReleaseFocus",
- },
- [METHOD_CALL_WATCH_FOCUS] = {
- .name = "WatchFocus",
- },
- [METHOD_CALL_UNWATCH_FOCUS] = {
- .name = "UnwatchFocus",
- },
- [METHOD_CALL_EMERGENT_EXIT_FOCUS] = {
- .name = "EmergentExitFocus",
- },
-};
-
-const struct mm_sound_dbus_signal_info g_signals[SIGNAL_MAX] = {
- [SIGNAL_TEST] = {
- .name = "SignalTest1",
- },
- [SIGNAL_PLAY_FILE_END] = {
- .name = "PlayFileEnd",
- },
- [SIGNAL_VOLUME_CHANGED] = {
- .name = "VolumeChanged",
- },
- [SIGNAL_DEVICE_CONNECTED] = {
- .name = "DeviceConnected",
- },
- [SIGNAL_DEVICE_INFO_CHANGED] = {
- .name = "DeviceInfoChanged",
- },
- [SIGNAL_FOCUS_CHANGED] = {
- .name = "FocusChanged",
- },
- [SIGNAL_FOCUS_WATCH] = {
- .name = "FocusWatch",
- }
-};
-
-const struct pulseaudio_dbus_property_info g_pulseaudio_properties[PULSEAUDIO_PROP_MAX] = {
- [PULSEAUDIO_PROP_AUDIO_BALANCE] = {
- .name = "AudioBalance",
- },
- [PULSEAUDIO_PROP_MONO_AUDIO] = {
- .name = "MonoAudio",
- },
- [PULSEAUDIO_PROP_MUTE_ALL] = {
- .name = "MuteAll",
- },
-};
-
-/*
-static const GDBusErrorEntry mm_sound_client_error_entries[] =
-{
- {MM_ERROR_SOUND_INTERNAL, "org.tizen.mm.sound.Error.Internal"},
- {MM_ERROR_INVALID_ARGUMENT, "org.tizen.mm.sound.Error.InvalidArgument"},
-};
-*/
-
-
-/* Only For error types which is currently being used in server-side */
-static const GDBusErrorEntry mm_sound_error_entries[] =
-{
- {MM_ERROR_OUT_OF_MEMORY, "org.tizen.multimedia.OutOfMemory"},
- {MM_ERROR_OUT_OF_STORAGE, "org.tizen.multimedia.OutOfStorage"},
- {MM_ERROR_INVALID_ARGUMENT, "org.tizen.multimedia.InvalidArgument"},
- {MM_ERROR_POLICY_INTERNAL, "org.tizen.multimedia.PolicyInternal"},
- {MM_ERROR_NOT_SUPPORT_API, "org.tizen.multimedia.NotSupportAPI"},
- {MM_ERROR_POLICY_BLOCKED, "org.tizen.multimedia.PolicyBlocked"},
- {MM_ERROR_END_OF_FILE, "org.tizen.multimedia.EndOfFile"},
- {MM_ERROR_COMMON_OUT_OF_RANGE, "org.tizen.multimedia.common.OutOfRange"},
- {MM_ERROR_COMMON_UNKNOWN, "org.tizen.multimedia.common.Unknown"},
- {MM_ERROR_COMMON_NO_FREE_SPACE, "org.tizen.multimedia.common.NoFreeSpace"},
- {MM_ERROR_SOUND_INTERNAL, "org.tizen.multimedia.audio.Internal"},
- {MM_ERROR_SOUND_INVALID_STATE, "org.tizen.multimedia.audio.InvalidState"},
- {MM_ERROR_SOUND_NO_FREE_SPACE, "org.tizen.multimedia.audio.NoFreeSpace"},
- {MM_ERROR_SOUND_UNSUPPORTED_MEDIA_TYPE, "org.tizen.multimedia.audio.UnsupportedMediaType"},
- {MM_ERROR_SOUND_INVALID_POINTER, "org.tizen.multimedia.audio.InvalidPointer"},
- {MM_ERROR_SOUND_INVALID_FILE, "org.tizen.multimedia.audio.InvalidFile"},
- {MM_ERROR_SOUND_FILE_NOT_FOUND, "org.tizen.multimedia.audio.FileNotFound"},
- {MM_ERROR_SOUND_NO_DATA, "org.tizen.multimedia.audio.NoData"},
- {MM_ERROR_SOUND_INVALID_PATH, "org.tizen.multimedia.audio.InvalidPath"},
-};
-
-
-/******************************************************************************************
- Wrapper Functions of GDbus
-******************************************************************************************/
-
-
-static int _parse_error_msg(char *full_err_msg, char **err_name, char **err_msg)
-{
- char *save_p, *domain, *_err_name, *_err_msg;
-
- if (!(domain = strtok_r(full_err_msg, ":", &save_p))) {
- debug_error("get domain failed");
- return -1;
- }
- if (!(_err_name = strtok_r(NULL, ":", &save_p))) {
- debug_error("get err name failed");
- return -1;
- }
- if (!(_err_msg = strtok_r(NULL, ":", &save_p))) {
- debug_error("get err msg failed");
- return -1;
- }
-
- *err_name = _err_name;
- *err_msg = _err_msg;
-
- return 0;
-}
-
-static int _convert_error_name(const char *err_name)
-{
- int i = 0;
-
- for (i = 0; i < G_N_ELEMENTS(mm_sound_error_entries); i++) {
- if (!strcmp(mm_sound_error_entries[i].dbus_error_name, err_name)) {
- return mm_sound_error_entries[i].error_code;
- }
- }
-
- return MM_ERROR_COMMON_UNKNOWN;
-}
-
-static int _dbus_method_call(GDBusConnection* conn, const char* bus_name, const char* object, const char* intf,
- const char* method, GVariant* args, GVariant** result)
-{
- int ret = MM_ERROR_NONE;
- GError *err = NULL;
- GVariant* dbus_reply = NULL;
-
- if (!conn || !object || !intf || !method) {
- debug_error("Invalid Argument");
- if (!conn)
- debug_error("conn null");
- else if (!object)
- debug_error("object null");
- else if (!intf)
- debug_error("intf null");
- else if (!method)
- debug_error("method null");
- return MM_ERROR_INVALID_ARGUMENT;
- }
-
- debug_log("Dbus call with obj'%s' intf'%s' method'%s'", object, intf, method);
-
- dbus_reply = g_dbus_connection_call_sync(conn, bus_name, object , intf, \
- method, args ,\
- NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err );
- if (dbus_reply && !err) {
- debug_log("Method Call '%s.%s' Success", intf, method);
- *result = dbus_reply;
- } else {
- char *err_name = NULL, *err_msg = NULL;
- debug_log("Method Call '%s.%s' Failed, %s", intf, method, err->message);
-
- if (_parse_error_msg(err->message, &err_name, &err_msg) < 0) {
- debug_error("failed to parse error message");
- g_error_free(err);
- return MM_ERROR_SOUND_INTERNAL;
- }
- ret = _convert_error_name(err_name);
- g_error_free(err);
- }
-
- return ret;
-}
-
-#if 0
-static int _dbus_set_property(GDBusConnection* conn, const char* bus_name, const char* object, const char* intf,
- const char* prop, GVariant* args, GVariant** result)
-{
- int ret = MM_ERROR_NONE;
-
- if (!conn || !object || !intf || !prop) {
- debug_error("Invalid Argument");
- return MM_ERROR_INVALID_ARGUMENT;
- }
-
- debug_log("Dbus set property with obj'%s' intf'%s' prop'%s'", object, intf, prop);
-
- if ((ret = _dbus_method_call(conn, bus_name, object, INTERFACE_DBUS, METHOD_SET,
- g_variant_new("(ssv)", intf, prop, args), result)) != MM_ERROR_NONE) {
- debug_error("Dbus call for set property failed");
- }
-
- return ret;
-}
-
-static int _dbus_get_property(GDBusConnection *conn, const char* bus_name, const char* object_name,
- const char* intf_name, const char* prop, GVariant** result)
-{
- int ret = MM_ERROR_NONE;
-
- if (!conn || !object_name || !intf_name || !prop) {
- debug_error("Invalid Argument");
- return MM_ERROR_INVALID_ARGUMENT;
- }
-
- debug_log("Dbus get property with obj'%s' intf'%s' prop'%s'", object_name, intf_name, prop);
-
- if ((ret = _dbus_method_call(conn,
- bus_name, object_name, INTERFACE_DBUS, METHOD_GET,
- g_variant_new("(ss)", intf_name, prop), result)) != MM_ERROR_NONE) {
- debug_error("Dbus call for get property failed");
- }
-
- return ret;
-}
-#endif
-
-static int _dbus_subscribe_signal(GDBusConnection *conn, const char* object_name, const char* intf_name,
- const char* signal_name, GDBusSignalCallback signal_cb, guint *subscribe_id, void* userdata)
-{
- guint subs_id = 0;
-
- if (!conn || !object_name || !intf_name || !signal_name || !signal_cb) {
- debug_error("Invalid Argument");
- return MM_ERROR_INVALID_ARGUMENT;
- }
-
- debug_log("Dbus subscirbe signal with Obj'%s' Intf'%s' sig'%s'", object_name, intf_name, signal_name);
-
- subs_id = g_dbus_connection_signal_subscribe(conn, NULL, intf_name, signal_name, object_name, \
- NULL , G_DBUS_SIGNAL_FLAGS_NONE , signal_cb, userdata, NULL );
-
- if (!subs_id) {
- debug_error ("g_dbus_connection_signal_subscribe() failed ");
- return MM_ERROR_SOUND_INTERNAL;
- } else {
- if (subscribe_id)
- *subscribe_id = subs_id;
- }
-
- return MM_ERROR_NONE;
-}
-
-static void _dbus_unsubscribe_signal(GDBusConnection *conn, guint subs_id)
-{
- if (!conn || !subs_id) {
- debug_error("Invalid Argument");
- }
-
- g_dbus_connection_signal_unsubscribe(conn, subs_id);
-}
-
-static GDBusConnection* _dbus_get_connection(GBusType bustype)
-{
- static GDBusConnection *conn_system = NULL;
- static GDBusConnection *conn_session = NULL;
-
- if (bustype == G_BUS_TYPE_SYSTEM) {
- if (conn_system) {
- debug_log("Already connected to system bus");
- } else {
- debug_log("Get new connection on system bus");
- conn_system = g_bus_get_sync(bustype, NULL, NULL);
- }
- return conn_system;
- } else if (bustype == G_BUS_TYPE_SESSION) {
- if (conn_session) {
- debug_log("Already connected to session bus");
- } else {
- debug_log("Get new connection on session bus");
- conn_session = g_bus_get_sync(bustype, NULL, NULL);
- }
- return conn_session;
- } else {
- debug_error("Invalid bus type");
- return NULL;
- }
-
-}
-
-#if 0
-static void _dbus_disconnect(GDBusConnection* conn)
-{
- debug_fenter ();
- g_object_unref(conn);
- debug_fleave ();
-}
-#endif
-
-/******************************************************************************************
- Simple Functions For Communicate with Sound-Server
-******************************************************************************************/
-
-static int _dbus_method_call_to(int dbus_to, int method_type, GVariant *args, GVariant **result)
-{
- int ret = MM_ERROR_NONE;
- GDBusConnection *conn = NULL;
- const char *bus_name, *object, *interface;
-
- if (method_type < 0 || method_type >= METHOD_CALL_MAX) {
- debug_error("Invalid method type");
- return MM_ERROR_INVALID_ARGUMENT;
- }
-
- if (dbus_to == DBUS_TO_SOUND_SERVER) {
- bus_name = BUS_NAME_SOUND_SERVER;
- object = OBJECT_SOUND_SERVER;
- interface = INTERFACE_SOUND_SERVER;
- } else if (dbus_to == DBUS_TO_PULSE_MODULE_DEVICE_MANAGER) {
- bus_name = BUS_NAME_PULSEAUDIO;
- object = OBJECT_PULSE_MODULE_DEVICE_MANAGER;
- interface = INTERFACE_PULSE_MODULE_DEVICE_MANAGER;
- } else if (dbus_to == DBUS_TO_PULSE_MODULE_STREAM_MANAGER) {
- bus_name = BUS_NAME_PULSEAUDIO;
- object = OBJECT_PULSE_MODULE_STREAM_MANAGER;
- interface = INTERFACE_PULSE_MODULE_STREAM_MANAGER;
- } else if (dbus_to == DBUS_TO_FOCUS_SERVER) {
- bus_name = BUS_NAME_FOCUS_SERVER;
- object = OBJECT_FOCUS_SERVER;
- interface = INTERFACE_FOCUS_SERVER;
- } else {
- debug_error("Invalid case, dbus_to %d", dbus_to);
- return MM_ERROR_SOUND_INTERNAL;
- }
-
- if ((conn = _dbus_get_connection(G_BUS_TYPE_SYSTEM))) {
- if((ret = _dbus_method_call(conn, bus_name,
- object,
- interface,
- g_methods[method_type].name,
- args, result)) != MM_ERROR_NONE) {
- debug_error("Dbus Call on Client Error");
- return ret;
- }
- } else {
- debug_error("Get Dbus Connection Error");
- return MM_ERROR_SOUND_INTERNAL;
- }
-
- return MM_ERROR_NONE;
-}
-
-static void _dbus_signal_callback (GDBusConnection *connection,
- const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal_name,
- GVariant *params,
- gpointer user_data)
-{
- struct user_callback* user_cb = (struct user_callback*) user_data;
-
- if (!user_cb || !user_cb->cb) {
- debug_error("User callback data Null");
- return;
- }
-
- if (user_cb->sig_type < 0 || user_cb->sig_type >= SIGNAL_MAX) {
- debug_error("Wrong Signal Type");
- return;
- }
-
- if (!params) {
- debug_error("Parameter Null");
- return;
- }
-
- debug_log("Signal(%s.%s) Received , Let's call Wrapper-Callback", interface_name, signal_name);
-
- if (user_cb->sig_type == SIGNAL_VOLUME_CHANGED) {
- char *volume_type_str = NULL, *direction = NULL;
- unsigned int volume_level;
-
- g_variant_get(params, "(&s&su)", &direction, &volume_type_str, &volume_level);
- ((mm_sound_volume_changed_wrapper_cb)(user_cb->cb))(direction, volume_type_str, volume_level, user_cb->userdata);
- } else if (user_cb->sig_type == SIGNAL_DEVICE_CONNECTED) {
- const char *name = NULL, *device_type = NULL;
- gboolean is_connected = FALSE;
- int device_id, io_direction, state;
-
- g_variant_get(params, "((i&sii&s)b)", &device_id, &device_type, &io_direction,
- &state, &name, &is_connected);
- ((mm_sound_device_connected_wrapper_cb)(user_cb->cb))(device_id, device_type, io_direction, state, name, is_connected, user_cb->userdata);
- } else if (user_cb->sig_type == SIGNAL_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, "((i&sii&s)i)", &device_id, &device_type, &io_direction,
- &state, &name, &changed_device_info_type);
- ((mm_sound_device_info_changed_wrapper_cb)(user_cb->cb))(device_id, device_type, io_direction, state, name, changed_device_info_type, user_cb->userdata);
- } else if (user_cb->sig_type == SIGNAL_FOCUS_CHANGED) {
- } else if (user_cb->sig_type == SIGNAL_FOCUS_WATCH) {
- } else if (user_cb->sig_type == SIGNAL_TEST) {
- int test_var = 0;
- g_variant_get(params, "(i)", &test_var);
- ((mm_sound_test_cb)(user_cb->cb))(test_var, user_cb->userdata);
- } else if (user_cb->sig_type == SIGNAL_PLAY_FILE_END) {
- int ended_handle = 0;
- g_variant_get(params, "(i)", &ended_handle);
- ((mm_sound_stop_callback_wrapper_func)(user_cb->cb))(ended_handle, user_cb->userdata);
- }
-}
-
-static int _dbus_signal_subscribe_to(int dbus_to, sound_server_signal_t signaltype, void *cb, void *userdata, int mask, unsigned int *subs_id)
-{
- GDBusConnection *conn = NULL;
- guint _subs_id = 0;
- struct user_callback *user_cb = NULL;
- const char *object, *interface;
-
- if (!cb) {
- debug_error("Callback data Null");
- return MM_ERROR_INVALID_ARGUMENT;
- }
-
- if (signaltype < 0 || signaltype >= SIGNAL_MAX) {
- debug_error("Wrong Signal Type");
- return MM_ERROR_INVALID_ARGUMENT;
- }
-
- if (!(user_cb = g_malloc0(sizeof(struct user_callback)))) {
- debug_error("Allocate Memory for User CB data Failed");
- return MM_ERROR_SOUND_INTERNAL;
- }
-
- user_cb->sig_type = signaltype;
- user_cb->cb = cb;
- user_cb->userdata = userdata;
- user_cb->mask = mask;
-
-
- if (dbus_to == DBUS_TO_SOUND_SERVER) {
- object = OBJECT_SOUND_SERVER;
- interface = INTERFACE_SOUND_SERVER;
- } else if (dbus_to == DBUS_TO_PULSE_MODULE_DEVICE_MANAGER) {
- object = OBJECT_PULSE_MODULE_DEVICE_MANAGER;
- interface = INTERFACE_PULSE_MODULE_DEVICE_MANAGER;
- } else if (dbus_to == DBUS_TO_PULSE_MODULE_STREAM_MANAGER) {
- object = OBJECT_PULSE_MODULE_STREAM_MANAGER;
- interface = INTERFACE_PULSE_MODULE_STREAM_MANAGER;
- } else {
- debug_error("Invalid case, dbus_to %d", dbus_to);
- goto fail;
- }
-
-
- if ((conn = _dbus_get_connection(G_BUS_TYPE_SYSTEM))) {
- if(_dbus_subscribe_signal(conn, object, interface, g_signals[signaltype].name,
- _dbus_signal_callback, &_subs_id, user_cb) != MM_ERROR_NONE) {
- debug_error("Dbus Subscribe on Client Error");
- goto fail;
- } else {
- if (subs_id)
- *subs_id = (unsigned int)_subs_id;
- }
- } else {
- debug_error("Get Dbus Connection Error");
- goto fail;
- }
- return MM_ERROR_NONE;
-
-fail:
- if (user_cb)
- free(user_cb);
- return MM_ERROR_SOUND_INTERNAL;
-}
-
-static int _dbus_signal_unsubscribe(unsigned int subs_id)
-{
- GDBusConnection *conn = NULL;
-
- if ((conn = _dbus_get_connection(G_BUS_TYPE_SYSTEM))) {
- _dbus_unsubscribe_signal(conn, (guint) subs_id);
- } else {
- debug_error("Get Dbus Connection Error");
- return MM_ERROR_SOUND_INTERNAL;
- }
-
- return MM_ERROR_NONE;
-}
-
-/******************************************************************************************
- Implementation of each dbus client code (Construct Params,..)
-******************************************************************************************/
-
-int mm_sound_client_dbus_add_test_callback(mm_sound_test_cb func, void* user_data, unsigned int *subs_id)
-{
- int ret = MM_ERROR_NONE;
-
- debug_fenter();
-
- if ((ret = _dbus_signal_subscribe_to(DBUS_TO_SOUND_SERVER, SIGNAL_TEST, func, user_data, 0, subs_id)) != MM_ERROR_NONE) {
- debug_error("add test callback failed");
- }
-
- debug_fleave();
- return ret;
-}
-
-int mm_sound_client_dbus_remove_test_callback(unsigned int subs_id)
-{
- int ret = MM_ERROR_NONE;
- debug_fenter();
-
- if ((ret = _dbus_signal_unsubscribe(subs_id)) != MM_ERROR_NONE) {
- debug_error("remove test callback failed");
- }
-
- debug_fleave();
- return ret;
-}
-
-int mm_sound_client_dbus_test(int a, int b, int *get)
-{
- int ret = MM_ERROR_NONE;
- int reply = 0;
- GVariant *params = NULL, *result = NULL;
-
- debug_fenter();
-
- params = g_variant_new("(ii)", a, b);
- if (params) {
- if ((ret = _dbus_method_call_to(DBUS_TO_SOUND_SERVER, METHOD_CALL_TEST, params, &result)) != MM_ERROR_NONE) {
- debug_error("dbus test call failed");
- goto cleanup;
- }
- } else {
- debug_error("Construct Param for method call failed");
- return MM_ERROR_SOUND_INTERNAL;
- }
-
- if (result) {
- g_variant_get(result, "(i)", &reply);
- debug_log("reply : %d", reply);
- *get = reply;
- } else {
- debug_error("reply null");
- }
-
-cleanup:
- if (result)
- g_variant_unref(result);
-
- debug_fleave();
- return ret;
-}
-
-int mm_sound_client_dbus_get_current_connected_device_list(int device_flags, GList** device_list)
-{
- int ret = MM_ERROR_NONE;
- GVariant *result = NULL, *child = NULL;
- GVariant *params;
- GVariantIter iter;
- mm_sound_device_t* device_item;
- const gchar *device_name_tmp = NULL, *device_type_tmp = NULL;
-
- debug_fenter();
-
- if (!device_list) {
- debug_error("Invalid Parameter, device_list null");
- ret = MM_ERROR_INVALID_ARGUMENT;
- goto cleanup;
- }
-
- params = g_variant_new("(i)", device_flags);
-
- if (params) {
- if ((ret = _dbus_method_call_to(DBUS_TO_PULSE_MODULE_DEVICE_MANAGER, METHOD_CALL_GET_CONNECTED_DEVICE_LIST, params, &result)) != MM_ERROR_NONE) {
- debug_error("Get current connected device list failed");
- goto cleanup;
- }
- } else {
- debug_error("Construct Param for get current connected device failed");
- return MM_ERROR_SOUND_INTERNAL;
- }
-
- child = g_variant_get_child_value(result, 0);
- 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)) {
- 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);
- } else {
- if (device_item)
- g_free(device_item);
- break;
- }
- }
-
-cleanup:
- if (result)
- g_variant_unref(result);
-
- debug_fleave();
- return ret;
-}
-
-int mm_sound_client_dbus_add_device_connected_callback(int device_flags, mm_sound_device_connected_wrapper_cb func, void* user_data, unsigned int *subs_id)
-{
- int ret = MM_ERROR_NONE;
-
- debug_fenter();
-
- if ((ret = _dbus_signal_subscribe_to(DBUS_TO_PULSE_MODULE_DEVICE_MANAGER, SIGNAL_DEVICE_CONNECTED, func, user_data, device_flags, subs_id)) != MM_ERROR_NONE) {
- debug_error("add device connected callback failed");
- }
-
- debug_fleave();
- return ret;
-}
-
-int mm_sound_client_dbus_remove_device_connected_callback(unsigned int subs_id)
-{
- int ret = MM_ERROR_NONE;
- debug_fenter();
-
- if ((ret = _dbus_signal_unsubscribe(subs_id)) != MM_ERROR_NONE) {
- debug_error("remove device connected callback failed");
- }
-
- debug_fleave();
- return ret;
-}
-
-int mm_sound_client_dbus_add_device_info_changed_callback(int device_flags, mm_sound_device_info_changed_wrapper_cb func, void* user_data, unsigned int *subs_id)
-{
- int ret = MM_ERROR_NONE;
- debug_fenter();
-
- if ((ret = _dbus_signal_subscribe_to(DBUS_TO_PULSE_MODULE_DEVICE_MANAGER, SIGNAL_DEVICE_INFO_CHANGED, func, user_data, device_flags, subs_id)) != MM_ERROR_NONE) {
- debug_error("Add device info changed callback failed");
- }
-
- debug_fleave();
- return ret;
-}
-
-int mm_sound_client_dbus_remove_device_info_changed_callback(unsigned int subs_id)
-{
- int ret = MM_ERROR_NONE;
- debug_fenter();
-
- if ((ret = _dbus_signal_unsubscribe(subs_id)) != MM_ERROR_NONE) {
- debug_error("remove device info changed callback failed");
- }
-
- debug_fleave();
- return ret;
-}
-
-int mm_sound_client_dbus_set_volume_by_type(const char *volume_type, const unsigned int volume_level)
-{
- int ret = MM_ERROR_NONE;
- char *reply = NULL, *direction = "out";
- GVariant *params = NULL, *result = NULL;
-
- debug_fenter();
-
- params = g_variant_new("(ssu)", direction, volume_type, volume_level);
- if (params) {
- if ((ret = _dbus_method_call_to(DBUS_TO_PULSE_MODULE_STREAM_MANAGER, METHOD_CALL_SET_VOLUME_LEVEL, params, &result)) != MM_ERROR_NONE) {
- debug_error("dbus test call failed");
- goto cleanup;
- }
- } else {
- debug_error("Construct Param for method call failed");
- return MM_ERROR_SOUND_INTERNAL;
- }
-
- if (result) {
- g_variant_get(result, "(&s)", &reply);
- debug_log("reply : %s", reply);
- if (!strcmp(reply, "STREAM_MANAGER_RETURN_ERROR"))
- ret = MM_ERROR_SOUND_INTERNAL;
- } else {
- debug_error("reply null");
- }
-
-cleanup:
- if (result)
- g_variant_unref(result);
-
- debug_fleave();
- return ret;
-}
-
-int mm_sound_client_dbus_add_volume_changed_callback(mm_sound_volume_changed_wrapper_cb func, void* user_data, unsigned int *subs_id)
-{
- int ret = MM_ERROR_NONE;
-
- debug_fenter();
-
- if ((ret = _dbus_signal_subscribe_to(DBUS_TO_PULSE_MODULE_STREAM_MANAGER, SIGNAL_VOLUME_CHANGED, func, user_data, 0, subs_id)) != MM_ERROR_NONE) {
- debug_error("Add Volume changed callback failed");
- }
-
- debug_fleave();
-
- return ret;
-}
-
-int mm_sound_client_dbus_remove_volume_changed_callback(unsigned int subs_id)
-{
- int ret = MM_ERROR_NONE;
- debug_fenter();
-
- if ((ret = _dbus_signal_unsubscribe(subs_id)) != MM_ERROR_NONE) {
- debug_error("Remove Volume changed callback failed");
- }
-
- debug_fleave();
- return ret;
-}
-
-int mm_sound_client_dbus_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 ret = MM_ERROR_NONE;
- int handle = 0;
- 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 = _dbus_method_call_to(DBUS_TO_SOUND_SERVER, METHOD_CALL_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 (result) {
- g_variant_get(result, "(i)", &handle);
- debug_log("handle : %d", handle);
- *codechandle = handle;
- } else {
- debug_error("reply null");
- }
-
-cleanup:
- if (result)
- g_variant_unref(result);
-
- debug_fleave();
- return ret;
-
-
-}
-
-int mm_sound_client_dbus_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;
-
- debug_fenter();
-
- if (!codechandle) {
- debug_error("Param for play is null");
- return MM_ERROR_INVALID_ARGUMENT;
- }
-
- params = g_variant_new("(iiiisi)", tone, repeat, volume, client_pid, stream_type, stream_index);
- if (params) {
- if ((ret = _dbus_method_call_to(DBUS_TO_SOUND_SERVER, METHOD_CALL_PLAY_DTMF_WITH_STREAM_INFO, params, &result)) != MM_ERROR_NONE) {
- debug_error("dbus play tone failed");
- goto cleanup;
- }
- } else {
- debug_error("Construct Param for method call failed");
- }
-
- if (result) {
- g_variant_get(result, "(i)", &handle);
- debug_log("handle : %d", handle);
- *codechandle = handle;
- } else {
- debug_error("reply null");
- }
-
-cleanup:
- if (result)
- g_variant_unref(result);
-
- debug_fleave();
- return ret;
-
-
-}
-
-int mm_sound_client_dbus_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 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("(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 = _dbus_method_call_to(DBUS_TO_SOUND_SERVER, METHOD_CALL_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");
- }
-
- if (result) {
- g_variant_get(result, "(i)", &handle);
- debug_log("handle : %d", handle);
- *codechandle = handle;
- } else {
- debug_error("reply null");
- }
-
-cleanup:
- if (result)
- g_variant_unref(result);
-
- debug_fleave();
- return ret;
-}
-
-int mm_sound_client_dbus_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 ret = MM_ERROR_NONE;
- int handle = 0;
- GVariant* params = NULL, *result = NULL;
-
- if (!filename || !codechandle) {
- debug_error("Param for play is null");
- return MM_ERROR_INVALID_ARGUMENT;
- }
-
- debug_fenter();
-
- params = g_variant_new("(siiiiisi)", filename, repeat, volume,
- priority, client_pid, handle_route, stream_type, stream_index);
- if (params) {
- if ((ret = _dbus_method_call_to(DBUS_TO_SOUND_SERVER, METHOD_CALL_PLAY_FILE_START_WITH_STREAM_INFO, params, &result)) != MM_ERROR_NONE) {
- debug_error("dbus play file failed");
- goto cleanup;
- }
- } else {
- debug_error("Construct Param for method call failed");
- }
-
- if (result) {
- g_variant_get(result, "(i)", &handle);
- debug_log("handle : %d", handle);
- *codechandle = handle;
- } else {
- debug_error("reply null");
- }
-
-cleanup:
- if (result)
- g_variant_unref(result);
-
- debug_fleave();
- return ret;
-
-
-}
-
-
-int mm_sound_client_dbus_stop_sound(int handle)
-{
- int ret = MM_ERROR_NONE;
- GVariant *result = NULL;
-
- debug_fenter();
-
- if ((ret = _dbus_method_call_to(DBUS_TO_SOUND_SERVER, METHOD_CALL_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_client_dbus_clear_focus(int pid)
-{
- int ret = MM_ERROR_NONE;
- GVariant *result = NULL;
-
- debug_fenter();
-
- if ((ret = _dbus_method_call_to(DBUS_TO_SOUND_SERVER, METHOD_CALL_CLEAR_FOCUS, g_variant_new("(i)", pid), &result)) != MM_ERROR_NONE) {
- debug_error("dbus clear focus failed");
- }
-
- if (result)
- g_variant_unref(result);
-
- debug_fleave();
- return ret;
-}
-
-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 ret = MM_ERROR_NONE;
-
- debug_fenter();
-
- if ((ret = _dbus_signal_subscribe_to(DBUS_TO_SOUND_SERVER, SIGNAL_PLAY_FILE_END, stop_cb, userdata, 0, subs_id)) != MM_ERROR_NONE) {
- debug_error("add play sound end callback failed");
- }
-
- debug_fleave();
-
- return ret;
-}
-
-int mm_sound_client_dbus_remove_play_sound_end_callback(unsigned int subs_id)
-{
- int ret = MM_ERROR_NONE;
- debug_fenter();
-
- if ((ret = _dbus_signal_unsubscribe(subs_id)) != MM_ERROR_NONE) {
- debug_error("Remove Play File End callback failed");
- }
-
- debug_fleave();
- return ret;
-}
-
-/*------------------------------------------ FOCUS --------------------------------------------------*/
-#ifdef USE_FOCUS
-
-#ifdef SUPPORT_CONTAINER
-#ifdef USE_SECURITY
-char* _get_cookie(int cookie_size)
-{
- int retval = -1;
- char* cookie = NULL;
-
- if (security_server_get_cookie_size() != cookie_size) {
- debug_error ("[Security] security_server_get_cookie_size() != COOKIE_SIZE(%d)\n", cookie_size);
- return false;
- }
-
- cookie = (char*)malloc (cookie_size);
-
- retval = security_server_request_cookie (cookie, cookie_size);
- if (retval == SECURITY_SERVER_API_SUCCESS) {
- debug_msg ("[Security] security_server_request_cookie() returns [%d]\n", retval);
- } else {
- debug_error ("[Security] security_server_request_cookie() returns [%d]\n", retval);
- }
-
- return cookie;
-}
-
-static GVariant* _get_cookie_variant ()
-{
- int i;
- GVariantBuilder builder;
- char* cookie = NULL;
-
- cookie = _get_cookie(COOKIE_SIZE);
-
- if (cookie == NULL)
- return NULL;
-
- g_variant_builder_init(&builder, G_VARIANT_TYPE_ARRAY);
- for (i = 0; i < COOKIE_SIZE; i++)
- g_variant_builder_add(&builder, "y", cookie[i]);
-
- free (cookie);
- return g_variant_builder_end(&builder);
-}
-
-#endif /* USE_SECURITY */
-#endif /* SUPPORT_CONTAINER */
-
-int mm_sound_client_dbus_get_unique_id(int *id)
-{
- int ret = MM_ERROR_NONE;
- int res = 0;
- GVariant *result = NULL;
-
- debug_fenter();
-
- if ((ret = _dbus_method_call_to(DBUS_TO_FOCUS_SERVER, METHOD_CALL_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);
- }
-
- debug_fleave();
-
- return ret;
-}
-
-int mm_sound_client_dbus_register_focus(int id, int instance, const char *stream_type, mm_sound_focus_changed_cb callback, bool is_for_session, void* user_data)
-{
- int ret = MM_ERROR_NONE;
- GVariant* params = NULL, *result = NULL;
-#ifdef SUPPORT_CONTAINER
- char container[128];
-#endif
-
- debug_fenter();
-
-#ifdef SUPPORT_CONTAINER
-#ifdef USE_SECURITY
- params = g_variant_new("(@ayiisb)", _get_cookie_variant(), instance, id, stream_type, is_for_session);
-#else /* USE_SECURITY */
- gethostname(container, sizeof(container));
- debug_error("container = %s", container);
- params = g_variant_new("(siisb)", container, instance, id, stream_type, is_for_session);
-#endif /* USE_SECURITY */
-
-#else /* SUPPORT_CONTAINER */
- params = g_variant_new("(iisb)", instance, id, stream_type, is_for_session);
-
-#endif /* SUPPORT_CONTAINER */
-
- if (params) {
- if ((ret = _dbus_method_call_to(DBUS_TO_FOCUS_SERVER, METHOD_CALL_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);
-
- debug_fleave();
-
- return ret;
-
-}
-
-int mm_sound_client_dbus_unregister_focus(int instance, int id, bool is_for_session)
-{
- 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 = _dbus_method_call_to(DBUS_TO_FOCUS_SERVER, METHOD_CALL_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_client_dbus_set_foucs_reacquisition(int instance, int id, bool reacquisition)
-{
- int ret = MM_ERROR_NONE;
- GVariant* params = NULL, *result = NULL;
-
- debug_fenter();
-
- params = g_variant_new("(iib)", instance, id, reacquisition);
- if (params) {
- if ((ret = _dbus_method_call_to(DBUS_TO_FOCUS_SERVER, METHOD_CALL_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);
-
- debug_fleave();
- return ret;
-}
-
-int mm_sound_client_dbus_get_acquired_focus_stream_type(int focus_type, char **stream_type, char **additional_info)
-{
- int ret = MM_ERROR_NONE;
- GVariant* params = NULL, *result = NULL;
-
- debug_fenter();
-
- params = g_variant_new("(i)", focus_type);
- if (params) {
- if ((ret = _dbus_method_call_to(DBUS_TO_FOCUS_SERVER, METHOD_CALL_GET_ACQUIRED_FOCUS_STREAM_TYPE, params, &result)) != MM_ERROR_NONE) {
- debug_error("dbus get stream type of acquired focus failed");
- }
- } else {
- debug_error("Construct Param for method call failed");
- }
-
- if (ret == MM_ERROR_NONE && result)
- g_variant_get(result, "(ss)", stream_type, additional_info);
- else
- g_variant_unref(result);
-
- debug_fleave();
- return ret;
-}
-
-int mm_sound_client_dbus_acquire_focus(int instance, int id, mm_sound_focus_type_e type, const char *option, bool is_for_session)
-{
- int ret = MM_ERROR_NONE;
- GVariant* params = NULL, *result = NULL;
-
- debug_fenter();
-
- params = g_variant_new("(iiisb)", instance, id, type, option, is_for_session);
- if (params) {
- if ((ret = _dbus_method_call_to(DBUS_TO_FOCUS_SERVER, METHOD_CALL_ACQUIRE_FOCUS, params, &result)) != MM_ERROR_NONE) {
- debug_error("dbus acquire 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_client_dbus_release_focus(int instance, int id, mm_sound_focus_type_e type, const char *option, bool is_for_session)
-{
- int ret = MM_ERROR_NONE;
- GVariant* params = NULL, *result = NULL;
-
- debug_fenter();
-
- params = g_variant_new("(iiisb)", instance, id, type, option, is_for_session);
- if (params) {
- if ((ret = _dbus_method_call_to(DBUS_TO_FOCUS_SERVER, METHOD_CALL_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);
-
- debug_fleave();
- return ret;
-}
-
-int mm_sound_client_dbus_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* user_data)
-{
- int ret = MM_ERROR_NONE;
- GVariant* params = NULL, *result = NULL;
-#ifdef SUPPORT_CONTAINER
- char container[128];
-#endif
-
- debug_fenter();
-#ifdef SUPPORT_CONTAINER
-#ifdef USE_SECURITY
- params = g_variant_new("(@ayiiib)", _get_cookie_variant(), instance, handle, type, is_for_session);
-#else /* USE_SECURITY */
- gethostname(container, sizeof(container));
- debug_error("container = %s", container);
- params = g_variant_new("(siiib)", container, instance, handle, type, is_for_session);
-#endif /* USE_SECURITY */
-
-#else /* SUPPORT_CONTAINER */
- params = g_variant_new("(iiib)", instance, handle, type, is_for_session);
-#endif /* SUPPORT_CONTAINER */
-
- if (params) {
- if ((ret = _dbus_method_call_to(DBUS_TO_FOCUS_SERVER, METHOD_CALL_WATCH_FOCUS, params, &result)) != MM_ERROR_NONE) {
- debug_error("dbus set 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);
- debug_fleave();
-
- return ret;
-
-}
-
-int mm_sound_client_dbus_unset_focus_watch_callback(int focus_tid, int handle, bool is_for_session)
-{
- int ret = MM_ERROR_NONE;
- GVariant* params = NULL, *result = NULL;
-
- debug_fenter();
-
- params = g_variant_new("(iib)", focus_tid, handle, is_for_session);
- if (params) {
- if ((ret = _dbus_method_call_to(DBUS_TO_FOCUS_SERVER, METHOD_CALL_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);
-
- debug_fleave();
-
- return ret;
-}
-
-int mm_sound_client_dbus_emergent_exit_focus(int exit_pid)
-{
- int ret = MM_ERROR_NONE;
- GVariant* params = NULL, *result = NULL;
-
- debug_fenter();
-
- params = g_variant_new("(i)", exit_pid);
- if (params) {
- if ((ret = _dbus_method_call_to(DBUS_TO_FOCUS_SERVER, METHOD_CALL_EMERGENT_EXIT_FOCUS, params, &result)) != MM_ERROR_NONE) {
- debug_error("dbus emergent exit focus failed");
- goto cleanup;
- }
- } else {
- debug_error("Construct Param for method call failed");
- }
-
-cleanup:
- if (ret != MM_ERROR_NONE)
- g_variant_get(result, "(i)", &ret);
- if (result)
- g_variant_unref(result);
-
- debug_fleave();
- return ret;
-}
-
-#endif /* USE_FOCUS */
-/*------------------------------------------ FOCUS --------------------------------------------------*/
-
-int mm_sound_client_dbus_initialize(void)
-{
- int ret = MM_ERROR_NONE;
-
- debug_fenter();
- debug_fleave();
-
- return ret;
-}
-
-int mm_sound_client_dbus_finalize(void)
-{
- int ret = MM_ERROR_NONE;
-
- debug_fenter();
- debug_fleave();
-
- return ret;
-}
--- /dev/null
+#include <glib.h>
+#include <poll.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <signal.h>
+
+#include <mm_error.h>
+#include <mm_debug.h>
+
+#include "include/mm_sound_proxy.h"
+#include "include/mm_sound_device.h"
+#include "include/mm_sound_common.h"
+#include "include/mm_sound_dbus.h"
+#include "include/mm_sound_intf.h"
+
+#ifdef USE_SECURITY
+#include <security-server.h>
+#define COOKIE_SIZE 20
+#endif
+
+
+struct callback_data {
+ void *user_cb;
+ void *user_data;
+ void *extra_data;
+ mm_sound_proxy_userdata_free free_func;
+};
+
+#define GET_CB_DATA(_cb_data, _func, _userdata, _freefunc, _extradata) \
+ do { \
+ _cb_data = (struct callback_data*) g_malloc0(sizeof(struct callback_data)); \
+ _cb_data->user_cb = _func; \
+ _cb_data->user_data = _userdata; \
+ _cb_data->free_func = _freefunc; \
+ _cb_data->extra_data = _extradata; \
+ } while (0)
+
+
+/* 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;
+
+ if (event == AUDIO_EVENT_VOLUME_CHANGED) {
+ char *volume_type_str = NULL, *direction = NULL;
+ unsigned volume_level;
+
+ 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, "((i&sii&s)b)", &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);
+ } 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, "((i&sii&s)i)", &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);
+ } else if (event == AUDIO_EVENT_FOCUS_CHANGED) {
+ } else if (event == AUDIO_EVENT_FOCUS_WATCH) {
+ } else if (event == AUDIO_EVENT_TEST) {
+ int test_var = 0;
+ g_variant_get(params, "(i)", &test_var);
+ ((mm_sound_test_cb)(cb_data->user_cb))(test_var, cb_data->user_data);
+ } else if (event == AUDIO_EVENT_PLAY_FILE_END) {
+ 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);
+ }
+}
+
+static void simple_callback_data_free_func(void *data)
+{
+ struct callback_data *cb_data = (struct callback_data*) data;
+
+ if (cb_data->free_func)
+ cb_data->free_func(cb_data->user_data);
+
+ g_free(cb_data);
+}
+
+int mm_sound_proxy_add_test_callback(mm_sound_test_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();
+
+ GET_CB_DATA(cb_data, func, userdata, freefunc, NULL);
+
+ if ((ret = mm_sound_dbus_signal_subscribe_to(AUDIO_PROVIDER_SOUND_SERVER, AUDIO_EVENT_TEST, dbus_callback, cb_data, simple_callback_data_free_func, subs_id)) != MM_ERROR_NONE) {
+ debug_error("add test callback failed");
+ }
+
+ debug_fleave();
+ return ret;
+}
+
+int mm_sound_proxy_remove_test_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 test callback failed");
+ }
+
+ debug_fleave();
+ return ret;
+}
+
+int mm_sound_proxy_test(int a, int b, int *get)
+{
+ int ret = MM_ERROR_NONE;
+ int reply = 0;
+ GVariant *params = NULL, *result = NULL;
+
+ 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 {
+ debug_error("Construct Param for method call failed");
+ return MM_ERROR_SOUND_INTERNAL;
+ }
+
+ if (result) {
+ g_variant_get(result, "(i)", &reply);
+ debug_log("reply : %d", reply);
+ *get = reply;
+ } else {
+ debug_error("reply null");
+ }
+
+cleanup:
+ if (result)
+ g_variant_unref(result);
+
+ debug_fleave();
+ return ret;
+}
+
+int mm_sound_proxy_get_current_connected_device_list(int device_flags, GList** device_list)
+{
+ int ret = MM_ERROR_NONE;
+ GVariant *result = NULL, *child = NULL;
+ GVariant *params;
+ GVariantIter iter;
+ mm_sound_device_t* device_item;
+ const gchar *device_name_tmp = NULL, *device_type_tmp = NULL;
+
+ debug_fenter();
+
+ if (!device_list) {
+ debug_error("Invalid Parameter, device_list null");
+ ret = MM_ERROR_INVALID_ARGUMENT;
+ goto cleanup;
+ }
+
+ params = g_variant_new("(i)", device_flags);
+
+ if (params) {
+ if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_DEVICE_MANAGER, AUDIO_METHOD_GET_CONNECTED_DEVICE_LIST, params, &result)) != MM_ERROR_NONE) {
+ debug_error("Get current connected device list failed");
+ goto cleanup;
+ }
+ } else {
+ debug_error("Construct Param for get current connected device failed");
+ return MM_ERROR_SOUND_INTERNAL;
+ }
+
+ child = g_variant_get_child_value(result, 0);
+ 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)) {
+ 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);
+ } else {
+ if (device_item)
+ g_free(device_item);
+ break;
+ }
+ }
+
+cleanup:
+ if (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 ret = MM_ERROR_NONE;
+ struct callback_data *cb_data;
+
+ debug_fenter();
+
+ GET_CB_DATA(cb_data, func, userdata, freefunc, NULL);
+
+ if ((ret = mm_sound_dbus_signal_subscribe_to(AUDIO_PROVIDER_DEVICE_MANAGER, AUDIO_EVENT_DEVICE_CONNECTED, dbus_callback, cb_data, simple_callback_data_free_func, subs_id)) != MM_ERROR_NONE) {
+ debug_error("add device connected callback failed");
+ }
+
+ debug_fleave();
+ return ret;
+}
+
+int mm_sound_proxy_remove_device_connected_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 connected callback failed");
+ }
+
+ debug_fleave();
+ 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 ret = MM_ERROR_NONE;
+ struct callback_data *cb_data;
+
+ debug_fenter();
+
+ GET_CB_DATA(cb_data, func, userdata, freefunc, NULL);
+
+ if ((ret = mm_sound_dbus_signal_subscribe_to(AUDIO_PROVIDER_DEVICE_MANAGER, AUDIO_EVENT_DEVICE_INFO_CHANGED, dbus_callback, cb_data, simple_callback_data_free_func, subs_id)) != MM_ERROR_NONE) {
+ debug_error("Add device info changed callback failed");
+ }
+
+ debug_fleave();
+ return ret;
+}
+
+int mm_sound_proxy_remove_device_info_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 info changed callback failed");
+ }
+
+ debug_fleave();
+ return ret;
+}
+
+int mm_sound_proxy_set_volume_by_type(const char *volume_type, const unsigned volume_level)
+{
+ int ret = MM_ERROR_NONE;
+ char *reply = NULL, *direction = "out";
+ GVariant *params = NULL, *result = NULL;
+
+ 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 {
+ debug_error("Construct Param for method call failed");
+ return MM_ERROR_SOUND_INTERNAL;
+ }
+
+ if (result) {
+ g_variant_get(result, "(&s)", &reply);
+ debug_log("reply : %s", reply);
+ if (!strcmp(reply, "STREAM_MANAGER_RETURN_ERROR"))
+ ret = MM_ERROR_SOUND_INTERNAL;
+ } else {
+ debug_error("reply null");
+ }
+
+cleanup:
+ if (result)
+ g_variant_unref(result);
+
+ debug_fleave();
+ return ret;
+}
+
+int mm_sound_proxy_add_volume_changed_callback(mm_sound_volume_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();
+
+ GET_CB_DATA(cb_data, func, userdata, freefunc, NULL);
+
+ if ((ret = mm_sound_dbus_signal_subscribe_to(AUDIO_PROVIDER_STREAM_MANAGER, AUDIO_EVENT_VOLUME_CHANGED, dbus_callback, cb_data, simple_callback_data_free_func, subs_id)) != MM_ERROR_NONE) {
+ debug_error("Add Volume changed callback failed");
+ }
+
+ debug_fleave();
+
+ return ret;
+}
+
+int mm_sound_proxy_remove_volume_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 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 ret = MM_ERROR_NONE;
+ int handle = 0;
+ 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 (result) {
+ g_variant_get(result, "(i)", &handle);
+ debug_log("handle : %d", handle);
+ *codechandle = handle;
+ } else {
+ debug_error("reply null");
+ }
+
+cleanup:
+ if (result)
+ g_variant_unref(result);
+
+ 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 ret = MM_ERROR_NONE;
+ int handle = 0;
+ GVariant* params = NULL, *result = NULL;
+
+ debug_fenter();
+
+ if (!codechandle) {
+ debug_error("Param for play is null");
+ 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 {
+ debug_error("Construct Param for method call failed");
+ }
+
+ if (result) {
+ g_variant_get(result, "(i)", &handle);
+ debug_log("handle : %d", handle);
+ *codechandle = handle;
+ } else {
+ debug_error("reply null");
+ }
+
+cleanup:
+ if (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 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("(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 {
+ debug_error("Construct Param for method call failed");
+ }
+
+ if (result) {
+ g_variant_get(result, "(i)", &handle);
+ debug_log("handle : %d", handle);
+ *codechandle = handle;
+ } else {
+ debug_error("reply null");
+ }
+
+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 ret = MM_ERROR_NONE;
+ int handle = 0;
+ GVariant* params = NULL, *result = NULL;
+
+ if (!filename || !codechandle) {
+ debug_error("Param for play is null");
+ return MM_ERROR_INVALID_ARGUMENT;
+ }
+
+ 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 {
+ debug_error("Construct Param for method call failed");
+ }
+
+ if (result) {
+ g_variant_get(result, "(i)", &handle);
+ debug_log("handle : %d", handle);
+ *codechandle = handle;
+ } else {
+ debug_error("reply null");
+ }
+
+cleanup:
+ if (result)
+ g_variant_unref(result);
+
+ debug_fleave();
+ return ret;
+
+
+}
+
+
+int mm_sound_proxy_stop_sound(int handle)
+{
+ int ret = MM_ERROR_NONE;
+ GVariant *result = NULL;
+
+ 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) {
+ 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);
+
+ debug_fleave();
+ return ret;
+}
+
+int mm_sound_proxy_add_play_sound_end_callback(mm_sound_stop_callback_wrapper_func func, void* userdata, mm_sound_proxy_userdata_free freefunc, unsigned *subs_id)
+{
+ int ret = MM_ERROR_NONE;
+ struct callback_data *cb_data;
+
+ debug_fenter();
+
+ GET_CB_DATA(cb_data, func, userdata, freefunc, NULL);
+
+ if ((ret = mm_sound_dbus_signal_subscribe_to(AUDIO_PROVIDER_SOUND_SERVER, AUDIO_EVENT_PLAY_FILE_END, dbus_callback, cb_data, simple_callback_data_free_func, subs_id)) != MM_ERROR_NONE) {
+ debug_error("add play sound end callback failed");
+ }
+
+ debug_fleave();
+
+ return ret;
+}
+
+int mm_sound_proxy_remove_play_sound_end_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 Play File End callback failed");
+ }
+
+ debug_fleave();
+ return ret;
+}
+
+/*------------------------------------------ FOCUS --------------------------------------------------*/
+#ifdef USE_FOCUS
+
+#ifdef SUPPORT_CONTAINER
+#ifdef USE_SECURITY
+char* _get_cookie(int cookie_size)
+{
+ int retval = -1;
+ char* cookie = NULL;
+
+ if (security_server_get_cookie_size() != cookie_size) {
+ debug_error ("[Security] security_server_get_cookie_size() != COOKIE_SIZE(%d)\n", cookie_size);
+ return false;
+ }
+
+ cookie = (char*)malloc (cookie_size);
+
+ retval = security_server_request_cookie (cookie, cookie_size);
+ if (retval == SECURITY_SERVER_API_SUCCESS) {
+ debug_msg ("[Security] security_server_request_cookie() returns [%d]\n", retval);
+ } else {
+ debug_error ("[Security] security_server_request_cookie() returns [%d]\n", retval);
+ }
+
+ return cookie;
+}
+
+static GVariant* _get_cookie_variant ()
+{
+ int i;
+ GVariantBuilder builder;
+ char* cookie = NULL;
+
+ cookie = _get_cookie(COOKIE_SIZE);
+
+ if (cookie == NULL)
+ return NULL;
+
+ g_variant_builder_init(&builder, G_VARIANT_TYPE_ARRAY);
+ for (i = 0; i < COOKIE_SIZE; i++)
+ g_variant_builder_add(&builder, "y", cookie[i]);
+
+ free (cookie);
+ return g_variant_builder_end(&builder);
+}
+
+#endif /* USE_SECURITY */
+#endif /* SUPPORT_CONTAINER */
+
+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);
+ }
+
+ 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 ret = MM_ERROR_NONE;
+ GVariant* params = NULL, *result = NULL;
+#ifdef SUPPORT_CONTAINER
+ char container[128];
+#endif
+
+ debug_fenter();
+
+#ifdef SUPPORT_CONTAINER
+#ifdef USE_SECURITY
+ params = g_variant_new("(@ayiisb)", _get_cookie_variant(), instance, id, stream_type, is_for_session);
+#else /* USE_SECURITY */
+ gethostname(container, sizeof(container));
+ debug_error("container = %s", container);
+ params = g_variant_new("(siisb)", container, instance, id, stream_type, is_for_session);
+#endif /* USE_SECURITY */
+
+#else /* SUPPORT_CONTAINER */
+ params = g_variant_new("(iisb)", instance, id, stream_type, is_for_session);
+
+#endif /* SUPPORT_CONTAINER */
+
+ 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);
+
+ debug_fleave();
+
+ return ret;
+
+}
+
+int mm_sound_proxy_unregister_focus(int instance, int id, bool is_for_session)
+{
+ 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);
+
+ debug_fleave();
+
+ return ret;
+}
+
+int mm_sound_proxy_set_foucs_reacquisition(int instance, int id, bool reacquisition)
+{
+ int ret = MM_ERROR_NONE;
+ GVariant* params = NULL, *result = NULL;
+
+ 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");
+ }
+ } 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_get_acquired_focus_stream_type(int focus_type, char **stream_type, char **additional_info)
+{
+ int ret = MM_ERROR_NONE;
+ GVariant* params = NULL, *result = NULL;
+
+ debug_fenter();
+
+ params = g_variant_new("(i)", focus_type);
+ if (params) {
+ if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_FOCUS_SERVER, AUDIO_METHOD_GET_ACQUIRED_FOCUS_STREAM_TYPE, params, &result)) != MM_ERROR_NONE) {
+ debug_error("dbus get stream type of acquired focus failed");
+ }
+ } else {
+ debug_error("Construct Param for method call failed");
+ }
+
+ if (ret == MM_ERROR_NONE && result)
+ g_variant_get(result, "(ss)", stream_type, additional_info);
+ else
+ g_variant_unref(result);
+
+ debug_fleave();
+ return ret;
+}
+
+int mm_sound_proxy_acquire_focus(int instance, int id, mm_sound_focus_type_e type, const char *option, bool is_for_session)
+{
+ int ret = MM_ERROR_NONE;
+ GVariant* params = NULL, *result = NULL;
+
+ debug_fenter();
+
+ params = g_variant_new("(iiisb)", instance, id, type, option, 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 {
+ 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_release_focus(int instance, int id, mm_sound_focus_type_e type, const char *option, bool is_for_session)
+{
+ int ret = MM_ERROR_NONE;
+ GVariant* params = NULL, *result = NULL;
+
+ debug_fenter();
+
+ params = g_variant_new("(iiisb)", instance, id, type, option, 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);
+
+ 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 ret = MM_ERROR_NONE;
+ GVariant* params = NULL, *result = NULL;
+#ifdef SUPPORT_CONTAINER
+ char container[128];
+#endif
+
+ debug_fenter();
+#ifdef SUPPORT_CONTAINER
+#ifdef USE_SECURITY
+ params = g_variant_new("(@ayiiib)", _get_cookie_variant(), instance, handle, type, is_for_session);
+#else /* USE_SECURITY */
+ gethostname(container, sizeof(container));
+ debug_error("container = %s", container);
+ params = g_variant_new("(siiib)", container, instance, handle, type, is_for_session);
+#endif /* USE_SECURITY */
+
+#else /* SUPPORT_CONTAINER */
+ params = g_variant_new("(iiib)", instance, handle, type, is_for_session);
+#endif /* SUPPORT_CONTAINER */
+
+ 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");
+ }
+ } 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_unset_focus_watch_callback(int focus_tid, int handle, bool is_for_session)
+{
+ int ret = MM_ERROR_NONE;
+ GVariant* params = NULL, *result = NULL;
+
+ 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);
+
+ debug_fleave();
+
+ return ret;
+}
+
+int mm_sound_proxy_emergent_exit_focus(int exit_pid)
+{
+ int ret = MM_ERROR_NONE;
+ GVariant* params = NULL, *result = NULL;
+
+ debug_fenter();
+
+ params = g_variant_new("(i)", exit_pid);
+ if (params) {
+ if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_FOCUS_SERVER, AUDIO_METHOD_EMERGENT_EXIT_FOCUS, params, &result)) != MM_ERROR_NONE) {
+ debug_error("dbus emergent exit focus failed");
+ goto cleanup;
+ }
+ } else {
+ debug_error("Construct Param for method call failed");
+ }
+
+cleanup:
+ if (ret != MM_ERROR_NONE)
+ g_variant_get(result, "(i)", &ret);
+ if (result)
+ g_variant_unref(result);
+
+ debug_fleave();
+ return ret;
+}
+
+#endif /* USE_FOCUS */
+/*------------------------------------------ FOCUS --------------------------------------------------*/
+
+int mm_sound_proxy_initialize(void)
+{
+ int ret = MM_ERROR_NONE;
+
+ debug_fenter();
+ debug_fleave();
+
+ return ret;
+}
+
+int mm_sound_proxy_finalize(void)
+{
+ int ret = MM_ERROR_NONE;
+
+ debug_fenter();
+ debug_fleave();
+
+ return ret;
+}
Name: libmm-sound
Summary: MMSound Package contains client lib and sound_server binary
-Version: 0.10.7
+Version: 0.10.8
Release: 0
Group: System/Libraries
License: Apache-2.0
#define __MM_SOUND_MGR_CODEC_H__
#include <mm_source.h>
+#include <mm_sound_stream.h>
typedef struct {
int tone;
#ifndef __MM_SOUND_MGR_IPC_H__
#define __MM_SOUND_MGR_IPC_H__
-#include "../../include/mm_sound_msg.h"
-
-#define SOUND_MSG_SET(sound_msg, x_msgtype, x_handle, x_code, x_msgid) \
-do { \
- sound_msg.msgtype = x_msgtype; \
- sound_msg.handle = x_handle; \
- sound_msg.code = x_code; \
- sound_msg.msgid = x_msgid; \
-} while(0)
-
-#define FREEZE_COMMAND_EXCLUDE "exclude"
-#define FREEZE_COMMAND_INCLUDE "include"
-#define FREEZE_COMMAND_WAKEUP "wakeup"
+#include <glib.h>
+#include <stdbool.h>
+#include "../../include/mm_sound_device.h"
+#include "../../include/mm_sound.h"
#ifdef SUPPORT_CONTAINER
gboolean enable_session, int *codechandle, char *stream_type, int stream_index);
int _MMSoundMgrIpcPlayFileWithStreamInfo(char* filename, int repeat, int volume,
int priority, int client_pid, int handle_route, int *codechandle, char *stream_type, int stream_index);
-//int _MMSoundMgrIpcStop(mm_ipc_msg_t *msg);
int _MMSoundMgrIpcStop(int handle);
int _MMSoundMgrIpcClearFocus(int pid);
-//int _MMSoundMgrIpcPlayDTMF(int *codechandle, mm_ipc_msg_t *msg);
int _MMSoundMgrIpcPlayDTMF(int tone, int repeat, int volume, int volume_config,
int session_type, int session_options, int client_pid,
gboolean enable_session, int *codechandle, char *stream_type, int stream_index);
int _MMSoundMgrIpcPlayDTMFWithStreamInfo(int tone, int repeat, int volume, int client_pid, int *codechandle, char *stream_type, int stream_index);
-//int __mm_sound_mgr_ipc_get_current_connected_device_list(mm_ipc_msg_t *msg, GList **device_list, int *total_num);
int __mm_sound_mgr_ipc_get_current_connected_device_list(int device_flags, mm_sound_device_t **device_list, int *total_num);
-/* send signal : mgr_xxx -> mgr_ipc_dbus */
-int _MMIpcCBSndMsg(mm_ipc_msg_t *msg);
-int _MMIpcCBRecvMsg(mm_ipc_msg_t *msg);
-int _MMIpcCBMsgEnQueueAgain(mm_ipc_msg_t *msg);
-
-int __mm_sound_mgr_ipc_freeze_send (char* command, int pid);
-
int __mm_sound_mgr_ipc_notify_play_file_end (int handle);
int __mm_sound_mgr_ipc_notify_device_connected (mm_sound_device_t *device, gboolean is_connected);
int __mm_sound_mgr_ipc_notify_device_info_changed (mm_sound_device_t *device, int changed_device_info_type);
#include "include/mm_sound_mgr_ipc_dbus.h"
#include "../include/mm_sound_common.h"
-#include "../include/mm_sound_msg.h"
//#include "include/mm_sound_thread_pool.h"
#include "include/mm_sound_mgr_codec.h"
#include <mm_error.h>
return __mm_sound_mgr_ipc_dbus_notify_available_device_changed(device_in, device_out, available);
}
-int __mm_sound_mgr_ipc_freeze_send (char* command, int pid)
-{
- return mm_sound_mgr_ipc_dbus_send_signal_freeze ( command, pid);
-}
-
-/* should be converted to general type */
-int _MMIpcCBSndMsg(mm_ipc_msg_t *msg)
-{
-// return _MMIpcMsgqCBSndMsg(msg);
- return MM_ERROR_NONE;
-}
-int _MMIpcCBRecvMsg(mm_ipc_msg_t *msg)
-{
-// return _MMIpcMsgqCBRecvMsg(msg);
- return MM_ERROR_NONE;
-}
-int _MMIpcCBMsgEnQueueAgain(mm_ipc_msg_t *msg)
-{
-// return _MMIpcMsgqCBMsgEnQueueAgain(msg);
- return MM_ERROR_NONE;
-}
-
int MMSoundMgrIpcInit(void)
{
return MM_ERROR_NONE;
#include "include/mm_sound_mgr_ipc_dbus.h"
#include "include/mm_sound_mgr_ipc.h"
+#include "../include/mm_sound_dbus.h"
#define BUS_NAME_SOUND_SERVER "org.tizen.SoundServer"
"</node>";
GDBusConnection* conn_g;
-typedef void (*dbus_method_handler)(GDBusMethodInvocation *invocation);
-typedef int (*dbus_signal_sender)(GDBusConnection *conn, GVariant *parameter);
-
-struct mm_sound_dbus_method{
- struct mm_sound_dbus_method_info info;
- dbus_method_handler handler;
-};
-
-struct mm_sound_dbus_signal{
- struct mm_sound_dbus_signal_info info;
- dbus_signal_sender sender;
-};
-
static void handle_method_play_file_start(GDBusMethodInvocation* invocation);
static void handle_method_play_file_start_with_stream_info(GDBusMethodInvocation* invocation);
static void handle_method_play_file_stop(GDBusMethodInvocation* invocation);
/* TODO : generate introspection xml automatically, with these value include argument and reply */
/* TODO : argument check with these information */
/* TODO : divide object and interface with features (ex. play, path, device) */
-struct mm_sound_dbus_method methods[METHOD_CALL_MAX] = {
- [METHOD_CALL_TEST] = {
+mm_sound_dbus_method_intf_t methods[AUDIO_METHOD_MAX] = {
+ [AUDIO_METHOD_TEST] = {
.info = {
.name = "MethodTest1",
},
.handler = handle_method_test
},
- [METHOD_CALL_PLAY_FILE_START] = {
+ [AUDIO_METHOD_PLAY_FILE_START] = {
.info = {
.name = "PlayFileStart",
},
.handler = handle_method_play_file_start
},
- [METHOD_CALL_PLAY_FILE_START_WITH_STREAM_INFO] = {
+ [AUDIO_METHOD_PLAY_FILE_START_WITH_STREAM_INFO] = {
.info = {
.name = "PlayFileStartWithStreamInfo",
},
.handler = handle_method_play_file_start_with_stream_info
},
- [METHOD_CALL_PLAY_FILE_STOP] = {
+ [AUDIO_METHOD_PLAY_FILE_STOP] = {
.info = {
.name = "PlayFileStop",
},
.handler = handle_method_play_file_stop
},
- [METHOD_CALL_CLEAR_FOCUS] = {
+ [AUDIO_METHOD_CLEAR_FOCUS] = {
.info = {
.name = "ClearFocus",
},
.handler = handle_method_clear_focus
},
- [METHOD_CALL_PLAY_DTMF] = {
+ [AUDIO_METHOD_PLAY_DTMF] = {
.info = {
.name = "PlayDTMF",
},
.handler = handle_method_play_dtmf
},
- [METHOD_CALL_PLAY_DTMF_WITH_STREAM_INFO] = {
+ [AUDIO_METHOD_PLAY_DTMF_WITH_STREAM_INFO] = {
.info = {
.name = "PlayDTMFWithStreamInfo",
},
.handler = handle_method_play_dtmf_with_stream_info
},
- [METHOD_CALL_GET_CONNECTED_DEVICE_LIST] = {
+ [AUDIO_METHOD_GET_CONNECTED_DEVICE_LIST] = {
.info = {
.name = "GetConnectedDeviceList",
},
},
};
-struct mm_sound_dbus_signal signals[SIGNAL_MAX] = {
- [SIGNAL_TEST] = {
- .info = {
- .name = "SignalTest1",
- },
- },
- [SIGNAL_PLAY_FILE_END] = {
- .info = {
- .name = "PlayFileEnd",
- },
- },
- [SIGNAL_VOLUME_CHANGED] = {
- .info = {
- .name = "VolumeChanged",
- },
- },
- [SIGNAL_DEVICE_CONNECTED] = {
- .info = {
- .name = "DeviceConnected",
- },
- },
- [SIGNAL_DEVICE_INFO_CHANGED] = {
- .info = {
- .name = "DeviceInfoChanged",
- },
- },
-};
-
-
-
static GDBusNodeInfo *introspection_data = NULL;
guint sound_server_owner_id ;
return "org.tizen.multimedia.common.Unknown";
}
-static int mm_sound_mgr_ipc_dbus_send_signal(int signal_type, GVariant *parameter)
+static int mm_sound_mgr_ipc_dbus_send_signal(audio_event_t event, GVariant *parameter)
{
- int ret = MM_ERROR_NONE;
- GDBusConnection *conn = NULL;
- GError* err = NULL;
- gboolean emit_success = FALSE;
-
- if (signal_type < 0 || signal_type >= SIGNAL_MAX || !parameter) {
- debug_error("Invalid Argument");
+ if(mm_sound_dbus_emit_signal(AUDIO_PROVIDER_SOUND_SERVER, event, parameter) != MM_ERROR_NONE) {
+ debug_error("Sound Server Emit signal failed");
return MM_ERROR_SOUND_INTERNAL;
}
-
- debug_log("Signal Emit : %s", signals[signal_type].info.name);
-
- if (!conn_g) {
- conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
- if (!conn && err) {
- debug_error ("g_bus_get_sync() error (%s) ", err->message);
- g_error_free (err);
- return MM_ERROR_SOUND_INTERNAL;
- }
- conn_g = conn;
- }
-/*
- if (!g_variant_is_of_type(parameter, G_VARIANT_TYPE(signals[signal_type].info.argument))) {
- debug_error("Invalid Signal Parameter");
- return MM_ERROR_INVALID_ARGUMENT;
- }
- */
-
- emit_success = g_dbus_connection_emit_signal(conn_g, NULL, OBJECT_SOUND_SERVER, INTERFACE_SOUND_SERVER,
- signals[signal_type].info.name, parameter, &err);
- if (!emit_success && err) {
- debug_error("Emit signal (%s) failed, (%s)", signals[signal_type].info.name, err->message);
- g_error_free(err);
- return MM_ERROR_SOUND_INTERNAL;
- }
-
- return ret;
+ return MM_ERROR_NONE;
}
static int _get_sender_pid(GDBusMethodInvocation* invocation)
g_variant_get(params, "(ii)", &val, &val2);
debug_log("Got value : %d , %d", val, val2);
- if ((ret = mm_sound_mgr_ipc_dbus_send_signal(SIGNAL_TEST, g_variant_new("(i)", val+val2))) != MM_ERROR_NONE) {
+ if ((ret = mm_sound_mgr_ipc_dbus_send_signal(AUDIO_EVENT_TEST, g_variant_new("(i)", val+val2))) != MM_ERROR_NONE) {
debug_error("signal send error : %X", ret);
} else {
debug_error("signal send success");
}
debug_log("Method Call, obj : %s, intf : %s, method : %s", object_path, interface_name, method_name);
- for (method_idx = 0; method_idx < METHOD_CALL_MAX; method_idx++) {
+ for (method_idx = 0; method_idx < AUDIO_METHOD_MAX; method_idx++) {
if (!g_strcmp0(method_name, methods[method_idx].info.name)) {
methods[method_idx].handler(invocation);
}
}
}
-/* not for mm-sound client */
-int mm_sound_mgr_ipc_dbus_send_signal_freeze (char* command, int pid)
-{
- GError *err = NULL;
- GDBusConnection *conn = NULL;
- gboolean ret;
-
- if (command == NULL || pid <= 0) {
- debug_error ("invalid arguments [%s][%d]", command, pid);
- return -1;
- }
-
- conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
- if (!conn && err) {
- debug_error ("g_bus_get_sync() error (%s) ", err->message);
- g_error_free (err);
- return -1;
- }
-
- ret = g_dbus_connection_emit_signal (conn,
- NULL, PROC_DBUS_OBJECT, PROC_DBUS_INTERFACE, PROC_DBUS_METHOD,
- g_variant_new ("(si)", command, pid),
- &err);
- if (!ret && err) {
- debug_error ("g_dbus_connection_emit_signal() error (%s) ", err->message);
- goto error;
- }
-
- ret = g_dbus_connection_flush_sync(conn, NULL, &err);
- if (!ret && err) {
- debug_error ("g_dbus_connection_flush_sync() error (%s) ", err->message);
- goto error;
- }
-
- g_object_unref(conn);
- debug_msg ("sending [%s] for pid (%d) success", command, pid);
-
- return 0;
-
-error:
- g_error_free (err);
- g_object_unref(conn);
- return -1;
-}
-
int __mm_sound_mgr_ipc_dbus_notify_device_connected (mm_sound_device_t *device, gboolean is_connected)
{
int ret = MM_ERROR_NONE;
GVariantBuilder builder;
GVariant* param = NULL;
- debug_log("Send Signal '%s'", signals[SIGNAL_DEVICE_CONNECTED]);
+ debug_log("Send device connected signal");
g_variant_builder_init(&builder, G_VARIANT_TYPE("((iiiis)b)"));
g_variant_builder_open(&builder, G_VARIANT_TYPE_TUPLE);
g_variant_builder_add(&builder, "b", is_connected);
param = g_variant_builder_end(&builder);
if (param) {
- if ((ret = mm_sound_mgr_ipc_dbus_send_signal(SIGNAL_DEVICE_CONNECTED, param))!= MM_ERROR_NONE) {
+ if ((ret = mm_sound_mgr_ipc_dbus_send_signal(AUDIO_EVENT_DEVICE_CONNECTED, param))!= MM_ERROR_NONE) {
debug_error("Send device connected signal failed");
}
} else {
GVariantBuilder builder;
GVariant* param = NULL;
- debug_log("Send Signal '%s'", signals[SIGNAL_DEVICE_INFO_CHANGED]);
+ debug_log("Send device info changed signal");
g_variant_builder_init(&builder, G_VARIANT_TYPE("((iiiis)i)"));
g_variant_builder_open(&builder, G_VARIANT_TYPE_TUPLE);
g_variant_builder_add(&builder, "i", changed_device_info_type);
param = g_variant_builder_end(&builder);
if (param) {
- if ((ret = mm_sound_mgr_ipc_dbus_send_signal(SIGNAL_DEVICE_INFO_CHANGED, param)) != MM_ERROR_NONE) {
+ if ((ret = mm_sound_mgr_ipc_dbus_send_signal(AUDIO_EVENT_DEVICE_INFO_CHANGED, param)) != MM_ERROR_NONE) {
debug_error("Send device info changed signal failed");
}
} else {
int ret = MM_ERROR_NONE;
GVariant* param = NULL;
- debug_log("Send Signal '%s'", signals[SIGNAL_VOLUME_CHANGED]);
+ debug_log("Send Signal volume changed signal");
param = g_variant_new("(uu)", vol_type, value);
if (param) {
- if ((ret = mm_sound_mgr_ipc_dbus_send_signal(SIGNAL_VOLUME_CHANGED, param)) != MM_ERROR_NONE) {
+ if ((ret = mm_sound_mgr_ipc_dbus_send_signal(AUDIO_EVENT_VOLUME_CHANGED, param)) != MM_ERROR_NONE) {
debug_error("Send device connected signal failed");
}
} else {
int ret = MM_ERROR_NONE;
GVariant* param = NULL;
- debug_log("Send Signal '%s'", signals[SIGNAL_PLAY_FILE_END]);
+ debug_log("Send play file ended signal");
param = g_variant_new("(i)", handle);
if (param) {
- if ((ret = mm_sound_mgr_ipc_dbus_send_signal(SIGNAL_PLAY_FILE_END, param)) != MM_ERROR_NONE) {
+ if ((ret = mm_sound_mgr_ipc_dbus_send_signal(AUDIO_EVENT_PLAY_FILE_END, param)) != MM_ERROR_NONE) {
debug_error("Send play file end for '%d' failed", handle);
}
} else {