mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
modules: improve parsing of rate and channels
This commit is contained in:
parent
f2c53622d2
commit
a84412ccb7
6 changed files with 21 additions and 31 deletions
|
|
@ -99,15 +99,15 @@ PW_LOG_TOPIC_STATIC(mod_topic, "mod." NAME);
|
|||
|
||||
#define DEFAULT_FORMAT "S16"
|
||||
#define DEFAULT_RATE 48000
|
||||
#define DEFAULT_CHANNELS "2"
|
||||
#define DEFAULT_CHANNELS 2
|
||||
#define DEFAULT_POSITION "[ FL FR ]"
|
||||
|
||||
#define MODULE_USAGE "[ node.latency=<latency as fraction> ] " \
|
||||
"[ node.name=<name of the nodes> ] " \
|
||||
"[ node.description=<description of the nodes> ] " \
|
||||
"[ audio.format=<format, default:"DEFAULT_FORMAT"> ] " \
|
||||
"[ audio.rate=<sample rate, default: 48000> ] " \
|
||||
"[ audio.channels=<number of channels, default:"DEFAULT_CHANNELS"> ] " \
|
||||
"[ audio.rate=<sample rate, default: "SPA_STRINGIFY(DEFAULT_RATE)"> ] " \
|
||||
"[ audio.channels=<number of channels, default:"SPA_STRINGIFY(EFAULT_CHANNELS) "> ] " \
|
||||
"[ audio.position=<channel map, default:"DEFAULT_POSITION"> ] " \
|
||||
"[ stream.props=<properties> ] "
|
||||
|
||||
|
|
@ -379,9 +379,7 @@ static int parse_audio_info(struct impl *impl)
|
|||
pw_log_error("invalid rate '%s'", str);
|
||||
return -EINVAL;
|
||||
}
|
||||
if ((str = pw_properties_get(props, PW_KEY_AUDIO_CHANNELS)) == NULL)
|
||||
str = DEFAULT_CHANNELS;
|
||||
info->channels = atoi(str);
|
||||
info->channels = pw_properties_get_uint32(props, PW_KEY_AUDIO_CHANNELS, DEFAULT_CHANNELS);
|
||||
if ((str = pw_properties_get(props, SPA_KEY_AUDIO_POSITION)) == NULL)
|
||||
str = DEFAULT_POSITION;
|
||||
parse_position(info, str, strlen(str));
|
||||
|
|
|
|||
|
|
@ -99,15 +99,15 @@ PW_LOG_TOPIC_STATIC(mod_topic, "mod." NAME);
|
|||
|
||||
#define DEFAULT_FORMAT "S16"
|
||||
#define DEFAULT_RATE 48000
|
||||
#define DEFAULT_CHANNELS "2"
|
||||
#define DEFAULT_CHANNELS 2
|
||||
#define DEFAULT_POSITION "[ FL FR ]"
|
||||
|
||||
#define MODULE_USAGE "[ node.latency=<latency as fraction> ] " \
|
||||
"[ node.name=<name of the nodes> ] " \
|
||||
"[ node.description=<description of the nodes> ] " \
|
||||
"[ audio.format=<format, default:"DEFAULT_FORMAT"> ] " \
|
||||
"[ audio.rate=<sample rate, default: 48000> ] " \
|
||||
"[ audio.channels=<number of channels, default:"DEFAULT_CHANNELS"> ] " \
|
||||
"[ audio.rate=<sample rate, default: "SPA_STRINGIFY(DEFAULT_RATE)"> ] " \
|
||||
"[ audio.channels=<number of channels, default:"SPA_STRINGIFY(EFAULT_CHANNELS) "> ] " \
|
||||
"[ audio.position=<channel map, default:"DEFAULT_POSITION"> ] " \
|
||||
"[ stream.props=<properties> ] "
|
||||
|
||||
|
|
@ -383,9 +383,7 @@ static int parse_audio_info(struct impl *impl)
|
|||
pw_log_error("invalid rate '%s'", str);
|
||||
return -EINVAL;
|
||||
}
|
||||
if ((str = pw_properties_get(props, PW_KEY_AUDIO_CHANNELS)) == NULL)
|
||||
str = DEFAULT_CHANNELS;
|
||||
info->channels = atoi(str);
|
||||
info->channels = pw_properties_get_uint32(props, PW_KEY_AUDIO_CHANNELS, DEFAULT_CHANNELS);
|
||||
if ((str = pw_properties_get(props, SPA_KEY_AUDIO_POSITION)) == NULL)
|
||||
str = DEFAULT_POSITION;
|
||||
parse_position(info, str, strlen(str));
|
||||
|
|
|
|||
|
|
@ -2083,10 +2083,8 @@ static void parse_audio_info(struct pw_properties *props, struct spa_audio_info_
|
|||
|
||||
*info = SPA_AUDIO_INFO_RAW_INIT(
|
||||
.format = SPA_AUDIO_FORMAT_F32P);
|
||||
if ((str = pw_properties_get(props, PW_KEY_AUDIO_RATE)) != NULL)
|
||||
info->rate = atoi(str);
|
||||
if ((str = pw_properties_get(props, PW_KEY_AUDIO_CHANNELS)) != NULL)
|
||||
info->channels = atoi(str);
|
||||
info->rate = pw_properties_get_int32(props, PW_KEY_AUDIO_RATE, 0);
|
||||
info->channels = pw_properties_get_int32(props, PW_KEY_AUDIO_CHANNELS, 0);
|
||||
if ((str = pw_properties_get(props, SPA_KEY_AUDIO_POSITION)) != NULL)
|
||||
parse_position(info, str, strlen(str));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ PW_LOG_TOPIC_STATIC(mod_topic, "mod." NAME);
|
|||
#define DEFAULT_SERVER "[ \"tcp:"SPA_STRINGIFY(DEFAULT_PORT)"\" ]"
|
||||
|
||||
#define DEFAULT_FORMAT "S16"
|
||||
#define DEFAULT_RATE "44100"
|
||||
#define DEFAULT_RATE 44100
|
||||
#define DEFAULT_CHANNELS 2
|
||||
#define DEFAULT_POSITION "[ FL FR ]"
|
||||
#define DEFAULT_LATENCY "1024/44100"
|
||||
|
|
@ -143,12 +143,12 @@ PW_LOG_TOPIC_STATIC(mod_topic, "mod." NAME);
|
|||
"[ playback=<bool> ] " \
|
||||
"[ remote.name=<remote> ] " \
|
||||
"[ node.latency=<num/denom, default:"DEFAULT_LATENCY"> ] " \
|
||||
"[ node.rate=<1/rate, default:1/"DEFAULT_RATE"> ] " \
|
||||
"[ node.rate=<1/rate, default:1/"SPA_STRINGIFY(DEFAULT_RATE)"> ] " \
|
||||
"[ capture.node=<source-target> [ stream.capture.sink=true ]] " \
|
||||
"[ playback.node=<sink-target> ] " \
|
||||
"[ audio.rate=<sample-rate, default:"DEFAULT_RATE"> ] " \
|
||||
"[ audio.rate=<sample-rate, default:"SPA_STRINGIFY(DEFAULT_RATE)"> ] " \
|
||||
"[ audio.format=<format, default:"DEFAULT_FORMAT"> ] " \
|
||||
"[ audio.channels=<channels, default: 2> ] " \
|
||||
"[ audio.channels=<channels, default: "SPA_STRINGIFY(DEFAULT_CHANNELS)"> ] " \
|
||||
"[ audio.position=<position, default:"DEFAULT_POSITION"> ] " \
|
||||
"[ server.address=<[ tcp:[<ip>:]<port>[,...] ], default:"DEFAULT_SERVER">" \
|
||||
|
||||
|
|
@ -804,9 +804,7 @@ static int parse_params(struct impl *impl)
|
|||
pw_log_error("invalid format '%s'", str);
|
||||
return -EINVAL;
|
||||
}
|
||||
if ((str = pw_properties_get(impl->props, "audio.rate")) == NULL)
|
||||
str = DEFAULT_RATE;
|
||||
impl->info.rate = atoi(str);
|
||||
impl->info.rate = pw_properties_get_uint32(impl->props, "audio.rate", DEFAULT_RATE);
|
||||
if (impl->info.rate == 0) {
|
||||
pw_log_error("invalid rate '%s'", str);
|
||||
return -EINVAL;
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ PW_LOG_TOPIC_STATIC(mod_topic, "mod." NAME);
|
|||
|
||||
#define DEFAULT_FORMAT "S16"
|
||||
#define DEFAULT_RATE 44100
|
||||
#define DEFAULT_CHANNELS "2"
|
||||
#define DEFAULT_CHANNELS 2
|
||||
#define DEFAULT_POSITION "[ FL FR ]"
|
||||
|
||||
#define DEFAULT_LATENCY (DEFAULT_RATE*2)
|
||||
|
|
@ -110,8 +110,8 @@ PW_LOG_TOPIC_STATIC(mod_topic, "mod." NAME);
|
|||
"[ node.name=<name of the nodes> ] " \
|
||||
"[ node.description=<description of the nodes> ] " \
|
||||
"[ audio.format=<format, default:"DEFAULT_FORMAT"> ] " \
|
||||
"[ audio.rate=<sample rate, default: 48000> ] " \
|
||||
"[ audio.channels=<number of channels, default:"DEFAULT_CHANNELS"> ] " \
|
||||
"[ audio.rate=<sample rate, default: "SPA_STRINGIFY(DEFAuLT_RATE)"> ] " \
|
||||
"[ audio.channels=<number of channels, default:"SPA_STRINGIFY(DEFAULT_CHANNELS)"> ] " \
|
||||
"[ audio.position=<channel map, default:"DEFAULT_POSITION"> ] " \
|
||||
"[ stream.props=<properties> ] "
|
||||
|
||||
|
|
@ -1523,9 +1523,7 @@ static int parse_audio_info(struct impl *impl)
|
|||
pw_log_error("invalid rate '%s'", str);
|
||||
return -EINVAL;
|
||||
}
|
||||
if ((str = pw_properties_get(props, PW_KEY_AUDIO_CHANNELS)) == NULL)
|
||||
str = DEFAULT_CHANNELS;
|
||||
info->channels = atoi(str);
|
||||
info->channels = pw_properties_get_uint32(props, PW_KEY_AUDIO_CHANNELS, DEFAULT_CHANNELS);
|
||||
if ((str = pw_properties_get(props, SPA_KEY_AUDIO_POSITION)) == NULL)
|
||||
str = DEFAULT_POSITION;
|
||||
parse_position(info, str, strlen(str));
|
||||
|
|
|
|||
|
|
@ -195,10 +195,10 @@ static void pw_properties_from_avahi_string(const char *key, const char *value,
|
|||
pw_properties_set(props, PW_KEY_NODE_TARGET, value);
|
||||
}
|
||||
else if (spa_streq(key, "rate")) {
|
||||
pw_properties_setf(props, PW_KEY_AUDIO_RATE, "%u", atoi(value));
|
||||
pw_properties_set(props, PW_KEY_AUDIO_RATE, value);
|
||||
}
|
||||
else if (spa_streq(key, "channels")) {
|
||||
pw_properties_setf(props, PW_KEY_AUDIO_CHANNELS, "%u", atoi(value));
|
||||
pw_properties_set(props, PW_KEY_AUDIO_CHANNELS, value);
|
||||
}
|
||||
else if (spa_streq(key, "channel_map")) {
|
||||
struct channel_map channel_map;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue