mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-02 09:01:46 -05:00
volume: Use a macro to check if a volume is valid
This adds a PA_VOLUME_IS_VALID() macro for checking if a given pa_volume_t is valid. This makes changes to the volume ranges simpler (just change PA_VOLUME_MAX, for example, without needing to modify any other code).
This commit is contained in:
parent
4d84a00b49
commit
1d2ef7923d
9 changed files with 30 additions and 27 deletions
|
|
@ -1310,7 +1310,7 @@ static void handle_upload_sample(DBusConnection *conn, DBusMessage *msg, void *u
|
|||
}
|
||||
|
||||
for (i = 0; i < n_volume_entries; ++i) {
|
||||
if (default_volume[i] > PA_VOLUME_MAX) {
|
||||
if (!PA_VOLUME_IS_VALID(default_volume[i])) {
|
||||
pa_dbus_send_error(conn, msg, DBUS_ERROR_INVALID_ARGS, "Invalid volume: %u.", default_volume[i]);
|
||||
goto finish;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -438,7 +438,7 @@ static void handle_set_volume(DBusConnection *conn, DBusMessage *msg, DBusMessag
|
|||
}
|
||||
|
||||
for (i = 0; i < n_volume_entries; ++i) {
|
||||
if (volume[i] > PA_VOLUME_MAX) {
|
||||
if (!PA_VOLUME_IS_VALID(volume[i])) {
|
||||
pa_dbus_send_error(conn, msg, DBUS_ERROR_INVALID_ARGS, "Too large volume value: %u", volume[i]);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -366,7 +366,7 @@ static void handle_play(DBusConnection *conn, DBusMessage *msg, void *userdata)
|
|||
if (!(property_list = pa_dbus_get_proplist_arg(conn, msg, &msg_iter)))
|
||||
return;
|
||||
|
||||
if (volume > PA_VOLUME_MAX) {
|
||||
if (PA_VOLUME_IS_VALID(volume)) {
|
||||
pa_dbus_send_error(conn, msg, DBUS_ERROR_INVALID_ARGS, "Invalid volume.");
|
||||
goto finish;
|
||||
}
|
||||
|
|
@ -416,7 +416,7 @@ static void handle_play_to_sink(DBusConnection *conn, DBusMessage *msg, void *us
|
|||
goto finish;
|
||||
}
|
||||
|
||||
if (volume > PA_VOLUME_MAX) {
|
||||
if (PA_VOLUME_IS_VALID(volume)) {
|
||||
pa_dbus_send_error(conn, msg, DBUS_ERROR_INVALID_ARGS, "Invalid volume.");
|
||||
goto finish;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -378,7 +378,7 @@ static void handle_set_volume(DBusConnection *conn, DBusMessage *msg, DBusMessag
|
|||
}
|
||||
|
||||
for (i = 0; i < n_volume_entries; ++i) {
|
||||
if (volume[i] > PA_VOLUME_MAX) {
|
||||
if (PA_VOLUME_IS_VALID(volume[i])) {
|
||||
pa_dbus_send_error(conn, msg, DBUS_ERROR_INVALID_ARGS, "Too large volume value: %u", volume[i]);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -367,7 +367,7 @@ static int get_volume_arg(DBusConnection *conn, DBusMessage *msg, DBusMessageIte
|
|||
pa_assert_se(dbus_message_iter_next(&struct_iter));
|
||||
dbus_message_iter_get_basic(&struct_iter, &chan_vol);
|
||||
|
||||
if (chan_vol > PA_VOLUME_MAX) {
|
||||
if (PA_VOLUME_IS_VALID(chan_vol)) {
|
||||
pa_dbus_send_error(conn, msg, DBUS_ERROR_INVALID_ARGS, "Invalid volume: %u", chan_vol);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue