mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
spa: make helper to init spa_audio_info_raw from dict
Make a function that can initialize raw audio info from a dict and fill in the defaults. We can use this in many of the modules when the audio format is parsed.
This commit is contained in:
parent
d932e52d5b
commit
e3a7035e8f
19 changed files with 204 additions and 255 deletions
|
|
@ -327,17 +327,13 @@ struct stream {
|
|||
|
||||
static void parse_audio_info(const struct pw_properties *props, struct spa_audio_info_raw *info)
|
||||
{
|
||||
const char *str;
|
||||
|
||||
spa_zero(*info);
|
||||
info->format = SPA_AUDIO_FORMAT_F32P;
|
||||
info->channels = pw_properties_get_uint32(props, PW_KEY_AUDIO_CHANNELS, 0);
|
||||
info->channels = SPA_MIN(info->channels, SPA_AUDIO_MAX_CHANNELS);
|
||||
if ((str = pw_properties_get(props, SPA_KEY_AUDIO_POSITION)) != NULL)
|
||||
spa_audio_parse_position(str, strlen(str), info->position, &info->channels);
|
||||
if (info->channels == 0)
|
||||
spa_audio_parse_position(DEFAULT_POSITION, strlen(DEFAULT_POSITION),
|
||||
info->position, &info->channels);
|
||||
spa_audio_info_raw_init_dict_keys(info,
|
||||
&SPA_DICT_ITEMS(
|
||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, "F32P"),
|
||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_POSITION, DEFAULT_POSITION)),
|
||||
&props->dict,
|
||||
SPA_KEY_AUDIO_CHANNELS,
|
||||
SPA_KEY_AUDIO_POSITION, NULL);
|
||||
}
|
||||
|
||||
static void ringbuffer_init(struct ringbuffer *r, void *buf, uint32_t size)
|
||||
|
|
|
|||
|
|
@ -153,7 +153,6 @@ PW_LOG_TOPIC_STATIC(mod_topic, "mod." NAME);
|
|||
#define PW_LOG_TOPIC_DEFAULT mod_topic
|
||||
|
||||
#define DEFAULT_RATE 48000
|
||||
#define DEFAULT_CHANNELS 2
|
||||
#define DEFAULT_POSITION "[ FL FR ]"
|
||||
|
||||
/* Hopefully this is enough for any combination of AEC engine and resampler
|
||||
|
|
@ -1194,21 +1193,15 @@ static const struct pw_impl_module_events module_events = {
|
|||
|
||||
static void parse_audio_info(struct pw_properties *props, struct spa_audio_info_raw *info)
|
||||
{
|
||||
const char *str;
|
||||
|
||||
*info = SPA_AUDIO_INFO_RAW_INIT(
|
||||
.format = SPA_AUDIO_FORMAT_F32P);
|
||||
info->rate = pw_properties_get_uint32(props, PW_KEY_AUDIO_RATE, info->rate);
|
||||
if (info->rate == 0)
|
||||
info->rate = DEFAULT_RATE;
|
||||
|
||||
info->channels = pw_properties_get_uint32(props, PW_KEY_AUDIO_CHANNELS, info->channels);
|
||||
info->channels = SPA_MIN(info->channels, SPA_AUDIO_MAX_CHANNELS);
|
||||
if ((str = pw_properties_get(props, SPA_KEY_AUDIO_POSITION)) != NULL)
|
||||
spa_audio_parse_position(str, strlen(str), info->position, &info->channels);
|
||||
if (info->channels == 0)
|
||||
spa_audio_parse_position(DEFAULT_POSITION, strlen(DEFAULT_POSITION),
|
||||
info->position, &info->channels);
|
||||
spa_audio_info_raw_init_dict_keys(info,
|
||||
&SPA_DICT_ITEMS(
|
||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, "F32P"),
|
||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_RATE, SPA_STRINGIFY(DEFAULT_RATE)),
|
||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_POSITION, DEFAULT_POSITION)),
|
||||
&props->dict,
|
||||
SPA_KEY_AUDIO_RATE,
|
||||
SPA_KEY_AUDIO_CHANNELS,
|
||||
SPA_KEY_AUDIO_POSITION, NULL);
|
||||
}
|
||||
|
||||
static void copy_props(struct impl *impl, struct pw_properties *props, const char *key)
|
||||
|
|
|
|||
|
|
@ -97,6 +97,8 @@
|
|||
PW_LOG_TOPIC_STATIC(mod_topic, "mod." NAME);
|
||||
#define PW_LOG_TOPIC_DEFAULT mod_topic
|
||||
|
||||
#define DEFAULT_POSITION "[ FL FR ]"
|
||||
|
||||
static const struct spa_dict_item module_props[] = {
|
||||
{ PW_KEY_MODULE_AUTHOR, "Wim Taymans <wim.taymans@gmail.com>" },
|
||||
{ PW_KEY_MODULE_DESCRIPTION, "Create example filter streams" },
|
||||
|
|
@ -450,15 +452,14 @@ static const struct pw_impl_module_events module_events = {
|
|||
|
||||
static void parse_audio_info(struct pw_properties *props, struct spa_audio_info_raw *info)
|
||||
{
|
||||
const char *str;
|
||||
|
||||
*info = SPA_AUDIO_INFO_RAW_INIT(
|
||||
.format = SPA_AUDIO_FORMAT_F32P);
|
||||
info->rate = pw_properties_get_int32(props, PW_KEY_AUDIO_RATE, 0);
|
||||
info->channels = pw_properties_get_uint32(props, PW_KEY_AUDIO_CHANNELS, 0);
|
||||
info->channels = SPA_MIN(info->channels, SPA_AUDIO_MAX_CHANNELS);
|
||||
if ((str = pw_properties_get(props, SPA_KEY_AUDIO_POSITION)) != NULL)
|
||||
spa_audio_parse_position(str, strlen(str), info->position, &info->channels);
|
||||
spa_audio_info_raw_init_dict_keys(info,
|
||||
&SPA_DICT_ITEMS(
|
||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, "F32P"),
|
||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_POSITION, DEFAULT_POSITION)),
|
||||
&props->dict,
|
||||
SPA_KEY_AUDIO_RATE,
|
||||
SPA_KEY_AUDIO_CHANNELS,
|
||||
SPA_KEY_AUDIO_POSITION, NULL);
|
||||
}
|
||||
|
||||
static void copy_props(struct impl *impl, struct pw_properties *props, const char *key)
|
||||
|
|
|
|||
|
|
@ -275,24 +275,16 @@ static const struct pw_impl_module_events module_events = {
|
|||
|
||||
static void parse_audio_info(const struct pw_properties *props, struct spa_audio_info_raw *info)
|
||||
{
|
||||
const char *str;
|
||||
|
||||
spa_zero(*info);
|
||||
if ((str = pw_properties_get(props, PW_KEY_AUDIO_FORMAT)) == NULL)
|
||||
str = DEFAULT_FORMAT;
|
||||
info->format = spa_type_audio_format_from_short_name(str);
|
||||
|
||||
info->rate = pw_properties_get_uint32(props, PW_KEY_AUDIO_RATE, info->rate);
|
||||
if (info->rate == 0)
|
||||
info->rate = DEFAULT_RATE;
|
||||
|
||||
info->channels = pw_properties_get_uint32(props, PW_KEY_AUDIO_CHANNELS, info->channels);
|
||||
info->channels = SPA_MIN(info->channels, SPA_AUDIO_MAX_CHANNELS);
|
||||
if ((str = pw_properties_get(props, SPA_KEY_AUDIO_POSITION)) != NULL)
|
||||
spa_audio_parse_position(str, strlen(str), info->position, &info->channels);
|
||||
if (info->channels == 0)
|
||||
spa_audio_parse_position(DEFAULT_POSITION, strlen(DEFAULT_POSITION),
|
||||
info->position, &info->channels);
|
||||
spa_audio_info_raw_init_dict_keys(info,
|
||||
&SPA_DICT_ITEMS(
|
||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, DEFAULT_FORMAT),
|
||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_RATE, SPA_STRINGIFY(DEFAULT_RATE)),
|
||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_POSITION, DEFAULT_POSITION)),
|
||||
&props->dict,
|
||||
SPA_KEY_AUDIO_FORMAT,
|
||||
SPA_KEY_AUDIO_RATE,
|
||||
SPA_KEY_AUDIO_CHANNELS,
|
||||
SPA_KEY_AUDIO_POSITION, NULL);
|
||||
}
|
||||
|
||||
static int calc_frame_size(const struct spa_audio_info_raw *info)
|
||||
|
|
|
|||
|
|
@ -281,24 +281,16 @@ static const struct pw_impl_module_events module_events = {
|
|||
|
||||
static void parse_audio_info(const struct pw_properties *props, struct spa_audio_info_raw *info)
|
||||
{
|
||||
const char *str;
|
||||
|
||||
spa_zero(*info);
|
||||
if ((str = pw_properties_get(props, PW_KEY_AUDIO_FORMAT)) == NULL)
|
||||
str = DEFAULT_FORMAT;
|
||||
info->format = spa_type_audio_format_from_short_name(str);
|
||||
|
||||
info->rate = pw_properties_get_uint32(props, PW_KEY_AUDIO_RATE, info->rate);
|
||||
if (info->rate == 0)
|
||||
info->rate = DEFAULT_RATE;
|
||||
|
||||
info->channels = pw_properties_get_uint32(props, PW_KEY_AUDIO_CHANNELS, info->channels);
|
||||
info->channels = SPA_MIN(info->channels, SPA_AUDIO_MAX_CHANNELS);
|
||||
if ((str = pw_properties_get(props, SPA_KEY_AUDIO_POSITION)) != NULL)
|
||||
spa_audio_parse_position(str, strlen(str), info->position, &info->channels);
|
||||
if (info->channels == 0)
|
||||
spa_audio_parse_position(DEFAULT_POSITION, strlen(DEFAULT_POSITION),
|
||||
info->position, &info->channels);
|
||||
spa_audio_info_raw_init_dict_keys(info,
|
||||
&SPA_DICT_ITEMS(
|
||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, DEFAULT_FORMAT),
|
||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_RATE, SPA_STRINGIFY(DEFAULT_RATE)),
|
||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_POSITION, DEFAULT_POSITION)),
|
||||
&props->dict,
|
||||
SPA_KEY_AUDIO_FORMAT,
|
||||
SPA_KEY_AUDIO_RATE,
|
||||
SPA_KEY_AUDIO_CHANNELS,
|
||||
SPA_KEY_AUDIO_POSITION, NULL);
|
||||
}
|
||||
|
||||
static int calc_frame_size(const struct spa_audio_info_raw *info)
|
||||
|
|
|
|||
|
|
@ -1424,18 +1424,13 @@ static void parse_devices(struct impl *impl, const char *val, size_t len)
|
|||
|
||||
static void parse_audio_info(const struct pw_properties *props, struct spa_audio_info_raw *info)
|
||||
{
|
||||
const char *str;
|
||||
|
||||
spa_zero(*info);
|
||||
info->format = SPA_AUDIO_FORMAT_F32P;
|
||||
info->rate = 0;
|
||||
info->channels = pw_properties_get_uint32(props, PW_KEY_AUDIO_CHANNELS, info->channels);
|
||||
info->channels = SPA_MIN(info->channels, SPA_AUDIO_MAX_CHANNELS);
|
||||
if ((str = pw_properties_get(props, SPA_KEY_AUDIO_POSITION)) != NULL)
|
||||
spa_audio_parse_position(str, strlen(str), info->position, &info->channels);
|
||||
if (info->channels == 0)
|
||||
spa_audio_parse_position(DEFAULT_POSITION, strlen(DEFAULT_POSITION),
|
||||
info->position, &info->channels);
|
||||
spa_audio_info_raw_init_dict_keys(info,
|
||||
&SPA_DICT_ITEMS(
|
||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, "F32P"),
|
||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_POSITION, DEFAULT_POSITION)),
|
||||
&props->dict,
|
||||
SPA_KEY_AUDIO_CHANNELS,
|
||||
SPA_KEY_AUDIO_POSITION, NULL);
|
||||
}
|
||||
|
||||
static void copy_props(struct impl *impl, struct pw_properties *props, const char *key)
|
||||
|
|
|
|||
|
|
@ -2907,15 +2907,12 @@ static const struct pw_impl_module_events module_events = {
|
|||
|
||||
static void parse_audio_info(struct pw_properties *props, struct spa_audio_info_raw *info)
|
||||
{
|
||||
const char *str;
|
||||
|
||||
*info = SPA_AUDIO_INFO_RAW_INIT(
|
||||
.format = SPA_AUDIO_FORMAT_F32P);
|
||||
info->rate = pw_properties_get_int32(props, PW_KEY_AUDIO_RATE, info->rate);
|
||||
info->channels = pw_properties_get_int32(props, PW_KEY_AUDIO_CHANNELS, info->channels);
|
||||
info->channels = SPA_MIN(info->channels, SPA_AUDIO_MAX_CHANNELS);
|
||||
if ((str = pw_properties_get(props, SPA_KEY_AUDIO_POSITION)) != NULL)
|
||||
spa_audio_parse_position(str, strlen(str), info->position, &info->channels);
|
||||
spa_audio_info_raw_init_dict_keys(info,
|
||||
&SPA_DICT_ITEMS(
|
||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, "F32P")),
|
||||
&props->dict,
|
||||
SPA_KEY_AUDIO_CHANNELS,
|
||||
SPA_KEY_AUDIO_POSITION, NULL);
|
||||
}
|
||||
|
||||
static void copy_props(struct impl *impl, struct pw_properties *props, const char *key)
|
||||
|
|
|
|||
|
|
@ -109,7 +109,6 @@ PW_LOG_TOPIC_STATIC(mod_topic, "mod." NAME);
|
|||
#define MAX_PORTS 128
|
||||
|
||||
#define DEFAULT_CLIENT_NAME "PipeWire"
|
||||
#define DEFAULT_CHANNELS 2
|
||||
#define DEFAULT_POSITION "[ FL FR ]"
|
||||
#define DEFAULT_MIDI_PORTS 1
|
||||
|
||||
|
|
@ -994,18 +993,13 @@ static const struct pw_impl_module_events module_events = {
|
|||
|
||||
static void parse_audio_info(const struct pw_properties *props, struct spa_audio_info_raw *info)
|
||||
{
|
||||
const char *str;
|
||||
|
||||
spa_zero(*info);
|
||||
info->format = SPA_AUDIO_FORMAT_F32P;
|
||||
info->rate = 0;
|
||||
info->channels = pw_properties_get_uint32(props, PW_KEY_AUDIO_CHANNELS, info->channels);
|
||||
info->channels = SPA_MIN(info->channels, SPA_AUDIO_MAX_CHANNELS);
|
||||
if ((str = pw_properties_get(props, SPA_KEY_AUDIO_POSITION)) != NULL)
|
||||
spa_audio_parse_position(str, strlen(str), info->position, &info->channels);
|
||||
if (info->channels == 0)
|
||||
spa_audio_parse_position(DEFAULT_POSITION, strlen(DEFAULT_POSITION),
|
||||
info->position, &info->channels);
|
||||
spa_audio_info_raw_init_dict_keys(info,
|
||||
&SPA_DICT_ITEMS(
|
||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, "F32P"),
|
||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_POSITION, DEFAULT_POSITION)),
|
||||
&props->dict,
|
||||
SPA_KEY_AUDIO_CHANNELS,
|
||||
SPA_KEY_AUDIO_POSITION, NULL);
|
||||
}
|
||||
|
||||
static void copy_props(struct impl *impl, struct pw_properties *props, const char *key)
|
||||
|
|
|
|||
|
|
@ -772,15 +772,13 @@ static const struct pw_impl_module_events module_events = {
|
|||
|
||||
static void parse_audio_info(struct pw_properties *props, struct spa_audio_info_raw *info)
|
||||
{
|
||||
const char *str;
|
||||
|
||||
*info = SPA_AUDIO_INFO_RAW_INIT(
|
||||
.format = SPA_AUDIO_FORMAT_F32P);
|
||||
info->rate = pw_properties_get_int32(props, PW_KEY_AUDIO_RATE, 0);
|
||||
info->channels = pw_properties_get_uint32(props, PW_KEY_AUDIO_CHANNELS, 0);
|
||||
info->channels = SPA_MIN(info->channels, SPA_AUDIO_MAX_CHANNELS);
|
||||
if ((str = pw_properties_get(props, SPA_KEY_AUDIO_POSITION)) != NULL)
|
||||
spa_audio_parse_position(str, strlen(str), info->position, &info->channels);
|
||||
spa_audio_info_raw_init_dict_keys(info,
|
||||
&SPA_DICT_ITEMS(
|
||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, "F32P")),
|
||||
&props->dict,
|
||||
SPA_KEY_AUDIO_RATE,
|
||||
SPA_KEY_AUDIO_CHANNELS,
|
||||
SPA_KEY_AUDIO_POSITION, NULL);
|
||||
}
|
||||
|
||||
static void copy_props(struct impl *impl, struct pw_properties *props, const char *key)
|
||||
|
|
|
|||
|
|
@ -1149,18 +1149,13 @@ static const struct pw_impl_module_events module_events = {
|
|||
|
||||
static void parse_audio_info(const struct pw_properties *props, struct spa_audio_info_raw *info)
|
||||
{
|
||||
const char *str;
|
||||
|
||||
spa_zero(*info);
|
||||
info->format = SPA_AUDIO_FORMAT_F32P;
|
||||
info->rate = 0;
|
||||
info->channels = pw_properties_get_uint32(props, PW_KEY_AUDIO_CHANNELS, info->channels);
|
||||
info->channels = SPA_MIN(info->channels, SPA_AUDIO_MAX_CHANNELS);
|
||||
if ((str = pw_properties_get(props, SPA_KEY_AUDIO_POSITION)) != NULL)
|
||||
spa_audio_parse_position(str, strlen(str), info->position, &info->channels);
|
||||
if (info->channels == 0)
|
||||
spa_audio_parse_position(DEFAULT_POSITION, strlen(DEFAULT_POSITION),
|
||||
info->position, &info->channels);
|
||||
spa_audio_info_raw_init_dict_keys(info,
|
||||
&SPA_DICT_ITEMS(
|
||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, "F32P"),
|
||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_POSITION, DEFAULT_POSITION)),
|
||||
&props->dict,
|
||||
SPA_KEY_AUDIO_CHANNELS,
|
||||
SPA_KEY_AUDIO_POSITION, NULL);
|
||||
}
|
||||
|
||||
static void copy_props(struct impl *impl, struct pw_properties *props, const char *key)
|
||||
|
|
|
|||
|
|
@ -1175,18 +1175,13 @@ static const struct pw_impl_module_events module_events = {
|
|||
|
||||
static void parse_audio_info(const struct pw_properties *props, struct spa_audio_info_raw *info)
|
||||
{
|
||||
const char *str;
|
||||
|
||||
spa_zero(*info);
|
||||
info->format = SPA_AUDIO_FORMAT_F32P;
|
||||
info->rate = 0;
|
||||
info->channels = pw_properties_get_uint32(props, PW_KEY_AUDIO_CHANNELS, info->channels);
|
||||
info->channels = SPA_MIN(info->channels, SPA_AUDIO_MAX_CHANNELS);
|
||||
if ((str = pw_properties_get(props, SPA_KEY_AUDIO_POSITION)) != NULL)
|
||||
spa_audio_parse_position(str, strlen(str), info->position, &info->channels);
|
||||
if (info->channels == 0)
|
||||
spa_audio_parse_position(DEFAULT_POSITION, strlen(DEFAULT_POSITION),
|
||||
info->position, &info->channels);
|
||||
spa_audio_info_raw_init_dict_keys(info,
|
||||
&SPA_DICT_ITEMS(
|
||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, "F32P"),
|
||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_POSITION, DEFAULT_POSITION)),
|
||||
&props->dict,
|
||||
SPA_KEY_AUDIO_CHANNELS,
|
||||
SPA_KEY_AUDIO_POSITION, NULL);
|
||||
}
|
||||
|
||||
static void copy_props(struct impl *impl, struct pw_properties *props, const char *key)
|
||||
|
|
|
|||
|
|
@ -124,7 +124,6 @@
|
|||
|
||||
#define DEFAULT_FORMAT "S16"
|
||||
#define DEFAULT_RATE 48000
|
||||
#define DEFAULT_CHANNELS 2
|
||||
#define DEFAULT_POSITION "[ FL FR ]"
|
||||
|
||||
#define RINGBUFFER_SIZE (1u << 22)
|
||||
|
|
@ -757,24 +756,16 @@ static const struct pw_impl_module_events module_events = {
|
|||
|
||||
static void parse_audio_info(const struct pw_properties *props, struct spa_audio_info_raw *info)
|
||||
{
|
||||
const char *str;
|
||||
|
||||
spa_zero(*info);
|
||||
if ((str = pw_properties_get(props, PW_KEY_AUDIO_FORMAT)) == NULL)
|
||||
str = DEFAULT_FORMAT;
|
||||
info->format = spa_type_audio_format_from_short_name(str);
|
||||
|
||||
info->rate = pw_properties_get_uint32(props, PW_KEY_AUDIO_RATE, info->rate);
|
||||
if (info->rate == 0)
|
||||
info->rate = DEFAULT_RATE;
|
||||
|
||||
info->channels = pw_properties_get_uint32(props, PW_KEY_AUDIO_CHANNELS, info->channels);
|
||||
info->channels = SPA_MIN(info->channels, SPA_AUDIO_MAX_CHANNELS);
|
||||
if ((str = pw_properties_get(props, SPA_KEY_AUDIO_POSITION)) != NULL)
|
||||
spa_audio_parse_position(str, strlen(str), info->position, &info->channels);
|
||||
if (info->channels == 0)
|
||||
spa_audio_parse_position(DEFAULT_POSITION, strlen(DEFAULT_POSITION),
|
||||
info->position, &info->channels);
|
||||
spa_audio_info_raw_init_dict_keys(info,
|
||||
&SPA_DICT_ITEMS(
|
||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, DEFAULT_FORMAT),
|
||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_RATE, SPA_STRINGIFY(DEFAULT_RATE)),
|
||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_POSITION, DEFAULT_POSITION)),
|
||||
&props->dict,
|
||||
SPA_KEY_AUDIO_FORMAT,
|
||||
SPA_KEY_AUDIO_RATE,
|
||||
SPA_KEY_AUDIO_CHANNELS,
|
||||
SPA_KEY_AUDIO_POSITION, NULL);
|
||||
}
|
||||
|
||||
static int calc_frame_size(const struct spa_audio_info_raw *info)
|
||||
|
|
|
|||
|
|
@ -822,24 +822,16 @@ static int calc_frame_size(struct spa_audio_info_raw *info)
|
|||
|
||||
static int parse_audio_info(const struct pw_properties *props, struct spa_audio_info_raw *info)
|
||||
{
|
||||
const char *str;
|
||||
|
||||
spa_zero(*info);
|
||||
if ((str = pw_properties_get(props, PW_KEY_AUDIO_FORMAT)) == NULL)
|
||||
str = DEFAULT_FORMAT;
|
||||
info->format = spa_type_audio_format_from_short_name(str);
|
||||
|
||||
info->rate = pw_properties_get_uint32(props, PW_KEY_AUDIO_RATE, info->rate);
|
||||
if (info->rate == 0)
|
||||
info->rate = DEFAULT_RATE;
|
||||
|
||||
info->channels = pw_properties_get_uint32(props, PW_KEY_AUDIO_CHANNELS, info->channels);
|
||||
info->channels = SPA_MIN(info->channels, SPA_AUDIO_MAX_CHANNELS);
|
||||
if ((str = pw_properties_get(props, SPA_KEY_AUDIO_POSITION)) != NULL)
|
||||
spa_audio_parse_position(str, strlen(str), info->position, &info->channels);
|
||||
if (info->channels == 0)
|
||||
spa_audio_parse_position(DEFAULT_POSITION, strlen(DEFAULT_POSITION),
|
||||
info->position, &info->channels);
|
||||
spa_audio_info_raw_init_dict_keys(info,
|
||||
&SPA_DICT_ITEMS(
|
||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, DEFAULT_FORMAT),
|
||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_RATE, SPA_STRINGIFY(DEFAULT_RATE)),
|
||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_POSITION, DEFAULT_POSITION)),
|
||||
&props->dict,
|
||||
SPA_KEY_AUDIO_FORMAT,
|
||||
SPA_KEY_AUDIO_RATE,
|
||||
SPA_KEY_AUDIO_CHANNELS,
|
||||
SPA_KEY_AUDIO_POSITION, NULL);
|
||||
|
||||
return calc_frame_size(info);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1067,24 +1067,16 @@ static const struct pw_impl_module_events module_events = {
|
|||
|
||||
static void parse_audio_info(const struct pw_properties *props, struct spa_audio_info_raw *info)
|
||||
{
|
||||
const char *str;
|
||||
|
||||
spa_zero(*info);
|
||||
if ((str = pw_properties_get(props, PW_KEY_AUDIO_FORMAT)) == NULL)
|
||||
str = DEFAULT_FORMAT;
|
||||
info->format = spa_type_audio_format_from_short_name(str);
|
||||
|
||||
info->rate = pw_properties_get_uint32(props, PW_KEY_AUDIO_RATE, info->rate);
|
||||
if (info->rate == 0)
|
||||
info->rate = DEFAULT_RATE;
|
||||
|
||||
info->channels = pw_properties_get_uint32(props, PW_KEY_AUDIO_CHANNELS, info->channels);
|
||||
info->channels = SPA_MIN(info->channels, SPA_AUDIO_MAX_CHANNELS);
|
||||
if ((str = pw_properties_get(props, SPA_KEY_AUDIO_POSITION)) != NULL)
|
||||
spa_audio_parse_position(str, strlen(str), info->position, &info->channels);
|
||||
if (info->channels == 0)
|
||||
spa_audio_parse_position(DEFAULT_POSITION, strlen(DEFAULT_POSITION),
|
||||
info->position, &info->channels);
|
||||
spa_audio_info_raw_init_dict_keys(info,
|
||||
&SPA_DICT_ITEMS(
|
||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, DEFAULT_FORMAT),
|
||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_RATE, SPA_STRINGIFY(DEFAULT_RATE)),
|
||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_POSITION, DEFAULT_POSITION)),
|
||||
&props->dict,
|
||||
SPA_KEY_AUDIO_FORMAT,
|
||||
SPA_KEY_AUDIO_RATE,
|
||||
SPA_KEY_AUDIO_CHANNELS,
|
||||
SPA_KEY_AUDIO_POSITION, NULL);
|
||||
}
|
||||
|
||||
static int calc_frame_size(struct spa_audio_info_raw *info)
|
||||
|
|
|
|||
|
|
@ -272,24 +272,16 @@ static const struct format_info *find_audio_format_info(const struct spa_audio_i
|
|||
|
||||
static void parse_audio_info(const struct pw_properties *props, struct spa_audio_info_raw *info)
|
||||
{
|
||||
const char *str;
|
||||
|
||||
spa_zero(*info);
|
||||
if ((str = pw_properties_get(props, PW_KEY_AUDIO_FORMAT)) == NULL)
|
||||
str = DEFAULT_FORMAT;
|
||||
info->format = spa_type_audio_format_from_short_name(str);
|
||||
|
||||
info->rate = pw_properties_get_uint32(props, PW_KEY_AUDIO_RATE, info->rate);
|
||||
if (info->rate == 0)
|
||||
info->rate = DEFAULT_RATE;
|
||||
|
||||
info->channels = pw_properties_get_uint32(props, PW_KEY_AUDIO_CHANNELS, info->channels);
|
||||
info->channels = SPA_MIN(info->channels, SPA_AUDIO_MAX_CHANNELS);
|
||||
if ((str = pw_properties_get(props, SPA_KEY_AUDIO_POSITION)) != NULL)
|
||||
spa_audio_parse_position(str, strlen(str), info->position, &info->channels);
|
||||
if (info->channels == 0)
|
||||
spa_audio_parse_position(DEFAULT_POSITION, strlen(DEFAULT_POSITION),
|
||||
info->position, &info->channels);
|
||||
spa_audio_info_raw_init_dict_keys(info,
|
||||
&SPA_DICT_ITEMS(
|
||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, DEFAULT_FORMAT),
|
||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_RATE, SPA_STRINGIFY(DEFAULT_RATE)),
|
||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_POSITION, DEFAULT_POSITION)),
|
||||
&props->dict,
|
||||
SPA_KEY_AUDIO_FORMAT,
|
||||
SPA_KEY_AUDIO_RATE,
|
||||
SPA_KEY_AUDIO_CHANNELS,
|
||||
SPA_KEY_AUDIO_POSITION, NULL);
|
||||
}
|
||||
|
||||
static uint32_t msec_to_samples(struct impl *impl, float msec)
|
||||
|
|
|
|||
|
|
@ -505,30 +505,20 @@ static int add_snapcast_stream(struct impl *impl, struct tunnel *t,
|
|||
|
||||
static void parse_audio_info(struct pw_properties *props, struct spa_audio_info_raw *info)
|
||||
{
|
||||
const char *str;
|
||||
spa_audio_info_raw_init_dict_keys(info,
|
||||
&SPA_DICT_ITEMS(
|
||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, DEFAULT_FORMAT),
|
||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_RATE, SPA_STRINGIFY(DEFAULT_RATE)),
|
||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_POSITION, DEFAULT_POSITION)),
|
||||
&props->dict,
|
||||
SPA_KEY_AUDIO_FORMAT,
|
||||
SPA_KEY_AUDIO_RATE,
|
||||
SPA_KEY_AUDIO_CHANNELS,
|
||||
SPA_KEY_AUDIO_POSITION, NULL);
|
||||
|
||||
spa_zero(*info);
|
||||
if ((str = pw_properties_get(props, PW_KEY_AUDIO_FORMAT)) == NULL)
|
||||
str = DEFAULT_FORMAT;
|
||||
info->format = spa_type_audio_format_from_short_name(str);
|
||||
if (info->format == 0) {
|
||||
str = DEFAULT_FORMAT;
|
||||
info->format = spa_type_audio_format_from_short_name(str);
|
||||
}
|
||||
pw_properties_set(props, PW_KEY_AUDIO_FORMAT, str);
|
||||
|
||||
info->rate = pw_properties_get_uint32(props, PW_KEY_AUDIO_RATE, info->rate);
|
||||
if (info->rate == 0)
|
||||
info->rate = DEFAULT_RATE;
|
||||
pw_properties_set(props, PW_KEY_AUDIO_FORMAT,
|
||||
spa_type_audio_format_to_short_name(info->format));
|
||||
pw_properties_setf(props, PW_KEY_AUDIO_RATE, "%d", info->rate);
|
||||
|
||||
info->channels = pw_properties_get_uint32(props, PW_KEY_AUDIO_CHANNELS, info->channels);
|
||||
info->channels = SPA_MIN(info->channels, SPA_AUDIO_MAX_CHANNELS);
|
||||
if ((str = pw_properties_get(props, SPA_KEY_AUDIO_POSITION)) != NULL)
|
||||
spa_audio_parse_position(str, strlen(str), info->position, &info->channels);
|
||||
if (info->channels == 0)
|
||||
spa_audio_parse_position(DEFAULT_POSITION, strlen(DEFAULT_POSITION),
|
||||
info->position, &info->channels);
|
||||
pw_properties_setf(props, PW_KEY_AUDIO_CHANNELS, "%d", info->channels);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -190,24 +190,16 @@ static const struct format_info *find_audio_format_info(const struct spa_audio_i
|
|||
|
||||
static void parse_audio_info(const struct pw_properties *props, struct spa_audio_info_raw *info)
|
||||
{
|
||||
const char *str;
|
||||
|
||||
spa_zero(*info);
|
||||
if ((str = pw_properties_get(props, PW_KEY_AUDIO_FORMAT)) == NULL)
|
||||
str = DEFAULT_FORMAT;
|
||||
info->format = spa_type_audio_format_from_short_name(str);
|
||||
|
||||
info->rate = pw_properties_get_uint32(props, PW_KEY_AUDIO_RATE, info->rate);
|
||||
if (info->rate == 0)
|
||||
info->rate = DEFAULT_RATE;
|
||||
|
||||
info->channels = pw_properties_get_uint32(props, PW_KEY_AUDIO_CHANNELS, info->channels);
|
||||
info->channels = SPA_MIN(info->channels, SPA_AUDIO_MAX_CHANNELS);
|
||||
if ((str = pw_properties_get(props, SPA_KEY_AUDIO_POSITION)) != NULL)
|
||||
spa_audio_parse_position(str, strlen(str), info->position, &info->channels);
|
||||
if (info->channels == 0)
|
||||
spa_audio_parse_position(DEFAULT_POSITION, strlen(DEFAULT_POSITION),
|
||||
info->position, &info->channels);
|
||||
spa_audio_info_raw_init_dict_keys(info,
|
||||
&SPA_DICT_ITEMS(
|
||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, DEFAULT_FORMAT),
|
||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_RATE, SPA_STRINGIFY(DEFAULT_RATE)),
|
||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_POSITION, DEFAULT_POSITION)),
|
||||
&props->dict,
|
||||
SPA_KEY_AUDIO_FORMAT,
|
||||
SPA_KEY_AUDIO_RATE,
|
||||
SPA_KEY_AUDIO_CHANNELS,
|
||||
SPA_KEY_AUDIO_POSITION, NULL);
|
||||
}
|
||||
|
||||
static uint32_t msec_to_samples(struct impl *impl, uint32_t msec)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue