Add new functions to support ducking state changed callback 92/209792/1 accepted/tizen/unified/20190716.111223 submit/tizen/20190716.020521
authorJeongmo Yang <jm80.yang@samsung.com>
Thu, 11 Jul 2019 05:59:40 +0000 (14:59 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Thu, 11 Jul 2019 06:00:39 +0000 (15:00 +0900)
[Version] 0.12.45
[Profile] Common
[Issue Type] New feature

Change-Id: Ia4664b74e810320c39a268c7f5de1c829ef874e6
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
common/mm_sound_dbus.c
include/mm_sound.h
include/mm_sound_client.h
include/mm_sound_intf.h
include/mm_sound_proxy.h
mm_sound.c
mm_sound_client.c
mm_sound_proxy.c
packaging/libmm-sound.spec

index e026a279732635aa9c6a5ead0e4aa69c3fade8b0..dfd574162ffdbe6377c13152ce4ae89a11626480 100644 (file)
@@ -129,6 +129,9 @@ const mm_sound_dbus_signal_info_t g_events[AUDIO_EVENT_MAX] = {
        },
        [AUDIO_EVENT_CLIENT_HANDLED] = {
                .name = "ClientSignalHandled",
+       },
+       [AUDIO_EVENT_DUCKING_STATE_CHANGED] = {
+               .name = "DuckingStateChanged",
        }
 };
 
@@ -404,6 +407,8 @@ static void _dbus_signal_callback(GDBusConnection *connection,
                (cb_data->user_cb)(AUDIO_EVENT_PLAY_FILE_END, params, cb_data->user_data);
        else if (!strcmp(signal_name, g_events[AUDIO_EVENT_DEVICE_RUNNING_CHANGED].name))
                (cb_data->user_cb)(AUDIO_EVENT_DEVICE_RUNNING_CHANGED, params, cb_data->user_data);
+       else if (!strcmp(signal_name, g_events[AUDIO_EVENT_DUCKING_STATE_CHANGED].name))
+               (cb_data->user_cb)(AUDIO_EVENT_DUCKING_STATE_CHANGED, params, cb_data->user_data);
 }
 
 static void callback_data_free_func(gpointer data)
index 534d8c5f2ddebc149b9c57be966d3cee6822bb3a..a7f3f4808652cfded797d29c9b2596b1c1c09294 100644 (file)
@@ -809,6 +809,11 @@ int mm_sound_get_device_name(MMSoundDevice_t device_h, char **name);
 int mm_sound_get_device_vendor_id(MMSoundDevice_t device_h, int *vendor_id);
 int mm_sound_get_device_product_id(MMSoundDevice_t device_h, int *product_id);
 
+/* Ducking */
+typedef void (*mm_sound_ducking_state_changed_cb) (int idx, bool is_ducked, void *user_data);
+int mm_sound_add_ducking_state_changed_callback(mm_sound_ducking_state_changed_cb func, void *user_data, unsigned int *subs_id);
+int mm_sound_remove_ducking_state_changed_callback(unsigned int subs_id);
+
 /**
  * Active device changed callback function type.
  *
index d939e0bd35ce4c40d84062773092c37d9879ccfa..0781b7a2599b2bbb073cf7d3f63b93fd148d524f 100644 (file)
@@ -73,6 +73,8 @@ int mm_sound_client_set_focus_watch_callback(int pid, mm_sound_focus_type_e type
 int mm_sound_client_unset_focus_watch_callback(int id);
 int mm_sound_client_request_unset_focus_watch_callback(int id);
 int mm_sound_client_execute_focus_func_in_main_context(focus_idle_event_type_e type, int data);
+int mm_sound_client_add_ducking_state_changed_callback(mm_sound_ducking_state_changed_cb func, void* user_data, unsigned int *subs_id);
+int mm_sound_client_remove_ducking_state_changed_callback(unsigned int subs_id);
 
 int mm_sound_client_add_test_callback(mm_sound_test_cb func, void* user_data, unsigned int *subs_id);
 int mm_sound_client_remove_test_callback(unsigned int subs_id);
@@ -88,5 +90,6 @@ typedef void (*mm_sound_device_state_changed_wrapper_cb)(int device_id, const ch
 typedef void (*mm_sound_device_running_changed_wrapper_cb)(int device_id, const char *device_type, int io_direction, int state,
                const char *name, int vendor_id, int product_id, bool is_running, int *stream_id, int stream_num, void *userdata);
 typedef void (*mm_sound_stop_callback_wrapper_func)(int id, void *userdata);
+typedef void (*mm_sound_ducking_state_changed_wrapper_cb)(int idx, bool is_ducked, void *userdata);
 
 #endif /* __MM_SOUND_CLIENT_H__ */
index fa023e0611842d68643675906cc970f436492a7b..020818cb2b82bd74721070c5b86411e5c46c0b19 100644 (file)
@@ -80,6 +80,7 @@ typedef enum audio_event {
        AUDIO_EVENT_CLIENT_SUBSCRIBED, /* Clients send this signal when they subscribed some signal. */
        AUDIO_EVENT_CLIENT_HANDLED, /* Clients send this siganl when they handled some signal. */
        AUDIO_EVENT_DEVICE_RUNNING_CHANGED,
+       AUDIO_EVENT_DUCKING_STATE_CHANGED,
        AUDIO_EVENT_MAX
 } audio_event_t;
 
index 4f6d28254d8ff0b8d37aa03ad879beac980fb43d..ee662a36e25a6439706a72a3b2577fb00e9f28b4 100644 (file)
@@ -58,6 +58,8 @@ int mm_sound_proxy_is_stream_on_device(int stream_id, int device_id, bool *is_on
 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);
+int mm_sound_proxy_add_ducking_state_changed_callback(mm_sound_ducking_state_changed_wrapper_cb func, void* userdata, mm_sound_proxy_userdata_free freefunc, unsigned *subs_id);
+int mm_sound_proxy_remove_ducking_state_changed_callback(unsigned subs_id);
 int mm_sound_proxy_set_mute_by_type(const char *volume_type, bool mute);
 int mm_sound_proxy_emergent_exit(int exit_pid);
 int mm_sound_proxy_set_filter_by_type(const char *stream_type, const char *filter_name, const char *filter_parameters, const char *filter_group);
index a689cbed688c00aa175320e49e979cff17e34110..97d4b53c27ae00bff84e125b07a387a367c779c1 100644 (file)
@@ -331,6 +331,37 @@ int mm_sound_remove_test_callback(unsigned int subs_id)
        return ret;
 }
 
+EXPORT_API
+int mm_sound_add_ducking_state_changed_callback(mm_sound_ducking_state_changed_cb func, void *user_data, unsigned int *subs_id)
+{
+       int ret = MM_ERROR_NONE;
+
+       if (func == NULL || subs_id == NULL) {
+               debug_error("argument is not valid");
+               return MM_ERROR_INVALID_ARGUMENT;
+       }
+
+       ret = mm_sound_client_add_ducking_state_changed_callback(func, user_data, subs_id);
+       if (ret < 0) {
+               debug_error("Can not add ducking state changed callback, ret = %x", ret);
+       }
+
+       return ret;
+}
+
+EXPORT_API
+int mm_sound_remove_ducking_state_changed_callback(unsigned int subs_id)
+{
+       int ret = MM_ERROR_NONE;
+
+       ret = mm_sound_client_remove_ducking_state_changed_callback(subs_id);
+       if (ret < 0) {
+               debug_error("Can not remove ducking state changed callback, ret = %x", ret);
+       }
+
+       return ret;
+}
+
 #ifdef TIZEN_TV
 EXPORT_API
 void mm_sound_dotnet_cleanup(int signo)
index e66193ac93a2174d152f5d017ccdd5d826324e3c..328ee4d06c395961e03cfd329a1b5a60baca9dc9 100644 (file)
@@ -1477,6 +1477,34 @@ int mm_sound_client_execute_focus_func_in_main_context(focus_idle_event_type_e t
        return MM_ERROR_NONE;
 }
 
