Add internal API to query current media playback device id 19/286119/2
authorSeungbae Shin <seungbae.shin@samsung.com>
Wed, 28 Dec 2022 08:01:18 +0000 (17:01 +0900)
committerSeungbae Shin <seungbae.shin@samsung.com>
Mon, 2 Jan 2023 02:05:48 +0000 (11:05 +0900)
int sound_manager_get_current_media_playback_device_id(int *device_id)

[Version] 0.7.2
[Issue Type] Internal API

Change-Id: I8cbb1e7829da66d59b5fdd1f53bc4084f75f4be9

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

index 39b2c57268d5ae5029864ac1edbed8296db2bead..9ba9e8abd59d6dd2028a844ce464270cee9513ed 100644 (file)
@@ -1374,6 +1374,21 @@ int sound_manager_get_device_sample_rate(sound_device_h device, sound_sample_rat
  */
 int sound_manager_get_device_channels(sound_device_h device, int *channels);
 
+/**
+ * @internal
+ * @brief Gets the current device id for media playback stream.
+ * @since_tizen 7.5
+ *
+ * @param[out] device_id       The output device id that a media playback stream can go out
+ * @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_NO_DATA No data
+ * @see sound_manager_get_current_media_playback_device_type()
+ */
+int sound_manager_get_current_media_playback_device_id(int *device_id);
+
 /**
  * @}
  */
index d8a4c9e7a2862907ed50edca4d1af4959aebe396..16f136483014fff3615b3154f5c972a5079c97eb 100644 (file)
@@ -311,7 +311,7 @@ int _set_volume_level(const char *direction, const char *volume_type, unsigned i
 
 int _get_current_volume_type(const char *direction, char **volume_type);
 
-int _get_current_media_routing_path(const char *direction, sound_device_type_e *device_type);
+int _get_current_media_routing_path(const char *direction, int *device_id, sound_device_type_e *device_type);
 
 void _update_focus_status(unsigned int index, unsigned int acquired_focus_status);
 
index 43f922fc9759e868b9346a09dfa2e53089ac2ac2..e512f2e275b065f721bcd8f8de35add491b2b50f 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-sound-manager
 Summary:    Sound Manager library
-Version:    0.7.1
+Version:    0.7.2
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 263e8364dc12f89a822300c5da510f8f33d4b6b8..10b5144a1d4cbddac3af6ebb7562e15e6405d938 100644 (file)
@@ -707,9 +707,10 @@ int sound_manager_is_stream_on_device(sound_stream_info_h stream_info, sound_dev
 
 int sound_manager_get_current_media_playback_device_type(sound_device_type_e *device_type)
 {
+       int unused;
        SM_ARG_CHECK(device_type);
 
-       return _get_current_media_routing_path("out", device_type);
+       return _get_current_media_routing_path("out", &unused, device_type);
 }
 
 int sound_manager_get_current_playback_focus(sound_stream_focus_change_reason_e *acquired_by, int *flags, char **extra_info)
index 1c78a10cd98d2bd33661385cbaf7018265c8920c..c369aa6db867c4b43103deeb3ceff1df69a98d03 100644 (file)
@@ -987,3 +987,11 @@ int sound_manager_get_host_volume(sound_type_e type, int *volume)
 
        return _convert_sound_manager_error_code(__func__, ret);
 }
+
+int sound_manager_get_current_media_playback_device_id(int *device_id)
+{
+       sound_device_type_e unused;
+       SM_ARG_CHECK(device_id);
+
+       return _get_current_media_routing_path("out", device_id, &unused);
+}
\ No newline at end of file
index ef52fe808518c8ba0be9eb9355bc7a5e3b8f1954..126674a455903b9d5392580e5f53f27a35b9050e 100644 (file)
@@ -1466,7 +1466,7 @@ LEAVE:
        return ret;
 }
 
-int _get_current_media_routing_path(const char *direction, sound_device_type_e *device_type)
+int _get_current_media_routing_path(const char *direction, int *device_id, sound_device_type_e *device_type)
 {
        int ret = SOUND_MANAGER_ERROR_NONE;
        GVariant *result = NULL;
@@ -1474,8 +1474,10 @@ int _get_current_media_routing_path(const char *direction, sound_device_type_e *
        GError *err = NULL;
        const gchar *dbus_device_type = NULL;
        const gchar *dbus_ret = NULL;
+       unsigned int dbus_device_id;
 
        SM_ARG_CHECK(direction);
+       SM_ARG_CHECK(device_id);
        SM_ARG_CHECK(device_type);
 
        if ((ret = __get_dbus_connection(&conn)) != SOUND_MANAGER_ERROR_NONE)
@@ -1487,7 +1489,7 @@ int _get_current_media_routing_path(const char *direction, sound_device_type_e *
                                                        PA_STREAM_MANAGER_INTERFACE,
                                                        PA_STREAM_MANAGER_METHOD_NAME_GET_CURRENT_MEDIA_ROUTING_PATH,
                                                        g_variant_new("(s)", direction),
-                                                       G_VARIANT_TYPE("(ss)"),
+                                                       G_VARIANT_TYPE("(uss)"),
                                                        G_DBUS_CALL_FLAGS_NONE,
                                                        DBUS_METHOD_TIMEOUT,
                                                        NULL,
@@ -1502,16 +1504,15 @@ int _get_current_media_routing_path(const char *direction, sound_device_type_e *
                //LCOV_EXCL_STOP
        }
 
-       g_variant_get(result, "(&s&s)", &dbus_device_type, &dbus_ret);
+       g_variant_get(result, "(u&s&s)", &dbus_device_id, &dbus_device_type, &dbus_ret);
 
        if (!strncmp("STREAM_MANAGER_RETURN_OK", dbus_ret, strlen(dbus_ret))) {
+               *device_id = (int)dbus_device_id;
                if (_convert_device_type_str_to_enum(dbus_device_type, device_type) < 0)
                        ret = SOUND_MANAGER_ERROR_INTERNAL;//LCOV_EXCL_LINE
        } else {
-               if (!strncmp("none", dbus_device_type, strlen(dbus_device_type)))
-                       ret = SOUND_MANAGER_ERROR_NO_DATA;
-               else
-                       ret = SOUND_MANAGER_ERROR_INTERNAL;
+               ret = (!strncmp("none", dbus_device_type, strlen(dbus_device_type))) ?
+                       SOUND_MANAGER_ERROR_NO_DATA : SOUND_MANAGER_ERROR_INTERNAL;
        }
 
        LOGI("dbus_ret[%s] ret[0x%x]", dbus_ret, ret);
index ca21a2036b77b3058971c541acaa218985a0baf9..203c4bc6c604f12b50903c999b010c0a8967f296 100644 (file)
@@ -2424,6 +2424,7 @@ static void interpret(char *cmd)
        case CURRENT_STATUS_GET_CURRENT_MEDIA_PLAYBACK_DEVICE_TYPE: {
                int ret = SOUND_MANAGER_ERROR_NONE;
                sound_device_type_e device_type;
+               int device_id;
 
                ret = sound_manager_get_current_media_playback_device_type(&device_type);
                if (ret)
@@ -2431,6 +2432,12 @@ static void interpret(char *cmd)
                else
                        g_print("device type is [%s]\n", g_device_type_str[device_type]);
 
+               ret = sound_manager_get_current_media_playback_device_id(&device_id);
+               if (ret)
+                       g_print("fail to sound_manager_get_current_media_playback_device_id, ret(0x%x)\n", ret);
+               else
+                       g_print("device id is [%d]\n", device_id);
+
                reset_menu_state();
                break;
        }