mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
pulse-server: Factor out sample spec/channel parsing from modargs
This should be more broadly useful for other modules.
This commit is contained in:
parent
9c8a578e21
commit
abf193452c
2 changed files with 51 additions and 35 deletions
|
|
@ -177,6 +177,54 @@ static void add_props(struct pw_properties *props, const char *str)
|
|||
free(s);
|
||||
}
|
||||
|
||||
static int args_to_audioinfo(struct impl *impl, struct pw_properties *props, struct spa_audio_info_raw *info)
|
||||
{
|
||||
const char *str;
|
||||
|
||||
/* We don't use any incoming format setting and use our native format */
|
||||
info->format = SPA_AUDIO_FORMAT_F32P;
|
||||
|
||||
if ((str = pw_properties_get(props, "channels")) != NULL) {
|
||||
info->channels = pw_properties_parse_int(str);
|
||||
pw_properties_set(props, "channels", NULL);
|
||||
} else {
|
||||
info->channels = impl->defs.sample_spec.channels;
|
||||
}
|
||||
if ((str = pw_properties_get(props, "rate")) != NULL) {
|
||||
info->rate = pw_properties_parse_int(str);
|
||||
pw_properties_set(props, "rate", NULL);
|
||||
} else {
|
||||
info->rate = 0;
|
||||
}
|
||||
|
||||
if ((str = pw_properties_get(props, "channel_map")) != NULL) {
|
||||
struct channel_map map;
|
||||
|
||||
channel_map_parse(str, &map);
|
||||
if (info->channels != map.channels) {
|
||||
pw_log_error("Mismatched channel map");
|
||||
return -EINVAL;
|
||||
}
|
||||
channel_map_to_positions(&map, info->position);
|
||||
pw_properties_set(props, "channel_map", NULL);
|
||||
} else {
|
||||
if (info->channels == impl->defs.channel_map.channels) {
|
||||
channel_map_to_positions(&impl->defs.channel_map, info->position);
|
||||
} else if (info->channels == 1) {
|
||||
info->position[0] = SPA_AUDIO_CHANNEL_MONO;
|
||||
} else if (info->channels == 2) {
|
||||
info->position[0] = SPA_AUDIO_CHANNEL_FL;
|
||||
info->position[1] = SPA_AUDIO_CHANNEL_FR;
|
||||
} else {
|
||||
pw_log_error("Mismatched channel map");
|
||||
return -EINVAL;
|
||||
}
|
||||
/* TODO: pull in all of pa_channel_map_init_auto() */
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include "module-loopback.c"
|
||||
#include "module-null-sink.c"
|
||||
#include "module-native-protocol-tcp.c"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue