pulse-server: add 2 quirks to block sink/source updates

See #1517
This commit is contained in:
Wim Taymans 2023-06-15 11:45:43 +02:00
parent d04e430f23
commit a0a32af386
4 changed files with 17 additions and 2 deletions

View file

@ -129,6 +129,8 @@ pulse.rules = [
# Possible quirks:" # Possible quirks:"
# force-s16-info forces sink and source info as S16 format # force-s16-info forces sink and source info as S16 format
# remove-capture-dont-move removes the capture DONT_MOVE flag # remove-capture-dont-move removes the capture DONT_MOVE flag
# block-source-volume blocks updates to source volume
# block-sink-volume blocks updates to sink volume
#quirks = [ ] #quirks = [ ]
} }
} }
@ -158,4 +160,8 @@ pulse.rules = [
} }
} }
} }
#{
# matches = [ { application.process.binary = "Discord" } ]
# actions = { quirks = [ block-source-volume ] }
#}
] ]

View file

@ -2911,10 +2911,15 @@ static int do_set_volume(struct client *client, uint32_t command, uint32_t tag,
(index != SPA_ID_INVALID && name != NULL)) (index != SPA_ID_INVALID && name != NULL))
return -EINVAL; return -EINVAL;
if (command == COMMAND_SET_SINK_VOLUME) if (command == COMMAND_SET_SINK_VOLUME) {
if (client->quirks & QUIRK_BLOCK_SINK_VOLUME)
return -EPERM;
direction = PW_DIRECTION_OUTPUT; direction = PW_DIRECTION_OUTPUT;
else } else {
if (client->quirks & QUIRK_BLOCK_SOURCE_VOLUME)
return -EPERM;
direction = PW_DIRECTION_INPUT; direction = PW_DIRECTION_INPUT;
}
o = find_device(client, index, name, direction == PW_DIRECTION_OUTPUT, &is_monitor); o = find_device(client, index, name, direction == PW_DIRECTION_OUTPUT, &is_monitor);
if (o == NULL || (info = o->info) == NULL || info->props == NULL) if (o == NULL || (info = o->info) == NULL || info->props == NULL)

View file

@ -17,6 +17,8 @@ static uint64_t parse_quirks(const char *str)
static const struct { const char *key; uint64_t value; } quirk_keys[] = { static const struct { const char *key; uint64_t value; } quirk_keys[] = {
{ "force-s16-info", QUIRK_FORCE_S16_FORMAT }, { "force-s16-info", QUIRK_FORCE_S16_FORMAT },
{ "remove-capture-dont-move", QUIRK_REMOVE_CAPTURE_DONT_MOVE }, { "remove-capture-dont-move", QUIRK_REMOVE_CAPTURE_DONT_MOVE },
{ "block-source-volume", QUIRK_BLOCK_SOURCE_VOLUME },
{ "block-sink-volume", QUIRK_BLOCK_SINK_VOLUME },
}; };
SPA_FOR_EACH_ELEMENT_VAR(quirk_keys, i) { SPA_FOR_EACH_ELEMENT_VAR(quirk_keys, i) {
if (spa_streq(str, i->key)) if (spa_streq(str, i->key))

View file

@ -10,6 +10,8 @@
#define QUIRK_FORCE_S16_FORMAT (1ull<<0) /** forces S16 sample format in sink and source #define QUIRK_FORCE_S16_FORMAT (1ull<<0) /** forces S16 sample format in sink and source
* info */ * info */
#define QUIRK_REMOVE_CAPTURE_DONT_MOVE (1ull<<1) /** removes the capture stream DONT_MOVE flag */ #define QUIRK_REMOVE_CAPTURE_DONT_MOVE (1ull<<1) /** removes the capture stream DONT_MOVE flag */
#define QUIRK_BLOCK_SOURCE_VOLUME (1ull<<2) /** block volume changes to sources */
#define QUIRK_BLOCK_SINK_VOLUME (1ull<<3) /** block volume changes to sinks */
int client_update_quirks(struct client *client); int client_update_quirks(struct client *client);