mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-08 13:29:59 -05:00
dbus: Always accept mono volumes when setting device or stream volume.
pa_sink_set_volume() and friends accept mono volumes too, so no need to impose unneeded restrictions in the D-Bus API.
This commit is contained in:
parent
6c5e3af275
commit
68e6340394
2 changed files with 8 additions and 10 deletions
|
|
@ -422,21 +422,20 @@ static void handle_set_volume(DBusConnection *conn, DBusMessage *msg, DBusMessag
|
||||||
pa_assert(iter);
|
pa_assert(iter);
|
||||||
pa_assert(d);
|
pa_assert(d);
|
||||||
|
|
||||||
pa_cvolume_init(&new_vol);
|
|
||||||
|
|
||||||
device_channels = (d->type == DEVICE_TYPE_SINK) ? d->sink->channel_map.channels : d->source->channel_map.channels;
|
device_channels = (d->type == DEVICE_TYPE_SINK) ? d->sink->channel_map.channels : d->source->channel_map.channels;
|
||||||
|
|
||||||
new_vol.channels = device_channels;
|
|
||||||
|
|
||||||
dbus_message_iter_recurse(iter, &array_iter);
|
dbus_message_iter_recurse(iter, &array_iter);
|
||||||
dbus_message_iter_get_fixed_array(&array_iter, &volume, &n_volume_entries);
|
dbus_message_iter_get_fixed_array(&array_iter, &volume, &n_volume_entries);
|
||||||
|
|
||||||
if (n_volume_entries != device_channels) {
|
if (n_volume_entries != device_channels && n_volume_entries != 1) {
|
||||||
pa_dbus_send_error(conn, msg, DBUS_ERROR_INVALID_ARGS,
|
pa_dbus_send_error(conn, msg, DBUS_ERROR_INVALID_ARGS,
|
||||||
"Expected %u volume entries, got %i.", device_channels, n_volume_entries);
|
"Expected %u volume entries, got %i.", device_channels, n_volume_entries);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pa_cvolume_init(&new_vol);
|
||||||
|
new_vol.channels = n_volume_entries;
|
||||||
|
|
||||||
for (i = 0; i < n_volume_entries; ++i) {
|
for (i = 0; i < n_volume_entries; ++i) {
|
||||||
if (!PA_VOLUME_IS_VALID(volume[i])) {
|
if (!PA_VOLUME_IS_VALID(volume[i])) {
|
||||||
pa_dbus_send_error(conn, msg, DBUS_ERROR_INVALID_ARGS, "Too large volume value: %u", volume[i]);
|
pa_dbus_send_error(conn, msg, DBUS_ERROR_INVALID_ARGS, "Too large volume value: %u", volume[i]);
|
||||||
|
|
|
||||||
|
|
@ -381,21 +381,20 @@ static void handle_set_volume(DBusConnection *conn, DBusMessage *msg, DBusMessag
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pa_cvolume_init(&new_vol);
|
|
||||||
|
|
||||||
stream_channels = s->sink_input->channel_map.channels;
|
stream_channels = s->sink_input->channel_map.channels;
|
||||||
|
|
||||||
new_vol.channels = stream_channels;
|
|
||||||
|
|
||||||
dbus_message_iter_recurse(iter, &array_iter);
|
dbus_message_iter_recurse(iter, &array_iter);
|
||||||
dbus_message_iter_get_fixed_array(&array_iter, &volume, &n_volume_entries);
|
dbus_message_iter_get_fixed_array(&array_iter, &volume, &n_volume_entries);
|
||||||
|
|
||||||
if (n_volume_entries != stream_channels) {
|
if (n_volume_entries != stream_channels && n_volume_entries != 1) {
|
||||||
pa_dbus_send_error(conn, msg, DBUS_ERROR_INVALID_ARGS,
|
pa_dbus_send_error(conn, msg, DBUS_ERROR_INVALID_ARGS,
|
||||||
"Expected %u volume entries, got %u.", stream_channels, n_volume_entries);
|
"Expected %u volume entries, got %u.", stream_channels, n_volume_entries);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pa_cvolume_init(&new_vol);
|
||||||
|
new_vol.channels = n_volume_entries;
|
||||||
|
|
||||||
for (i = 0; i < n_volume_entries; ++i) {
|
for (i = 0; i < n_volume_entries; ++i) {
|
||||||
if (!PA_VOLUME_IS_VALID(volume[i])) {
|
if (!PA_VOLUME_IS_VALID(volume[i])) {
|
||||||
pa_dbus_send_error(conn, msg, DBUS_ERROR_INVALID_ARGS, "Invalid volume: %u", volume[i]);
|
pa_dbus_send_error(conn, msg, DBUS_ERROR_INVALID_ARGS, "Invalid volume: %u", volume[i]);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue