mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
pulse-server: don't send invalid format and channels
This commit is contained in:
parent
0c66b5677b
commit
2cd59fdf8b
2 changed files with 27 additions and 0 deletions
|
|
@ -3410,6 +3410,11 @@ static int fill_sink_info(struct client *client, struct message *m,
|
||||||
|
|
||||||
collect_device_info(o, card, &dev_info);
|
collect_device_info(o, card, &dev_info);
|
||||||
|
|
||||||
|
if (!sample_spec_valid(&dev_info.ss) ||
|
||||||
|
!channel_map_valid(&dev_info.map) ||
|
||||||
|
!volume_valid(&dev_info.volume_info.volume))
|
||||||
|
return -ENOENT;
|
||||||
|
|
||||||
flags = SINK_LATENCY | SINK_DYNAMIC_LATENCY | SINK_DECIBEL_VOLUME;
|
flags = SINK_LATENCY | SINK_DYNAMIC_LATENCY | SINK_DECIBEL_VOLUME;
|
||||||
if ((str = spa_dict_lookup(info->props, PW_KEY_DEVICE_API)) != NULL)
|
if ((str = spa_dict_lookup(info->props, PW_KEY_DEVICE_API)) != NULL)
|
||||||
flags |= SINK_HARDWARE;
|
flags |= SINK_HARDWARE;
|
||||||
|
|
@ -3539,6 +3544,11 @@ static int fill_source_info(struct client *client, struct message *m,
|
||||||
|
|
||||||
collect_device_info(o, card, &dev_info);
|
collect_device_info(o, card, &dev_info);
|
||||||
|
|
||||||
|
if (!sample_spec_valid(&dev_info.ss) ||
|
||||||
|
!channel_map_valid(&dev_info.map) ||
|
||||||
|
!volume_valid(&dev_info.volume_info.volume))
|
||||||
|
return -ENOENT;
|
||||||
|
|
||||||
flags = SOURCE_LATENCY | SOURCE_DYNAMIC_LATENCY | SOURCE_DECIBEL_VOLUME;
|
flags = SOURCE_LATENCY | SOURCE_DYNAMIC_LATENCY | SOURCE_DECIBEL_VOLUME;
|
||||||
if ((str = spa_dict_lookup(info->props, PW_KEY_DEVICE_API)) != NULL)
|
if ((str = spa_dict_lookup(info->props, PW_KEY_DEVICE_API)) != NULL)
|
||||||
flags |= SOURCE_HARDWARE;
|
flags |= SOURCE_HARDWARE;
|
||||||
|
|
@ -3642,6 +3652,11 @@ static int fill_sink_input_info(struct client *client, struct message *m,
|
||||||
|
|
||||||
collect_device_info(o, NULL, &dev_info);
|
collect_device_info(o, NULL, &dev_info);
|
||||||
|
|
||||||
|
if (!sample_spec_valid(&dev_info.ss) ||
|
||||||
|
!channel_map_valid(&dev_info.map) ||
|
||||||
|
!volume_valid(&dev_info.volume_info.volume))
|
||||||
|
return -ENOENT;
|
||||||
|
|
||||||
peer = find_linked(manager, o->id, PW_DIRECTION_OUTPUT);
|
peer = find_linked(manager, o->id, PW_DIRECTION_OUTPUT);
|
||||||
|
|
||||||
message_put(m,
|
message_put(m,
|
||||||
|
|
@ -3707,6 +3722,11 @@ static int fill_source_output_info(struct client *client, struct message *m,
|
||||||
|
|
||||||
collect_device_info(o, NULL, &dev_info);
|
collect_device_info(o, NULL, &dev_info);
|
||||||
|
|
||||||
|
if (!sample_spec_valid(&dev_info.ss) ||
|
||||||
|
!channel_map_valid(&dev_info.map) ||
|
||||||
|
!volume_valid(&dev_info.volume_info.volume))
|
||||||
|
return -ENOENT;
|
||||||
|
|
||||||
peer = find_linked(manager, o->id, PW_DIRECTION_INPUT);
|
peer = find_linked(manager, o->id, PW_DIRECTION_INPUT);
|
||||||
if (peer && is_source_or_monitor(peer)) {
|
if (peer && is_source_or_monitor(peer)) {
|
||||||
peer_id = peer->id;
|
peer_id = peer->id;
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,13 @@ struct volume {
|
||||||
.values[1] = 1.0f, \
|
.values[1] = 1.0f, \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool volume_valid(const struct volume *vol)
|
||||||
|
{
|
||||||
|
if (vol->channels == 0 || vol->channels > CHANNELS_MAX)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
struct volume_info {
|
struct volume_info {
|
||||||
struct volume volume;
|
struct volume volume;
|
||||||
struct channel_map map;
|
struct channel_map map;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue