mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
modules: handle format parsing errors
This commit is contained in:
parent
b8eeb2db45
commit
5e1e3fca1e
17 changed files with 125 additions and 66 deletions
|
|
@ -326,9 +326,9 @@ struct stream {
|
||||||
unsigned int have_latency:1;
|
unsigned int have_latency:1;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void parse_audio_info(const struct pw_properties *props, struct spa_audio_info_raw *info)
|
static int parse_audio_info(const struct pw_properties *props, struct spa_audio_info_raw *info)
|
||||||
{
|
{
|
||||||
spa_audio_info_raw_init_dict_keys(info,
|
return spa_audio_info_raw_init_dict_keys(info,
|
||||||
&SPA_DICT_ITEMS(
|
&SPA_DICT_ITEMS(
|
||||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, "F32P"),
|
SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, "F32P"),
|
||||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_POSITION, DEFAULT_POSITION)),
|
SPA_DICT_ITEM(SPA_KEY_AUDIO_POSITION, DEFAULT_POSITION)),
|
||||||
|
|
@ -1638,7 +1638,10 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
||||||
copy_props(props, impl->combine_props, "resample.prefill");
|
copy_props(props, impl->combine_props, "resample.prefill");
|
||||||
copy_props(props, impl->combine_props, "resample.disable");
|
copy_props(props, impl->combine_props, "resample.disable");
|
||||||
|
|
||||||
parse_audio_info(impl->combine_props, &impl->info);
|
if ((res = parse_audio_info(impl->combine_props, &impl->info)) < 0) {
|
||||||
|
pw_log_error( "can't create format: %s", spa_strerror(res));
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
copy_props(props, impl->stream_props, PW_KEY_NODE_LOOP_NAME);
|
copy_props(props, impl->stream_props, PW_KEY_NODE_LOOP_NAME);
|
||||||
copy_props(props, impl->stream_props, PW_KEY_NODE_GROUP);
|
copy_props(props, impl->stream_props, PW_KEY_NODE_GROUP);
|
||||||
|
|
|
||||||
|
|
@ -1203,9 +1203,9 @@ static const struct pw_impl_module_events module_events = {
|
||||||
.destroy = module_destroy,
|
.destroy = module_destroy,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void parse_audio_info(struct pw_properties *props, struct spa_audio_info_raw *info)
|
static int parse_audio_info(struct pw_properties *props, struct spa_audio_info_raw *info)
|
||||||
{
|
{
|
||||||
spa_audio_info_raw_init_dict_keys(info,
|
return spa_audio_info_raw_init_dict_keys(info,
|
||||||
&SPA_DICT_ITEMS(
|
&SPA_DICT_ITEMS(
|
||||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, "F32P"),
|
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_RATE, SPA_STRINGIFY(DEFAULT_RATE)),
|
||||||
|
|
@ -1291,7 +1291,10 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
||||||
if (pw_properties_get(props, "resample.prefill") == NULL)
|
if (pw_properties_get(props, "resample.prefill") == NULL)
|
||||||
pw_properties_set(props, "resample.prefill", "true");
|
pw_properties_set(props, "resample.prefill", "true");
|
||||||
|
|
||||||
parse_audio_info(props, &info);
|
if ((res = parse_audio_info(props, &info)) < 0) {
|
||||||
|
pw_log_error( "can't parse format: %s", spa_strerror(res));
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
impl->capture_info = info;
|
impl->capture_info = info;
|
||||||
impl->source_info = info;
|
impl->source_info = info;
|
||||||
|
|
|
||||||
|
|
@ -467,9 +467,9 @@ static const struct pw_impl_module_events module_events = {
|
||||||
.destroy = module_destroy,
|
.destroy = module_destroy,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void parse_audio_info(struct pw_properties *props, struct spa_audio_info_raw *info)
|
static int parse_audio_info(struct pw_properties *props, struct spa_audio_info_raw *info)
|
||||||
{
|
{
|
||||||
spa_audio_info_raw_init_dict_keys(info,
|
return spa_audio_info_raw_init_dict_keys(info,
|
||||||
&SPA_DICT_ITEMS(
|
&SPA_DICT_ITEMS(
|
||||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, "F32P"),
|
SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, "F32P"),
|
||||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_POSITION, DEFAULT_POSITION)),
|
SPA_DICT_ITEM(SPA_KEY_AUDIO_POSITION, DEFAULT_POSITION)),
|
||||||
|
|
@ -573,8 +573,11 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
||||||
if (pw_properties_get(impl->playback_props, PW_KEY_NODE_DESCRIPTION) == NULL)
|
if (pw_properties_get(impl->playback_props, PW_KEY_NODE_DESCRIPTION) == NULL)
|
||||||
pw_properties_set(impl->playback_props, PW_KEY_NODE_DESCRIPTION, str);
|
pw_properties_set(impl->playback_props, PW_KEY_NODE_DESCRIPTION, str);
|
||||||
|
|
||||||
parse_audio_info(impl->capture_props, &impl->capture_info);
|
if ((res = parse_audio_info(impl->capture_props, &impl->capture_info)) < 0 ||
|
||||||
parse_audio_info(impl->playback_props, &impl->playback_info);
|
(res = parse_audio_info(impl->playback_props, &impl->playback_info)) < 0) {
|
||||||
|
pw_log_error( "can't parse formats: %s", spa_strerror(res));
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
if (!impl->capture_info.rate && !impl->playback_info.rate) {
|
if (!impl->capture_info.rate && !impl->playback_info.rate) {
|
||||||
if (pw_properties_get(impl->playback_props, "resample.disable") == NULL)
|
if (pw_properties_get(impl->playback_props, "resample.disable") == NULL)
|
||||||
|
|
|
||||||
|
|
@ -273,9 +273,9 @@ static const struct pw_impl_module_events module_events = {
|
||||||
.destroy = module_destroy,
|
.destroy = module_destroy,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void parse_audio_info(const struct pw_properties *props, struct spa_audio_info_raw *info)
|
static int parse_audio_info(const struct pw_properties *props, struct spa_audio_info_raw *info)
|
||||||
{
|
{
|
||||||
spa_audio_info_raw_init_dict_keys(info,
|
return spa_audio_info_raw_init_dict_keys(info,
|
||||||
&SPA_DICT_ITEMS(
|
&SPA_DICT_ITEMS(
|
||||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, DEFAULT_FORMAT),
|
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_RATE, SPA_STRINGIFY(DEFAULT_RATE)),
|
||||||
|
|
@ -395,7 +395,10 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
||||||
copy_props(impl, props, PW_KEY_NODE_VIRTUAL);
|
copy_props(impl, props, PW_KEY_NODE_VIRTUAL);
|
||||||
copy_props(impl, props, PW_KEY_MEDIA_CLASS);
|
copy_props(impl, props, PW_KEY_MEDIA_CLASS);
|
||||||
|
|
||||||
parse_audio_info(impl->stream_props, &impl->info);
|
if ((res = parse_audio_info(impl->stream_props, &impl->info)) < 0) {
|
||||||
|
pw_log_error( "can't parse format: %s", spa_strerror(res));
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
impl->frame_size = calc_frame_size(&impl->info);
|
impl->frame_size = calc_frame_size(&impl->info);
|
||||||
if (impl->frame_size == 0) {
|
if (impl->frame_size == 0) {
|
||||||
|
|
|
||||||
|
|
@ -279,9 +279,9 @@ static const struct pw_impl_module_events module_events = {
|
||||||
.destroy = module_destroy,
|
.destroy = module_destroy,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void parse_audio_info(const struct pw_properties *props, struct spa_audio_info_raw *info)
|
static int parse_audio_info(const struct pw_properties *props, struct spa_audio_info_raw *info)
|
||||||
{
|
{
|
||||||
spa_audio_info_raw_init_dict_keys(info,
|
return spa_audio_info_raw_init_dict_keys(info,
|
||||||
&SPA_DICT_ITEMS(
|
&SPA_DICT_ITEMS(
|
||||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, DEFAULT_FORMAT),
|
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_RATE, SPA_STRINGIFY(DEFAULT_RATE)),
|
||||||
|
|
@ -401,7 +401,10 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
||||||
copy_props(impl, props, PW_KEY_NODE_VIRTUAL);
|
copy_props(impl, props, PW_KEY_NODE_VIRTUAL);
|
||||||
copy_props(impl, props, PW_KEY_MEDIA_CLASS);
|
copy_props(impl, props, PW_KEY_MEDIA_CLASS);
|
||||||
|
|
||||||
parse_audio_info(impl->stream_props, &impl->info);
|
if ((res = parse_audio_info(impl->stream_props, &impl->info)) < 0) {
|
||||||
|
pw_log_error( "can't parse format: %s", spa_strerror(res));
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
impl->frame_size = calc_frame_size(&impl->info);
|
impl->frame_size = calc_frame_size(&impl->info);
|
||||||
if (impl->frame_size == 0) {
|
if (impl->frame_size == 0) {
|
||||||
|
|
|
||||||
|
|
@ -1429,9 +1429,9 @@ 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)
|
static int parse_audio_info(const struct pw_properties *props, struct spa_audio_info_raw *info)
|
||||||
{
|
{
|
||||||
spa_audio_info_raw_init_dict_keys(info,
|
return spa_audio_info_raw_init_dict_keys(info,
|
||||||
&SPA_DICT_ITEMS(
|
&SPA_DICT_ITEMS(
|
||||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, "F32P"),
|
SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, "F32P"),
|
||||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_POSITION, DEFAULT_POSITION)),
|
SPA_DICT_ITEM(SPA_KEY_AUDIO_POSITION, DEFAULT_POSITION)),
|
||||||
|
|
@ -1582,8 +1582,11 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
||||||
copy_props(impl, props, PW_KEY_NODE_VIRTUAL);
|
copy_props(impl, props, PW_KEY_NODE_VIRTUAL);
|
||||||
copy_props(impl, props, PW_KEY_NODE_PAUSE_ON_IDLE);
|
copy_props(impl, props, PW_KEY_NODE_PAUSE_ON_IDLE);
|
||||||
|
|
||||||
parse_audio_info(impl->source.props, &impl->source.info);
|
if ((res = parse_audio_info(impl->source.props, &impl->source.info)) < 0 ||
|
||||||
parse_audio_info(impl->sink.props, &impl->sink.info);
|
(res = parse_audio_info(impl->sink.props, &impl->sink.info)) < 0) {
|
||||||
|
pw_log_error( "can't parse format: %s", spa_strerror(res));
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
impl->core = pw_context_get_object(impl->context, PW_TYPE_INTERFACE_Core);
|
impl->core = pw_context_get_object(impl->context, PW_TYPE_INTERFACE_Core);
|
||||||
if (impl->core == NULL) {
|
if (impl->core == NULL) {
|
||||||
|
|
|
||||||
|
|
@ -1833,9 +1833,9 @@ static const struct pw_impl_module_events module_events = {
|
||||||
.destroy = module_destroy,
|
.destroy = module_destroy,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void parse_audio_info(struct pw_properties *props, struct spa_audio_info_raw *info)
|
static int parse_audio_info(struct pw_properties *props, struct spa_audio_info_raw *info)
|
||||||
{
|
{
|
||||||
spa_audio_info_raw_init_dict_keys(info,
|
return spa_audio_info_raw_init_dict_keys(info,
|
||||||
&SPA_DICT_ITEMS(
|
&SPA_DICT_ITEMS(
|
||||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, "F32P")),
|
SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, "F32P")),
|
||||||
&props->dict,
|
&props->dict,
|
||||||
|
|
@ -1928,8 +1928,11 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
||||||
copy_props(impl, props, PW_KEY_MEDIA_NAME);
|
copy_props(impl, props, PW_KEY_MEDIA_NAME);
|
||||||
copy_props(impl, props, "resample.prefill");
|
copy_props(impl, props, "resample.prefill");
|
||||||
|
|
||||||
parse_audio_info(impl->capture_props, &impl->capture_info);
|
if ((res = parse_audio_info(impl->capture_props, &impl->capture_info)) < 0 ||
|
||||||
parse_audio_info(impl->playback_props, &impl->playback_info);
|
(res = parse_audio_info(impl->playback_props, &impl->playback_info)) < 0) {
|
||||||
|
pw_log_error( "can't parse format: %s", spa_strerror(res));
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
if (!impl->capture_info.rate && !impl->playback_info.rate) {
|
if (!impl->capture_info.rate && !impl->playback_info.rate) {
|
||||||
if (pw_properties_get(impl->playback_props, "resample.disable") == NULL)
|
if (pw_properties_get(impl->playback_props, "resample.disable") == NULL)
|
||||||
|
|
|
||||||
|
|
@ -1053,9 +1053,9 @@ static const struct pw_impl_module_events module_events = {
|
||||||
.destroy = module_destroy,
|
.destroy = module_destroy,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void parse_audio_info(const struct pw_properties *props, struct spa_audio_info_raw *info)
|
static int parse_audio_info(const struct pw_properties *props, struct spa_audio_info_raw *info)
|
||||||
{
|
{
|
||||||
spa_audio_info_raw_init_dict_keys(info,
|
return spa_audio_info_raw_init_dict_keys(info,
|
||||||
&SPA_DICT_ITEMS(
|
&SPA_DICT_ITEMS(
|
||||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, "F32P"),
|
SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, "F32P"),
|
||||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_POSITION, DEFAULT_POSITION)),
|
SPA_DICT_ITEM(SPA_KEY_AUDIO_POSITION, DEFAULT_POSITION)),
|
||||||
|
|
@ -1178,8 +1178,11 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
||||||
copy_props(impl, props, "jack.connect-audio");
|
copy_props(impl, props, "jack.connect-audio");
|
||||||
copy_props(impl, props, "jack.connect-midi");
|
copy_props(impl, props, "jack.connect-midi");
|
||||||
|
|
||||||
parse_audio_info(impl->source.props, &impl->source.info);
|
if ((res = parse_audio_info(impl->source.props, &impl->source.info)) < 0 ||
|
||||||
parse_audio_info(impl->sink.props, &impl->sink.info);
|
(res = parse_audio_info(impl->sink.props, &impl->sink.info)) < 0) {
|
||||||
|
pw_log_error( "can't parse format: %s", spa_strerror(res));
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
impl->source.n_midi = pw_properties_get_uint32(impl->source.props,
|
impl->source.n_midi = pw_properties_get_uint32(impl->source.props,
|
||||||
"midi.ports", DEFAULT_MIDI_PORTS);
|
"midi.ports", DEFAULT_MIDI_PORTS);
|
||||||
|
|
|
||||||
|
|
@ -838,9 +838,9 @@ static const struct pw_impl_module_events module_events = {
|
||||||
.destroy = module_destroy,
|
.destroy = module_destroy,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void parse_audio_info(struct pw_properties *props, struct spa_audio_info_raw *info)
|
static int parse_audio_info(struct pw_properties *props, struct spa_audio_info_raw *info)
|
||||||
{
|
{
|
||||||
spa_audio_info_raw_init_dict_keys(info,
|
return spa_audio_info_raw_init_dict_keys(info,
|
||||||
&SPA_DICT_ITEMS(
|
&SPA_DICT_ITEMS(
|
||||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, "F32P")),
|
SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, "F32P")),
|
||||||
&props->dict,
|
&props->dict,
|
||||||
|
|
@ -952,9 +952,12 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
||||||
if (pw_properties_get(impl->playback_props, PW_KEY_NODE_DESCRIPTION) == NULL)
|
if (pw_properties_get(impl->playback_props, PW_KEY_NODE_DESCRIPTION) == NULL)
|
||||||
pw_properties_set(impl->playback_props, PW_KEY_NODE_DESCRIPTION, str);
|
pw_properties_set(impl->playback_props, PW_KEY_NODE_DESCRIPTION, str);
|
||||||
|
|
||||||
parse_audio_info(props, &impl->info);
|
if ((res = parse_audio_info(props, &impl->info)) < 0 ||
|
||||||
parse_audio_info(impl->capture_props, &impl->capture_info);
|
(res = parse_audio_info(impl->capture_props, &impl->capture_info)) < 0 ||
|
||||||
parse_audio_info(impl->playback_props, &impl->playback_info);
|
(res = parse_audio_info(impl->playback_props, &impl->playback_info)) < 0) {
|
||||||
|
pw_log_error( "can't parse formats: %s", spa_strerror(res));
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
if (!impl->capture_info.rate && !impl->playback_info.rate) {
|
if (!impl->capture_info.rate && !impl->playback_info.rate) {
|
||||||
if (pw_properties_get(impl->playback_props, "resample.disable") == NULL)
|
if (pw_properties_get(impl->playback_props, "resample.disable") == NULL)
|
||||||
|
|
|
||||||
|
|
@ -1221,9 +1221,9 @@ static const struct pw_impl_module_events module_events = {
|
||||||
.destroy = module_destroy,
|
.destroy = module_destroy,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void parse_audio_info(const struct pw_properties *props, struct spa_audio_info_raw *info)
|
static int parse_audio_info(const struct pw_properties *props, struct spa_audio_info_raw *info)
|
||||||
{
|
{
|
||||||
spa_audio_info_raw_init_dict_keys(info,
|
return spa_audio_info_raw_init_dict_keys(info,
|
||||||
&SPA_DICT_ITEMS(
|
&SPA_DICT_ITEMS(
|
||||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, "F32P")),
|
SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, "F32P")),
|
||||||
&props->dict,
|
&props->dict,
|
||||||
|
|
@ -1339,8 +1339,11 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
||||||
copy_props(impl, props, "midi.ports");
|
copy_props(impl, props, "midi.ports");
|
||||||
copy_props(impl, props, "audio.ports");
|
copy_props(impl, props, "audio.ports");
|
||||||
|
|
||||||
parse_audio_info(impl->source.props, &impl->source.info);
|
if ((res = parse_audio_info(impl->source.props, &impl->source.info)) < 0 ||
|
||||||
parse_audio_info(impl->sink.props, &impl->sink.info);
|
(res = parse_audio_info(impl->sink.props, &impl->sink.info)) < 0) {
|
||||||
|
pw_log_error( "can't parse format: %s", spa_strerror(res));
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
impl->source.wanted_n_midi = pw_properties_get_int32(impl->source.props,
|
impl->source.wanted_n_midi = pw_properties_get_int32(impl->source.props,
|
||||||
"midi.ports", DEFAULT_MIDI_PORTS);
|
"midi.ports", DEFAULT_MIDI_PORTS);
|
||||||
|
|
|
||||||
|
|
@ -181,7 +181,7 @@ static const struct spa_dict_item module_props[] = {
|
||||||
{ PW_KEY_MODULE_VERSION, PACKAGE_VERSION },
|
{ PW_KEY_MODULE_VERSION, PACKAGE_VERSION },
|
||||||
};
|
};
|
||||||
|
|
||||||
static void parse_audio_info(const struct pw_properties *props, struct spa_audio_info_raw *info);
|
static int parse_audio_info(const struct pw_properties *props, struct spa_audio_info_raw *info);
|
||||||
|
|
||||||
struct port {
|
struct port {
|
||||||
enum spa_direction direction;
|
enum spa_direction direction;
|
||||||
|
|
@ -969,8 +969,11 @@ static int handle_follower_available(struct impl *impl, struct nj2_session_param
|
||||||
follower->sink.direction = PW_DIRECTION_INPUT;
|
follower->sink.direction = PW_DIRECTION_INPUT;
|
||||||
follower->sink.props = pw_properties_copy(impl->sink_props);
|
follower->sink.props = pw_properties_copy(impl->sink_props);
|
||||||
|
|
||||||
parse_audio_info(follower->source.props, &follower->source.info);
|
if ((res = parse_audio_info(follower->source.props, &follower->source.info)) < 0 ||
|
||||||
parse_audio_info(follower->sink.props, &follower->sink.info);
|
(res = parse_audio_info(follower->sink.props, &follower->sink.info)) < 0) {
|
||||||
|
pw_log_error("can't parse format: %s", spa_strerror(res));
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
follower->source.n_audio = pw_properties_get_uint32(follower->source.props,
|
follower->source.n_audio = pw_properties_get_uint32(follower->source.props,
|
||||||
"audio.ports", follower->source.info.channels ?
|
"audio.ports", follower->source.info.channels ?
|
||||||
|
|
@ -1292,9 +1295,9 @@ static const struct pw_impl_module_events module_events = {
|
||||||
.destroy = module_destroy,
|
.destroy = module_destroy,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void parse_audio_info(const struct pw_properties *props, struct spa_audio_info_raw *info)
|
static int parse_audio_info(const struct pw_properties *props, struct spa_audio_info_raw *info)
|
||||||
{
|
{
|
||||||
spa_audio_info_raw_init_dict_keys(info,
|
return spa_audio_info_raw_init_dict_keys(info,
|
||||||
&SPA_DICT_ITEMS(
|
&SPA_DICT_ITEMS(
|
||||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, "F32P")),
|
SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, "F32P")),
|
||||||
&props->dict,
|
&props->dict,
|
||||||
|
|
|
||||||
|
|
@ -745,9 +745,9 @@ static const struct pw_impl_module_events module_events = {
|
||||||
.destroy = module_destroy,
|
.destroy = module_destroy,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void parse_audio_info(const struct pw_properties *props, struct spa_audio_info_raw *info)
|
static int parse_audio_info(const struct pw_properties *props, struct spa_audio_info_raw *info)
|
||||||
{
|
{
|
||||||
spa_audio_info_raw_init_dict_keys(info,
|
return spa_audio_info_raw_init_dict_keys(info,
|
||||||
&SPA_DICT_ITEMS(
|
&SPA_DICT_ITEMS(
|
||||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, DEFAULT_FORMAT),
|
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_RATE, SPA_STRINGIFY(DEFAULT_RATE)),
|
||||||
|
|
@ -896,7 +896,10 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
||||||
copy_props(impl, props, PW_KEY_TARGET_OBJECT);
|
copy_props(impl, props, PW_KEY_TARGET_OBJECT);
|
||||||
copy_props(impl, props, "pipe.filename");
|
copy_props(impl, props, "pipe.filename");
|
||||||
|
|
||||||
parse_audio_info(impl->stream_props, &impl->info);
|
if ((res = parse_audio_info(impl->stream_props, &impl->info)) < 0) {
|
||||||
|
pw_log_error("can't parse format: %s", spa_strerror(res));
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
impl->frame_size = calc_frame_size(&impl->info);
|
impl->frame_size = calc_frame_size(&impl->info);
|
||||||
if (impl->frame_size == 0) {
|
if (impl->frame_size == 0) {
|
||||||
|
|
|
||||||
|
|
@ -815,13 +815,14 @@ static int calc_frame_size(struct spa_audio_info_raw *info)
|
||||||
case SPA_AUDIO_FORMAT_F64_OE:
|
case SPA_AUDIO_FORMAT_F64_OE:
|
||||||
return res * 8;
|
return res * 8;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return -ENOTSUP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int parse_audio_info(const struct pw_properties *props, struct spa_audio_info_raw *info)
|
static int parse_audio_info(const struct pw_properties *props, struct spa_audio_info_raw *info)
|
||||||
{
|
{
|
||||||
spa_audio_info_raw_init_dict_keys(info,
|
int res;
|
||||||
|
if ((res = spa_audio_info_raw_init_dict_keys(info,
|
||||||
&SPA_DICT_ITEMS(
|
&SPA_DICT_ITEMS(
|
||||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, DEFAULT_FORMAT),
|
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_RATE, SPA_STRINGIFY(DEFAULT_RATE)),
|
||||||
|
|
@ -830,7 +831,8 @@ static int parse_audio_info(const struct pw_properties *props, struct spa_audio_
|
||||||
SPA_KEY_AUDIO_FORMAT,
|
SPA_KEY_AUDIO_FORMAT,
|
||||||
SPA_KEY_AUDIO_RATE,
|
SPA_KEY_AUDIO_RATE,
|
||||||
SPA_KEY_AUDIO_CHANNELS,
|
SPA_KEY_AUDIO_CHANNELS,
|
||||||
SPA_KEY_AUDIO_POSITION, NULL);
|
SPA_KEY_AUDIO_POSITION, NULL)) < 0)
|
||||||
|
return res;
|
||||||
|
|
||||||
return calc_frame_size(info);
|
return calc_frame_size(info);
|
||||||
}
|
}
|
||||||
|
|
@ -851,6 +853,7 @@ static int parse_params(struct impl *impl)
|
||||||
const char *str;
|
const char *str;
|
||||||
struct spa_json it[1];
|
struct spa_json it[1];
|
||||||
char value[512];
|
char value[512];
|
||||||
|
int res;
|
||||||
|
|
||||||
pw_properties_fetch_bool(impl->props, "capture", &impl->capture);
|
pw_properties_fetch_bool(impl->props, "capture", &impl->capture);
|
||||||
pw_properties_fetch_bool(impl->props, "playback", &impl->playback);
|
pw_properties_fetch_bool(impl->props, "playback", &impl->playback);
|
||||||
|
|
@ -894,19 +897,20 @@ static int parse_params(struct impl *impl)
|
||||||
copy_props(impl, PW_KEY_NODE_VIRTUAL);
|
copy_props(impl, PW_KEY_NODE_VIRTUAL);
|
||||||
copy_props(impl, PW_KEY_NODE_NETWORK);
|
copy_props(impl, PW_KEY_NODE_NETWORK);
|
||||||
|
|
||||||
impl->capture_frame_size = parse_audio_info(impl->capture_props, &impl->capture_info);
|
if ((res = parse_audio_info(impl->capture_props, &impl->capture_info)) <= 0) {
|
||||||
if (impl->capture_frame_size == 0) {
|
|
||||||
pw_log_error("unsupported capture audio format:%d channels:%d",
|
pw_log_error("unsupported capture audio format:%d channels:%d",
|
||||||
impl->capture_info.format, impl->capture_info.channels);
|
impl->capture_info.format, impl->capture_info.channels);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
impl->capture_frame_size = res;
|
||||||
|
|
||||||
impl->playback_frame_size = parse_audio_info(impl->playback_props, &impl->playback_info);
|
if ((res = parse_audio_info(impl->playback_props, &impl->playback_info)) <= 0) {
|
||||||
if (impl->playback_frame_size == 0) {
|
|
||||||
pw_log_error("unsupported playback audio format:%d channels:%d",
|
pw_log_error("unsupported playback audio format:%d channels:%d",
|
||||||
impl->playback_info.format, impl->playback_info.channels);
|
impl->playback_info.format, impl->playback_info.channels);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
impl->playback_frame_size = res;
|
||||||
|
|
||||||
if (impl->capture_info.rate != 0 &&
|
if (impl->capture_info.rate != 0 &&
|
||||||
pw_properties_get(impl->capture_props, PW_KEY_NODE_RATE) == NULL)
|
pw_properties_get(impl->capture_props, PW_KEY_NODE_RATE) == NULL)
|
||||||
pw_properties_setf(impl->capture_props, PW_KEY_NODE_RATE,
|
pw_properties_setf(impl->capture_props, PW_KEY_NODE_RATE,
|
||||||
|
|
|
||||||
|
|
@ -1048,9 +1048,9 @@ static const struct pw_impl_module_events module_events = {
|
||||||
.destroy = module_destroy,
|
.destroy = module_destroy,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void parse_audio_info(const struct pw_properties *props, struct spa_audio_info_raw *info)
|
static int parse_audio_info(const struct pw_properties *props, struct spa_audio_info_raw *info)
|
||||||
{
|
{
|
||||||
spa_audio_info_raw_init_dict_keys(info,
|
return spa_audio_info_raw_init_dict_keys(info,
|
||||||
&SPA_DICT_ITEMS(
|
&SPA_DICT_ITEMS(
|
||||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, DEFAULT_FORMAT),
|
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_RATE, SPA_STRINGIFY(DEFAULT_RATE)),
|
||||||
|
|
@ -1192,7 +1192,10 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
||||||
copy_props(impl, props, PW_KEY_NODE_NETWORK);
|
copy_props(impl, props, PW_KEY_NODE_NETWORK);
|
||||||
copy_props(impl, props, PW_KEY_MEDIA_CLASS);
|
copy_props(impl, props, PW_KEY_MEDIA_CLASS);
|
||||||
|
|
||||||
parse_audio_info(impl->stream_props, &impl->info);
|
if ((res = parse_audio_info(impl->stream_props, &impl->info)) < 0) {
|
||||||
|
pw_log_error("can't parse format: %s", spa_strerror(res));
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
impl->frame_size = calc_frame_size(&impl->info);
|
impl->frame_size = calc_frame_size(&impl->info);
|
||||||
if (impl->frame_size == 0) {
|
if (impl->frame_size == 0) {
|
||||||
|
|
|
||||||
|
|
@ -569,9 +569,9 @@ static const struct format_info *find_audio_format_info(const struct spa_audio_i
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void parse_audio_info(const struct pw_properties *props, struct spa_audio_info_raw *info)
|
static int parse_audio_info(const struct pw_properties *props, struct spa_audio_info_raw *info)
|
||||||
{
|
{
|
||||||
spa_audio_info_raw_init_dict_keys(info,
|
return spa_audio_info_raw_init_dict_keys(info,
|
||||||
&SPA_DICT_ITEMS(
|
&SPA_DICT_ITEMS(
|
||||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, DEFAULT_FORMAT),
|
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_RATE, SPA_STRINGIFY(DEFAULT_RATE)),
|
||||||
|
|
@ -675,7 +675,10 @@ struct rtp_stream *rtp_stream_new(struct pw_core *core,
|
||||||
|
|
||||||
switch (impl->info.media_subtype) {
|
switch (impl->info.media_subtype) {
|
||||||
case SPA_MEDIA_SUBTYPE_raw:
|
case SPA_MEDIA_SUBTYPE_raw:
|
||||||
parse_audio_info(props, &impl->info.info.raw);
|
if ((res = parse_audio_info(props, &impl->info.info.raw)) < 0) {
|
||||||
|
pw_log_error("can't parse format: %s", spa_strerror(res));
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
impl->stream_info = impl->info;
|
impl->stream_info = impl->info;
|
||||||
impl->format_info = find_audio_format_info(&impl->info);
|
impl->format_info = find_audio_format_info(&impl->info);
|
||||||
if (impl->format_info == NULL) {
|
if (impl->format_info == NULL) {
|
||||||
|
|
@ -704,7 +707,10 @@ struct rtp_stream *rtp_stream_new(struct pw_core *core,
|
||||||
case SPA_MEDIA_SUBTYPE_opus:
|
case SPA_MEDIA_SUBTYPE_opus:
|
||||||
impl->stream_info.media_type = SPA_MEDIA_TYPE_audio;
|
impl->stream_info.media_type = SPA_MEDIA_TYPE_audio;
|
||||||
impl->stream_info.media_subtype = SPA_MEDIA_SUBTYPE_raw;
|
impl->stream_info.media_subtype = SPA_MEDIA_SUBTYPE_raw;
|
||||||
parse_audio_info(props, &impl->stream_info.info.raw);
|
if ((res = parse_audio_info(props, &impl->stream_info.info.raw)) < 0) {
|
||||||
|
pw_log_error("can't parse format: %s", spa_strerror(res));
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
impl->stream_info.info.raw.format = SPA_AUDIO_FORMAT_F32;
|
impl->stream_info.info.raw.format = SPA_AUDIO_FORMAT_F32;
|
||||||
impl->info.info.opus.rate = impl->stream_info.info.raw.rate;
|
impl->info.info.opus.rate = impl->stream_info.info.raw.rate;
|
||||||
impl->info.info.opus.channels = impl->stream_info.info.raw.channels;
|
impl->info.info.opus.channels = impl->stream_info.info.raw.channels;
|
||||||
|
|
|
||||||
|
|
@ -503,9 +503,11 @@ static int add_snapcast_stream(struct impl *impl, struct tunnel *t,
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void parse_audio_info(struct pw_properties *props, struct spa_audio_info_raw *info)
|
static int parse_audio_info(struct pw_properties *props, struct spa_audio_info_raw *info)
|
||||||
{
|
{
|
||||||
spa_audio_info_raw_init_dict_keys(info,
|
int res;
|
||||||
|
|
||||||
|
if ((res = spa_audio_info_raw_init_dict_keys(info,
|
||||||
&SPA_DICT_ITEMS(
|
&SPA_DICT_ITEMS(
|
||||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, DEFAULT_FORMAT),
|
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_RATE, SPA_STRINGIFY(DEFAULT_RATE)),
|
||||||
|
|
@ -514,12 +516,14 @@ static void parse_audio_info(struct pw_properties *props, struct spa_audio_info_
|
||||||
SPA_KEY_AUDIO_FORMAT,
|
SPA_KEY_AUDIO_FORMAT,
|
||||||
SPA_KEY_AUDIO_RATE,
|
SPA_KEY_AUDIO_RATE,
|
||||||
SPA_KEY_AUDIO_CHANNELS,
|
SPA_KEY_AUDIO_CHANNELS,
|
||||||
SPA_KEY_AUDIO_POSITION, NULL);
|
SPA_KEY_AUDIO_POSITION, NULL)) < 0)
|
||||||
|
return res;
|
||||||
|
|
||||||
pw_properties_set(props, PW_KEY_AUDIO_FORMAT,
|
pw_properties_set(props, PW_KEY_AUDIO_FORMAT,
|
||||||
spa_type_audio_format_to_short_name(info->format));
|
spa_type_audio_format_to_short_name(info->format));
|
||||||
pw_properties_setf(props, PW_KEY_AUDIO_RATE, "%d", info->rate);
|
pw_properties_setf(props, PW_KEY_AUDIO_RATE, "%d", info->rate);
|
||||||
pw_properties_setf(props, PW_KEY_AUDIO_CHANNELS, "%d", info->channels);
|
pw_properties_setf(props, PW_KEY_AUDIO_CHANNELS, "%d", info->channels);
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int create_stream(struct impl *impl, struct pw_properties *props,
|
static int create_stream(struct impl *impl, struct pw_properties *props,
|
||||||
|
|
@ -545,7 +549,10 @@ static int create_stream(struct impl *impl, struct pw_properties *props,
|
||||||
if ((str = pw_properties_get(props, "capture.props")) == NULL)
|
if ((str = pw_properties_get(props, "capture.props")) == NULL)
|
||||||
pw_properties_set(props, "capture.props", "{ media.class = Audio/Sink }");
|
pw_properties_set(props, "capture.props", "{ media.class = Audio/Sink }");
|
||||||
|
|
||||||
parse_audio_info(props, &t->audio_info);
|
if ((res = parse_audio_info(props, &t->audio_info)) < 0) {
|
||||||
|
pw_log_error("Can't parse format: %s", spa_strerror(res));
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
if ((f = open_memstream(&args, &size)) == NULL) {
|
if ((f = open_memstream(&args, &size)) == NULL) {
|
||||||
res = -errno;
|
res = -errno;
|
||||||
|
|
|
||||||
|
|
@ -185,9 +185,9 @@ static const struct format_info *find_audio_format_info(const struct spa_audio_i
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void parse_audio_info(const struct pw_properties *props, struct spa_audio_info_raw *info)
|
static int parse_audio_info(const struct pw_properties *props, struct spa_audio_info_raw *info)
|
||||||
{
|
{
|
||||||
spa_audio_info_raw_init_dict_keys(info,
|
return spa_audio_info_raw_init_dict_keys(info,
|
||||||
&SPA_DICT_ITEMS(
|
&SPA_DICT_ITEMS(
|
||||||
SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, DEFAULT_FORMAT),
|
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_RATE, SPA_STRINGIFY(DEFAULT_RATE)),
|
||||||
|
|
@ -274,7 +274,10 @@ struct vban_stream *vban_stream_new(struct pw_core *core,
|
||||||
|
|
||||||
switch (impl->info.media_subtype) {
|
switch (impl->info.media_subtype) {
|
||||||
case SPA_MEDIA_SUBTYPE_raw:
|
case SPA_MEDIA_SUBTYPE_raw:
|
||||||
parse_audio_info(props, &impl->info.info.raw);
|
if ((res = parse_audio_info(props, &impl->info.info.raw)) < 0) {
|
||||||
|
pw_log_error("can't parse format: %s", spa_strerror(res));
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
if (SPA_FLAG_IS_SET(impl->info.info.raw.flags, SPA_AUDIO_FLAG_UNPOSITIONED))
|
if (SPA_FLAG_IS_SET(impl->info.info.raw.flags, SPA_AUDIO_FLAG_UNPOSITIONED))
|
||||||
default_layout(impl->info.info.raw.channels,
|
default_layout(impl->info.info.raw.channels,
|
||||||
impl->info.info.raw.position,
|
impl->info.info.raw.position,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue