Add mute API set for internal use 24/199824/2 accepted/tizen/unified/20190221.015440 submit/tizen/20190220.021455
authorSangchul Lee <sc11.lee@samsung.com>
Thu, 14 Feb 2019 08:28:47 +0000 (17:28 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Mon, 18 Feb 2019 06:48:22 +0000 (15:48 +0900)
[Version] 0.5.19
[Issue Type] New feature

Change-Id: I0078859a58d8d6420bf8ca9842165ca5c4d8f339
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
include/sound_manager_internal.h
include/sound_manager_internal_tv.h
packaging/capi-media-sound-manager.spec
src/sound_manager_internal.c
test/sound_manager_test.c

index dcf2e34..f2847c2 100644 (file)
@@ -155,6 +155,39 @@ int sound_manager_get_master_volume(int *level);
 
 /**
  * @internal
+ * @brief Sets the mute specified for a particular sound type.
+ * @since_tizen 5.5
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/volume.set
+ * @param[in]          type The sound type
+ * @param[in]          mute    The mute state to be set: (@c true = mute, @c false = unmute)
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #SOUND_MANAGER_ERROR_NONE Success
+ * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SOUND_MANAGER_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
+ * @see sound_manager_get_mute()
+ */
+int sound_manager_set_mute(sound_type_e type, bool mute);
+
+/**
+ * @internal
+ * @brief Gets the mute specified for a particular sound type.
+ * @since_tizen 5.5
+ * @param[in]          type The sound type
+ * @param[out] muted   The current mute state: (@c true = muted, @c false = unmuted)
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #SOUND_MANAGER_ERROR_NONE Success
+ * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
+ * @see sound_manager_set_mute()
+ */
+int sound_manager_get_mute(sound_type_e type, bool *muted);
+
+/**
+ * @internal
  * @brief Creates a handle for stream information.
  * @since_tizen 3.0
  *
index b9fb146..879e3b4 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
 * Copyright (c) 2015 - 2018 Samsung Electronics Co., Ltd All Rights Reserved
 *
@@ -110,6 +111,39 @@ typedef enum {
 
 /**
  * @internal
+ * @brief Sets the mute specified for a particular sound type.
+ * @since_tizen 5.5
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/volume.set
+ * @param[in]          type The sound type
+ * @param[in]          mute    The mute state to be set: (@c true = mute, @c false = unmute)
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #SOUND_MANAGER_ERROR_NONE Success
+ * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SOUND_MANAGER_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
+ * @see sound_manager_get_mute()
+ */
+int sound_manager_set_mute(sound_type_e type, bool mute);
+
+/**
+ * @internal
+ * @brief Gets the mute specified for a particular sound type.
+ * @since_tizen 5.5
+ * @param[in]          type The sound type
+ * @param[out] muted   The current mute state: (@c true = muted, @c false = unmuted)
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #SOUND_MANAGER_ERROR_NONE Success
+ * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
+ * @see sound_manager_set_mute()
+ */
+int sound_manager_get_mute(sound_type_e type, bool *muted);
+
+/**
+ * @internal
  * @brief Creates a handle for stream information.
  * @since_tizen 3.0
  *
index dc131e8..4d9db35 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-sound-manager
 Summary:    Sound Manager library
-Version:    0.5.18
+Version:    0.5.19
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 7e61c35..a7d1796 100644 (file)
@@ -64,6 +64,33 @@ int sound_manager_get_master_volume(int *level)
 }
 #endif
 
+int sound_manager_set_mute(sound_type_e type, bool mute)
+{
+       int ret = MM_ERROR_NONE;
+
+       if (type >= SOUND_TYPE_NUM)
+               return _convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT);
+
+       ret = mm_sound_set_mute(type, mute);
+       LOGI("type=%d, mute=%d", type, mute);
+
+       return _convert_sound_manager_error_code(__func__, ret);
+}
+
+int sound_manager_get_mute(sound_type_e type, bool *muted)
+{
+       int ret = MM_ERROR_NONE;
+
+       if (type >= SOUND_TYPE_NUM)
+               return _convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT);
+       SM_NULL_ARG_CHECK(muted);
+
+       ret = mm_sound_get_mute(type, muted);
+       LOGI("type=%d, mute=%d", type, *muted);
+
+       return _convert_sound_manager_error_code(__func__, ret);
+}
+
 int sound_manager_create_stream_information_internal(sound_stream_type_internal_e stream_type, sound_stream_focus_state_changed_cb callback, void *user_data, sound_stream_info_h *stream_info)
 {
        int ret = MM_ERROR_NONE;
index 894aaaa..775ce2d 100644 (file)
@@ -34,6 +34,8 @@ enum {
        CURRENT_STATUS_SET_VOLUME,
        CURRENT_STATUS_GET_VOLUME,
        CURRENT_STATUS_GET_CURRENT_SOUND_TYPE,
+       CURRENT_STATUS_SET_MUTE,
+       CURRENT_STATUS_GET_MUTE,
        CURRENT_STATUS_ADD_VOLUME_CHANGED_CB,
        CURRENT_STATUS_REMOVE_VOLUME_CHANGED_CB,
        CURRENT_STATUS_SET_DEVICE_MASK,
@@ -179,33 +181,37 @@ void quit_program()
 
 void _interpret_main_menu(char *cmd)
 {
-       if (strncmp(cmd, "gx", 3) == 0)
+       if (strncmp(cmd, "gx", 2) == 0)
                g_menu_state = CURRENT_STATUS_GET_MAX_VOLUME;
-       else if (strncmp(cmd, "sv", 3) == 0)
+       else if (strncmp(cmd, "sv", 2) == 0)
                g_menu_state = CURRENT_STATUS_SET_VOLUME;
-       else if (strncmp(cmd, "gv", 3) == 0)
+       else if (strncmp(cmd, "gv", 2) == 0)
                g_menu_state = CURRENT_STATUS_GET_VOLUME;
-       else if (strncmp(cmd, "gt", 3) == 0)
+       else if (strncmp(cmd, "gt", 2) == 0)
                g_menu_state = CURRENT_STATUS_GET_CURRENT_SOUND_TYPE;
-       else if (strncmp(cmd, "av", 3) == 0)
+       else if (strncmp(cmd, "av", 2) == 0)
                g_menu_state = CURRENT_STATUS_ADD_VOLUME_CHANGED_CB;
-       else if (strncmp(cmd, "rv", 3) == 0)
+       else if (strncmp(cmd, "rv", 2) == 0)
                g_menu_state = CURRENT_STATUS_REMOVE_VOLUME_CHANGED_CB;
-       else if (strncmp(cmd, "sk", 3) == 0)
+       else if (strncmp(cmd, "sm", 2) == 0)
+               g_menu_state = CURRENT_STATUS_SET_MUTE;
+       else if (strncmp(cmd, "gm", 2) == 0)
+               g_menu_state = CURRENT_STATUS_GET_MUTE;
+       else if (strncmp(cmd, "sk", 2) == 0)
                g_menu_state = CURRENT_STATUS_SET_DEVICE_MASK;
-       else if (strncmp(cmd, "gk", 3) == 0)
+       else if (strncmp(cmd, "gk", 2) == 0)
                g_menu_state = CURRENT_STATUS_GET_DEVICE_MASK;
-       else if (strncmp(cmd, "gl", 3) == 0)
+       else if (strncmp(cmd, "gl", 2) == 0)
                g_menu_state = CURRENT_STATUS_GET_DEVICE_LIST;
-       else if (strncmp(cmd, "pl", 3) == 0)
+       else if (strncmp(cmd, "pl", 2) == 0)
                g_menu_state = CURRENT_STATUS_PRINT_DEVICE_LIST;
-       else if (strncmp(cmd, "fl", 3) == 0)
+       else if (strncmp(cmd, "fl", 2) == 0)
                g_menu_state = CURRENT_STATUS_FREE_DEVICE_LIST;
-       else if (strncmp(cmd, "gn", 3) == 0)
+       else if (strncmp(cmd, "gn", 2) == 0)
                g_menu_state = CURRENT_STATUS_GET_DEVICE_NEXT;
-       else if (strncmp(cmd, "gp", 3) == 0)
+       else if (strncmp(cmd, "gp", 2) == 0)
                g_menu_state = CURRENT_STATUS_GET_DEVICE_PREV;
-       else if (strncmp(cmd, "gd", 3) == 0)
+       else if (strncmp(cmd, "gd", 2) == 0)
                g_menu_state = CURRENT_STATUS_GET_DEVICE_STATE_BY_ID;
        else if (strncmp(cmd, "gssf", 4) == 0)
                g_menu_state = CURRENT_STATUS_GET_SUPPORTED_SAMPLE_FORMATS;
@@ -323,7 +329,9 @@ void display_sub_basic()
        g_print("gx. Get Max Volume \t");
        g_print("gv. Get Volume \t");
        g_print("sv. Set Volume \n");
-       g_print("gt. Get Current Sound Type \n");
+       g_print("gt. Get Current Sound Type \t");
+       g_print("gm. *Get Mute \t");
+       g_print("sm. *Set Mute \n");
        g_print("av. Add Volume Changed CB \t");
        g_print("rv. Remove Volume Changed CB \n");
 #ifndef TIZEN_FEATURE_TV_PROD
@@ -410,6 +418,12 @@ static void displaymenu()
                g_print("*** input sound type(0:SYSTEM 1:NOTIFICATION 2:ALARM 3:RINGTONE 4:MEDIA 5:CALL 6:VOIP 7:VOICE)\n");
        else if (g_menu_state == CURRENT_STATUS_GET_CURRENT_SOUND_TYPE)
                g_print("*** press enter to get current sound type\n");
+       else if (g_menu_state == CURRENT_STATUS_SET_MUTE) {
+               if (flag == 0)
+                       g_print("*** input sound type and desired mute state(0:SYSTEM 1:NOTIFICATION 2:ALARM 3:RINGTONE 4:MEDIA 5:CALL 6:VOIP 7:VOICE, (0:unmute, 1:mute))\n");
+               flag = 1;
+       } else if (g_menu_state == CURRENT_STATUS_GET_MUTE)
+               g_print("*** input sound type(0:SYSTEM 1:NOTIFICATION 2:ALARM 3:RINGTONE 4:MEDIA 5:CALL 6:VOIP 7:VOICE)\n");
        else if (g_menu_state == CURRENT_STATUS_ADD_VOLUME_CHANGED_CB)
                g_print("*** press enter to add volume changed cb\n");
        else if (g_menu_state == CURRENT_STATUS_REMOVE_VOLUME_CHANGED_CB)
@@ -743,6 +757,43 @@ static void interpret(char *cmd)
                reset_menu_state();
                break;
        }
+       case CURRENT_STATUS_SET_MUTE: {
+               static int cnt = 0;
+               static sound_type_e type;
+               bool mute = false;
+               switch (cnt) {
+               case 0:
+                       if (convert_sound_type(&type, cmd) == 1)
+                               cnt++;
+                       else
+                               reset_menu_state();
+                       break;
+               case 1:
+                       mute = (bool)atoi(cmd);
+                       if (sound_manager_set_mute(type, mute) != SOUND_MANAGER_ERROR_NONE)
+                               g_print("fail to set mute\n");
+                       else
+                               g_print("set mute success : sound type(%d), mute(%d)\n", type, mute);
+                       cnt = 0;
+                       reset_menu_state();
+                       break;
+               default:
+                       break;
+               }
+               break;
+       }
+       case CURRENT_STATUS_GET_MUTE: {
+               sound_type_e type;
+               bool muted;
+               if (convert_sound_type(&type, cmd) == 1) {
+                       if (sound_manager_get_mute(type, &muted) != SOUND_MANAGER_ERROR_NONE)
+                               g_print("fail to get mute\n");
+                       else
+                               g_print("get mute success : sound_type(%d), muted(%d)\n", type, muted);
+               }
+               reset_menu_state();
+               break;
+       }
        case CURRENT_STATUS_ADD_VOLUME_CHANGED_CB: {
                if (sound_manager_add_volume_changed_cb(_volume_changed_cb, NULL, &g_volume_cb_id) != SOUND_MANAGER_ERROR_NONE)
                        g_print("fail to add volume changed cb\n");