diff --git a/src/modules/module-protocol-pulse.c b/src/modules/module-protocol-pulse.c index 1e87b4baa..79e424de8 100644 --- a/src/modules/module-protocol-pulse.c +++ b/src/modules/module-protocol-pulse.c @@ -194,6 +194,32 @@ * VMs usually can't support the low latency settings that are possible on real * hardware. * + * ### Quirk options + * + *\code{.unparsed} + * pulse.fix.format = "S16LE" + *\endcode + * + * When a stream uses the FIX_FORMAT flag, fixate the format to this value. + * Normally the format would be fixed to the sink/source that the stream connects + * to. When an invalid format (null or "") is set, the FIX_FORMAT flag is ignored. + * + *\code{.unparsed} + * pulse.fix.rate = 48000 + *\endcode + * + * When a stream uses the FIX_RATE flag, fixate the sample rate to this value. + * Normally the rate would be fixed to the sink/source that the stream connects + * to. When a 0 rate is set, the FIX_RATE flag is ignored. + * + *\code{.unparsed} + * pulse.fix.position = "[ FL FR ]" + *\endcode + * + * When a stream uses the FIX_CHANNELS flag, fixate the channels to this value. + * Normally the channels would be fixed to the sink/source that the stream connects + * to. When an invalid position (null or "") is set, the FIX_CHANNELS flag is ignored. + * * ## Command execution * * As part of the server startup sequence, a set of commands can be executed. diff --git a/src/modules/module-protocol-pulse/format.c b/src/modules/module-protocol-pulse/format.c index a4d5376c1..a73317f9d 100644 --- a/src/modules/module-protocol-pulse/format.c +++ b/src/modules/module-protocol-pulse/format.c @@ -243,24 +243,34 @@ void sample_spec_fix(struct sample_spec *ss, struct channel_map *map, { const char *str; if (fix_ss->format != 0) { - if ((str = spa_dict_lookup(props, "pulse.fix.format")) != NULL) - ss->format = format_name2id(str); + if ((str = spa_dict_lookup(props, "pulse.fix.format")) != NULL) { + uint32_t val = format_name2id(str); + if (val != SPA_AUDIO_FORMAT_UNKNOWN) + ss->format = val; + } else ss->format = fix_ss->format; /* convert back and forth to convert potential planar to packed */ ss->format = format_pa2id(format_id2pa(ss->format)); } if (fix_ss->rate != 0) { - if ((str = spa_dict_lookup(props, "pulse.fix.rate")) != NULL) - ss->rate = atoi(str); + if ((str = spa_dict_lookup(props, "pulse.fix.rate")) != NULL) { + uint32_t val = atoi(str); + if (val != 0) + ss->rate = val; + } else ss->rate = fix_ss->rate; ss->rate = SPA_CLAMP(ss->rate, 0u, RATE_MAX); } if (fix_ss->channels != 0) { if ((str = spa_dict_lookup(props, "pulse.fix.position")) != NULL) { - channel_map_parse_position(str, map); - ss->channels = map->channels; + struct channel_map val; + channel_map_parse_position(str, &val); + if (val.channels > 0) { + ss->channels = val.channels; + *map = val; + } } else { ss->channels = fix_ss->channels; *map = *fix_map;