mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
pulse-server: improve FIX_ flag handling
When a stream uses the FIX_ flags it should negotiate to the format of the sink or source it connects to. To do this, look up the sink or source and look at the format, use this as the allowed format for the stream when the FIX flags are set. Make it still possible to override with with properties. Use audio.position to make it possible to set a channelmap override.
This commit is contained in:
parent
ad6ab7e0b7
commit
eb797cac48
3 changed files with 68 additions and 21 deletions
|
|
@ -225,27 +225,35 @@ bool sample_spec_valid(const struct sample_spec *ss)
|
|||
ss->channels > 0 && ss->channels <= CHANNELS_MAX);
|
||||
}
|
||||
|
||||
void sample_spec_fix(struct sample_spec *ss, struct spa_dict *props,
|
||||
bool fix_format, bool fix_rate, bool fix_channels)
|
||||
void sample_spec_fix(struct sample_spec *ss, struct channel_map *map,
|
||||
const struct sample_spec *fix_ss, const struct channel_map *fix_map,
|
||||
struct spa_dict *props)
|
||||
{
|
||||
const char *str;
|
||||
if (fix_format) {
|
||||
if (fix_ss->format != 0) {
|
||||
if ((str = spa_dict_lookup(props, "pulse.fix.format")) != NULL)
|
||||
ss->format = format_name2id(str);
|
||||
else
|
||||
ss->format = SPA_AUDIO_FORMAT_UNKNOWN;
|
||||
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_rate) {
|
||||
if (fix_ss->rate != 0) {
|
||||
if ((str = spa_dict_lookup(props, "pulse.fix.rate")) != NULL)
|
||||
ss->rate = atoi(str);
|
||||
else
|
||||
ss->rate = 0;
|
||||
ss->rate = fix_ss->rate;
|
||||
ss->rate = SPA_CLAMP(ss->rate, 0u, RATE_MAX);
|
||||
}
|
||||
if (fix_channels) {
|
||||
if ((str = spa_dict_lookup(props, "pulse.fix.channels")) != NULL)
|
||||
ss->channels = atoi(str);
|
||||
else
|
||||
ss->channels = 0;
|
||||
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;
|
||||
} else {
|
||||
ss->channels = fix_ss->channels;
|
||||
*map = *fix_map;
|
||||
}
|
||||
ss->channels = SPA_CLAMP(ss->channels, 0u, CHANNELS_MAX);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue