Add internal api for rpi playback route 34/259034/7 accepted/tizen/unified/20210708.131541 submit/tizen/20210705.072009 submit/tizen/20210707.025110
authorSeungbae Shin <seungbae.shin@samsung.com>
Mon, 31 May 2021 07:17:16 +0000 (16:17 +0900)
committerSeungbae Shin <seungbae.shin@samsung.com>
Mon, 5 Jul 2021 06:58:28 +0000 (15:58 +0900)
[Version] 0.6.36
[Issue Type] Internal feature

Change-Id: I6b820b5510bb01ef8d71e959c2cf12ac23f9b313

include/sound_manager_internal.h
include/sound_manager_private.h
packaging/capi-media-sound-manager.spec
src/sound_manager_internal.c
src/sound_manager_private.c
test/sound_manager_test.c

index 6c0709b..1a105bf 100644 (file)
@@ -121,6 +121,18 @@ typedef enum {
 
 /**
  * @internal
+ * @brief Enumeration for rpi playback route
+ * @since_tizen 6.5
+ */
+typedef enum {
+       SOUND_RPI_PLAYBACK_AUTO,      /**< NOT IN USE */
+       SOUND_RPI_PLAYBACK_HEADPHONE, /**< Headphone (default) */
+       SOUND_RPI_PLAYBACK_HDMI1,     /**< HDMI1 */
+       SOUND_RPI_PLAYBACK_HDMI2,     /**< HDMI2 (only for RPI4) */
+} sound_rpi_playback_route_type;
+
+/**
+ * @internal
  * @brief Gets the maximum master volume level.
  * @since_tizen 3.0
  * @param[out] max_level       The maximum volume level
@@ -1226,6 +1238,35 @@ int sound_manager_start_aec(void);
 int sound_manager_stop_aec(void);
 
 /**
+ * @internal
+ * @brief Set force hdmi route
+ * @since_tizen 6.5
+ * @param[in]  type The playback route type for rpi
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #SOUND_MANAGER_ERROR_NONE Success
+ * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
+ * @retval #SOUND_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @see sound_manager_get_rpi_playback_route()
+ */
+int sound_manager_set_rpi_playback_route(sound_rpi_playback_route_type type);
+
+/**
+ * @internal
+ * @brief Get force hdmi route status
+ * @since_tizen 6.5
+ * @remarks The default value is #SOUND_RPI_PLAYBACK_HEADPHONE.
+ * @param[out] type The current playback route type of rpi
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #SOUND_MANAGER_ERROR_NONE Success
+ * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
+ * @retval #SOUND_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @see sound_manager_set_rpi_playback_route()
+ */
+int sound_manager_get_rpi_playback_route(sound_rpi_playback_route_type *type);
+
+/**
  * @}
  */
 
index 79d3c62..b3e7a25 100644 (file)
@@ -394,6 +394,10 @@ int _get_preemptive_device(sound_stream_type_e stream_type, int *in_device_id, i
 
 int _get_latest_stream_pid(int stream_type, unsigned int *pid);
 
+int _set_rpi_playback_route(sound_rpi_playback_route_type type);
+
+int _get_rpi_playback_route(sound_rpi_playback_route_type *type);
+
 #ifdef __cplusplus
 }
 #endif
index fb9375a..d1d116c 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-sound-manager
 Summary:    Sound Manager library
-Version:    0.6.35
+Version:    0.6.36
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 5d19a0b..da5e51b 100644 (file)
@@ -904,3 +904,12 @@ int sound_manager_stop_aec(void)
        return _stop_aec();
 }
 
+int sound_manager_set_rpi_playback_route(sound_rpi_playback_route_type type)
+{
+       return _set_rpi_playback_route(type);
+}
+
+int sound_manager_get_rpi_playback_route(sound_rpi_playback_route_type *type)
+{
+       return _get_rpi_playback_route(type);
+}
\ No newline at end of file
index 2307926..53e9c39 100644 (file)
@@ -68,6 +68,7 @@
 #define PA_STREAM_MANAGER_METHOD_NAME_PUBLISH_LOCAL_DEVICE      "PublishLocalDevice"
 #define PA_STREAM_MANAGER_METHOD_NAME_DISCOVER_REMOTE_DEVICE    "DiscoverRemoteDevice"
 #define PA_STREAM_MANAGER_METHOD_NAME_SET_REMOTE_PERMISSION     "SetRemotePermission"
+#define PA_STREAM_MANAGER_METHOD_NAME_SET_RPI_PLAYBACK_ROUTE    "SetRpiPlaybackRoute"
 
 #define PA_STREAM_MANAGER_SIGNAL_NAME_REMOTE_FOUND              "RemoteFound"
 
@@ -95,6 +96,8 @@
 #define VCONF_PATH_PREFIX_VOLUME                                "file/private/sound/volume/"
 #define VCONF_PATH_MAX                                          64
 
+#define VCONF_SOUND_RPI_PLAYBACK_ROUTE                          "file/private/sound/rpi_playback_route"
+
 #define SM_SOUND_TYPE_CHECK(x_sound_type, x_error) \
 if (!strncmp(x_sound_type, "system", strlen(x_sound_type)) || \
        !strncmp(x_sound_type, "notification", strlen(x_sound_type)) || \
@@ -2542,6 +2545,37 @@ int _stop_aec(void)
 
        return SOUND_MANAGER_ERROR_NONE;
 }
+
+int _set_rpi_playback_route(sound_rpi_playback_route_type type)
+{
+       int ret;
+
+       LOGI("set rpi playback route : %u", type);
+
+       ret = __dbus_method_call(PA_STREAM_MANAGER_METHOD_NAME_SET_RPI_PLAYBACK_ROUTE, g_variant_new("(u)", type), NULL);
+       if (ret != SOUND_MANAGER_ERROR_NONE)
+               LOGE("_set_rpi_playback_route failed");
+
+       return ret;
+}
+
+int _get_rpi_playback_route(sound_rpi_playback_route_type *type)
+{
+       int route_type;
+       int ret;
+
+       ret = vconf_get_int(VCONF_SOUND_RPI_PLAYBACK_ROUTE, &route_type);
+       if (ret != 0) {
+               LOGE("Failed to get vconf [%s], err [%d]", VCONF_SOUND_RPI_PLAYBACK_ROUTE, ret);
+               return SOUND_MANAGER_ERROR_INVALID_OPERATION;
+       }
+
+       LOGI("current rpi playback route : %u", route_type);
+       *type = route_type;
+
+       return SOUND_MANAGER_ERROR_NONE;
+}
+
 //LCOV_EXCL_STOP
 
 static int __check_manual_route_type(sound_stream_info_s *stream_info)
index 2a02610..d6b0fe5 100644 (file)
@@ -120,6 +120,8 @@ enum {
        CURRENT_STATUS_SET_REMOTE_PERMISSION,
        CURRENT_STATUS_LAUNCH_ECHO_CANCEL,
        CURRENT_STATUS_QUIT_ECHO_CANCEL,
+       CURRENT_STATUS_SET_RPI_PLAYBACK_ROUTE,
+       CURRENT_STATUS_GET_RPI_PLAYBACK_ROUTE,
 };
 
 
@@ -395,6 +397,10 @@ void _interpret_main_menu(char *cmd)
                g_menu_state = CURRENT_STATUS_LAUNCH_ECHO_CANCEL;
        else if (strncmp(cmd, "qec", MAX_CMD_LEN) == 0)
                g_menu_state = CURRENT_STATUS_QUIT_ECHO_CANCEL;
+       else if (strncmp(cmd, "srpr", MAX_CMD_LEN) == 0)
+               g_menu_state = CURRENT_STATUS_SET_RPI_PLAYBACK_ROUTE;
+       else if (strncmp(cmd, "grpr", MAX_CMD_LEN) == 0)
+               g_menu_state = CURRENT_STATUS_GET_RPI_PLAYBACK_ROUTE;
        else if (strncmp(cmd, "q", MAX_CMD_LEN) == 0) {
                g_print("closing the test suite\n");
                quit_program();
@@ -506,6 +512,8 @@ void display_sub_basic()
        g_print("alw. *Allow remote device\n");
        g_print("lec. *Launch EC\n");
        g_print("qec. *Quit EC\n");
+       g_print("srpr. *Set RPI playback route\t");
+       g_print("grpr. *Get RPI playback route\n");
        g_print("                                                                 * is for internal usage.\n");
        g_print("=========================================================================================\n");
 }
@@ -708,6 +716,10 @@ static void displaymenu()
                g_print("*** press enter to launch acoustic echo cancellation service\n");
        else if (g_menu_state == CURRENT_STATUS_QUIT_ECHO_CANCEL)
                g_print("*** press enter to quit acoustic echo cancellation service\n");
+       else if (g_menu_state == CURRENT_STATUS_SET_RPI_PLAYBACK_ROUTE)
+               g_print("*** input rpi playback route to set (0:auto, 1:headphone, 2:HDMI1, 3:HDMI2(rpi4 only)\n");
+       else if (g_menu_state == CURRENT_STATUS_GET_RPI_PLAYBACK_ROUTE)
+               g_print("*** press enter to get rpi playback route\n");
        else {
                g_print("*** unknown status.\n");
                quit_program();
@@ -2844,6 +2856,32 @@ static void interpret(char *cmd)
                reset_menu_state();
                break;
        }
+       case CURRENT_STATUS_SET_RPI_PLAYBACK_ROUTE: {
+               int ret;
+               sound_rpi_playback_route_type type = atoi(cmd);
+
+               ret = sound_manager_set_rpi_playback_route(type);
+               if (!ret)
+                       g_print("success to set rpi playback route\n");
+               else
+                       g_print("fail to set rpi playback route\n");
+
+               reset_menu_state();
+               break;
+       }
+       case CURRENT_STATUS_GET_RPI_PLAYBACK_ROUTE: {
+               int ret;
+               sound_rpi_playback_route_type type;
+
+               ret = sound_manager_get_rpi_playback_route(&type);
+               if (!ret)
+                       g_print("success to get rpi playback route : %u\n", type);
+               else
+                       g_print("fail to get rpi playback route\n");
+
+               reset_menu_state();
+               break;
+       }
        }
 end:
        g_timeout_add(100, timeout_menu_display, 0);