From: Sangchul Lee Date: Wed, 13 Nov 2019 05:38:19 +0000 (+0900) Subject: stream-manager-dbus: Support invalid argument error returned by handle_set_volume_level() X-Git-Tag: accepted/tizen/unified/20191118.122954^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F28%2F217728%2F1;p=platform%2Fcore%2Fmultimedia%2Fpulseaudio-modules-tizen.git stream-manager-dbus: Support invalid argument error returned by handle_set_volume_level() [Version] 11.1.88 [Issue Type] Improvement Change-Id: Icd45ce7efd08b651341027385ca5b7f184410c0a Signed-off-by: Sangchul Lee --- diff --git a/packaging/pulseaudio-modules-tizen.spec b/packaging/pulseaudio-modules-tizen.spec index a011caa..3194b96 100644 --- a/packaging/pulseaudio-modules-tizen.spec +++ b/packaging/pulseaudio-modules-tizen.spec @@ -1,6 +1,6 @@ Name: pulseaudio-modules-tizen Summary: Pulseaudio modules for Tizen -Version: 11.1.87 +Version: 11.1.88 Release: 0 Group: Multimedia/Audio License: LGPL-2.1+ diff --git a/src/stream-manager-dbus.c b/src/stream-manager-dbus.c index 972c6d6..a54b4e9 100644 --- a/src/stream-manager-dbus.c +++ b/src/stream-manager-dbus.c @@ -893,6 +893,7 @@ static void handle_set_volume_level(DBusConnection *conn, DBusMessage *msg, void DBusMessage *reply = NULL; pa_stream_manager *m = (pa_stream_manager*)userdata; int ret = 0; + ret_msg_t ret_msg = RET_MSG_ERROR_INTERNAL; pa_assert(conn); pa_assert(msg); @@ -912,21 +913,24 @@ static void handle_set_volume_level(DBusConnection *conn, DBusMessage *msg, void else if (pa_safe_streq(direction, "out")) stream_type = STREAM_SINK_INPUT; else { - pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_STRING, &stream_manager_dbus_ret_str[RET_MSG_ERROR_INTERNAL], DBUS_TYPE_INVALID)); + pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_STRING, &stream_manager_dbus_ret_str[ret_msg], DBUS_TYPE_INVALID)); ret = -1; goto finish; } /* check vconf update here, volume will not be set if update fails */ if ((ret = update_volume_vconf(type, level))) { - pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_STRING, &stream_manager_dbus_ret_str[RET_MSG_ERROR_INTERNAL], DBUS_TYPE_INVALID)); + pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_STRING, &stream_manager_dbus_ret_str[ret_msg], DBUS_TYPE_INVALID)); goto finish; } - if ((ret = set_volume_level_by_type(m, stream_type, type, level))) - pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_STRING, &stream_manager_dbus_ret_str[RET_MSG_ERROR_INTERNAL], DBUS_TYPE_INVALID)); - else + if ((ret = set_volume_level_by_type(m, stream_type, type, level))) { + if (ret == -2) + ret_msg = RET_MSG_ERROR_INVALID_ARGUMENT; + pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_STRING, &stream_manager_dbus_ret_str[ret_msg], DBUS_TYPE_INVALID)); + } else { pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_STRING, &stream_manager_dbus_ret_str[RET_MSG_OK], DBUS_TYPE_INVALID)); + } finish: pa_assert_se(dbus_connection_send(conn, reply, NULL)); diff --git a/src/stream-manager-volume.c b/src/stream-manager-volume.c index f524444..073adf6 100644 --- a/src/stream-manager-volume.c +++ b/src/stream-manager-volume.c @@ -210,7 +210,7 @@ static int get_volume_value(pa_stream_manager *m, stream_type_t stream_type, boo if (!(value = pa_idxset_get_by_index(v->values[stream_type].idx_volume_values, volume_level))) { pa_log_error("failed to pa_idxset_get_by_index()"); - return -1; + return -2; } volume_linear = *value; @@ -344,6 +344,7 @@ int32_t set_volume_level_by_type(pa_stream_manager *m, stream_type_t stream_type void *s = NULL; pa_hashmap *volumes = NULL; pa_cvolume cv; + int ret = 0; pa_assert(m); pa_assert(m->volume_infos); @@ -363,7 +364,7 @@ int32_t set_volume_level_by_type(pa_stream_manager *m, stream_type_t stream_type if (!(v = pa_hashmap_get(volumes, volume_type))) { pa_log_error("could not get volume_info, stream_type[%d], volume_type[%s]", stream_type, volume_type); - return -1; + return -2; } if (pa_safe_streq(volume_type, MASTER_VOLUME_TYPE) && MASTER_VOLUME_LEVEL_MAX < volume_level) { @@ -379,8 +380,8 @@ int32_t set_volume_level_by_type(pa_stream_manager *m, stream_type_t stream_type if (!pa_safe_streq(volume_type, MASTER_VOLUME_TYPE)) { /* Get volume value */ - if (get_volume_value(m, stream_type, is_hal_volume, volume_type, volume_level, &volume_linear)) - return -1; + if ((ret = get_volume_value(m, stream_type, is_hal_volume, volume_type, volume_level, &volume_linear))) + return ret; PA_IDXSET_FOREACH(s, stream_type == STREAM_SINK_INPUT ? m->core->sink_inputs : m->core->source_outputs, idx) { /* Update volume level of stream if it has requested the volume type */