const char *direction = NULL;
const char *type = NULL;
dbus_uint32_t level = 0;
+ uint32_t old_level = 0;
stream_type_t stream_type = STREAM_SINK_INPUT;
- int ret = 0;
+ int ret = RET_MSG_OK;
pa_assert(conn);
pa_assert(msg);
goto finish;
}
- /* check vconf update here, volume will not be set if update fails */
- if ((ret = update_volume_vconf(type, level))) {
+ if (get_volume_level_by_type(m, GET_VOLUME_CURRENT_LEVEL, stream_type, type, &old_level) != 0) {
ret = RET_MSG_ERROR_INTERNAL;
goto finish;
}
- if ((ret = set_volume_level_by_type(m, stream_type, type, level)) != 0)
+ if ((ret = set_volume_level_by_type(m, stream_type, type, level)) != 0) {
ret = (ret == -2) ? RET_MSG_ERROR_INVALID_ARGUMENT : RET_MSG_ERROR_INTERNAL;
+ goto finish;
+ }
+
+ if (update_volume_vconf(type, level) != 0) {
+ ret = RET_MSG_ERROR_INTERNAL;
+ pa_log_error("Failed to update volume vconf, rollback to old level[%u]", old_level);
+ set_volume_level_by_type(m, stream_type, type, old_level);
+ }
finish:
pa_dbus_send_basic_value_reply(conn, msg, DBUS_TYPE_STRING, &stream_manager_dbus_ret_str[ret]);
- if (ret == 0)
+ if (ret == RET_MSG_OK)
send_volume_changed_signal(conn, direction, type, level);
}