From: Seungbae Shin Date: Wed, 28 Dec 2022 08:01:18 +0000 (+0900) Subject: Add internal API to query current media playback device id X-Git-Tag: accepted/tizen/unified/20230105.154708~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F19%2F286119%2F2;p=platform%2Fcore%2Fapi%2Fsound-manager.git Add internal API to query current media playback device id int sound_manager_get_current_media_playback_device_id(int *device_id) [Version] 0.7.2 [Issue Type] Internal API Change-Id: I8cbb1e7829da66d59b5fdd1f53bc4084f75f4be9 --- diff --git a/include/sound_manager_internal.h b/include/sound_manager_internal.h index 39b2c57..9ba9e8a 100644 --- a/include/sound_manager_internal.h +++ b/include/sound_manager_internal.h @@ -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); + /** * @} */ diff --git a/include/sound_manager_private.h b/include/sound_manager_private.h index d8a4c9e..16f1364 100644 --- a/include/sound_manager_private.h +++ b/include/sound_manager_private.h @@ -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); diff --git a/packaging/capi-media-sound-manager.spec b/packaging/capi-media-sound-manager.spec index 43f922f..e512f2e 100644 --- a/packaging/capi-media-sound-manager.spec +++ b/packaging/capi-media-sound-manager.spec @@ -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 diff --git a/src/sound_manager.c b/src/sound_manager.c index 263e836..10b5144 100644 --- a/src/sound_manager.c +++ b/src/sound_manager.c @@ -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) diff --git a/src/sound_manager_internal.c b/src/sound_manager_internal.c index 1c78a10..c369aa6 100644 --- a/src/sound_manager_internal.c +++ b/src/sound_manager_internal.c @@ -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 diff --git a/src/sound_manager_private.c b/src/sound_manager_private.c index ef52fe8..126674a 100644 --- a/src/sound_manager_private.c +++ b/src/sound_manager_private.c @@ -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); diff --git a/test/sound_manager_test.c b/test/sound_manager_test.c index ca21a20..203c4bc 100644 --- a/test/sound_manager_test.c +++ b/test/sound_manager_test.c @@ -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; }