+int mm_sound_client_add_ducking_state_changed_callback(mm_sound_ducking_state_changed_cb func, void* userdata, unsigned int *subs_id)
+{
+       int ret = MM_ERROR_NONE;
+       struct callback_data *cb_data = NULL;
+
+       debug_fenter();
+
+       GET_CB_DATA(cb_data, func, userdata, NULL);
+
+       ret = mm_sound_proxy_add_ducking_state_changed_callback((mm_sound_ducking_state_changed_wrapper_cb)func,
+               cb_data, g_free, subs_id);
+
+       debug_fleave();
+
+       return ret;
+}
+
+int mm_sound_client_remove_ducking_state_changed_callback(unsigned int subs_id)
+{
+       int ret = MM_ERROR_NONE;
+       debug_fenter();
+
+       ret = mm_sound_proxy_remove_ducking_state_changed_callback(subs_id);
+
+       debug_fleave();
+       return ret;
+}
+
 int mm_sound_client_add_test_callback(mm_sound_test_cb func, void* user_data, unsigned int *subs_id)
 {
        int ret = MM_ERROR_NONE;
index 04f493fa2e2b55a4a79f19ef1f02a1e6aa869346..5f3548cbf0210aacee3f84ec36ca02ad3388ad48 100644 (file)
@@ -238,6 +238,13 @@ static void dbus_callback(audio_event_t event, GVariant *params, void *userdata)
                int ended_handle = 0;
                g_variant_get(params, "(i)", &ended_handle);
                ((mm_sound_stop_callback_wrapper_func)(cb_data->user_cb))(ended_handle, cb_data->user_data);
+       } else if (event == AUDIO_EVENT_DUCKING_STATE_CHANGED) {
+               int idx = 0;
+               int is_ducked = 0;
+
+               g_variant_get(params, "(ii)", &idx, &is_ducked);
+
+               ((mm_sound_ducking_state_changed_wrapper_cb)(cb_data->user_cb))(idx, is_ducked, cb_data->user_data);
        }
 }
 
@@ -711,6 +718,37 @@ int mm_sound_proxy_remove_volume_changed_callback(unsigned subs_id)
        return ret;
 }
 
+int mm_sound_proxy_add_ducking_state_changed_callback(mm_sound_ducking_state_changed_wrapper_cb func, void* userdata, mm_sound_proxy_userdata_free freefunc, unsigned *subs_id)
+{
+       int ret = MM_ERROR_NONE;
+       struct callback_data *cb_data;
+
+       debug_fenter();
+
+       CB_DATA_NEW(cb_data, func, userdata, freefunc);
+
+       if ((ret = mm_sound_dbus_signal_subscribe_to(AUDIO_PROVIDER_STREAM_MANAGER, AUDIO_EVENT_DUCKING_STATE_CHANGED, dbus_callback, cb_data, simple_callback_data_free_func, &cb_data->subs_id)) != MM_ERROR_NONE)
+               debug_error("Add Duckding State changed callback failed");
+       else
+               *subs_id = cb_data->subs_id;
+
+       debug_fleave();
+
+       return ret;
+}
+
+int mm_sound_proxy_remove_ducking_state_changed_callback(unsigned subs_id)
+{
+       int ret = MM_ERROR_NONE;
+       debug_fenter();
+
+       if ((ret = mm_sound_dbus_signal_unsubscribe(subs_id)) != MM_ERROR_NONE)
+               debug_error("Remove Ducking State changed callback failed");
+
+       debug_fleave();
+       return ret;
+}
+
 int mm_sound_proxy_set_mute_by_type(const char *volume_type, bool mute)
 {
        int ret = MM_ERROR_NONE;
index 62c3ffbae38c4e6bb192cf7158195eb8250e9a3d..745d37015f1380e3fbff009f2e33205d62061e80 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-sound
 Summary:    MMSound Package contains client lib and sound_server binary
-Version:    0.12.44
+Version:    0.12.45
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0