diff --git a/src/modules/module-protocol-pulse/modules/module-combine-sink.c b/src/modules/module-protocol-pulse/modules/module-combine-sink.c index 6f5791ad0..b4b8f0586 100644 --- a/src/modules/module-protocol-pulse/modules/module-combine-sink.c +++ b/src/modules/module-protocol-pulse/modules/module-combine-sink.c @@ -411,8 +411,7 @@ struct module *create_module_combine_sink(struct impl *impl, const char *argumen struct module *module; struct module_combine_sink_data *d; struct pw_properties *props = NULL; - const char *str; - char *sink_name = NULL, **sink_names = NULL; + char *str, *sink_name = NULL, **sink_names = NULL; struct spa_audio_info_raw info = { 0 }; int i, n, res; @@ -424,16 +423,12 @@ struct module *create_module_combine_sink(struct impl *impl, const char *argumen if (argument) module_args_add_props(props, argument); - if ((str = pw_properties_get(props, "sink_name")) != NULL) { - sink_name = strdup(str); - pw_properties_set(props, "sink_name", NULL); - } else { + if ((sink_name = pw_properties_steal(props, "sink_name")) == NULL) sink_name = strdup("combined"); - } - if ((str = pw_properties_get(props, "slaves")) != NULL) { + if ((str = pw_properties_steal(props, "slaves")) != NULL) { sink_names = pw_split_strv(str, ",", MAX_SINKS, &n); - pw_properties_set(props, "slaves", NULL); + free(str); } if (pw_properties_set(props, "adjust_time", NULL) != 0) diff --git a/src/modules/module-protocol-pulse/modules/module-echo-cancel.c b/src/modules/module-protocol-pulse/modules/module-echo-cancel.c index 10a52663c..e98c94a3b 100644 --- a/src/modules/module-protocol-pulse/modules/module-echo-cancel.c +++ b/src/modules/module-protocol-pulse/modules/module-echo-cancel.c @@ -160,8 +160,8 @@ struct module *create_module_echo_cancel(struct impl *impl, const char *argument struct module *module; struct module_echo_cancel_data *d; struct pw_properties *props = NULL, *aec_props = NULL, *sink_props = NULL, *source_props = NULL; - const char *str; struct spa_audio_info_raw info = { 0 }; + char *str; int res; props = pw_properties_new_dict(&SPA_DICT_INIT_ARRAY(module_echo_cancel_info)); @@ -178,14 +178,15 @@ struct module *create_module_echo_cancel(struct impl *impl, const char *argument pw_properties_move(source_props, PW_KEY_NODE_NAME, props, "source_name", "echo-cancel"); pw_properties_move(sink_props, PW_KEY_NODE_NAME, props, "sink_name", "echo-cancel"); - if ((str = pw_properties_get(props, "source_master")) != NULL) { + if ((str = pw_properties_steal(props, "source_master")) != NULL) { if (pw_endswith(str, ".monitor")) { pw_properties_setf(source_props, PW_KEY_NODE_TARGET, "%.*s", (int)strlen(str)-8, str); } else { pw_properties_set(source_props, PW_KEY_NODE_TARGET, str); } - pw_properties_set(props, "source_master", NULL); + + free(str); } pw_properties_move(sink_props, PW_KEY_NODE_TARGET, props, "sink_master", NULL); @@ -195,14 +196,14 @@ struct module *create_module_echo_cancel(struct impl *impl, const char *argument goto out; } - if ((str = pw_properties_get(props, "source_properties")) != NULL) { + if ((str = pw_properties_steal(props, "source_properties")) != NULL) { module_args_add_props(source_props, str); - pw_properties_set(props, "source_properties", NULL); + free(str); } - if ((str = pw_properties_get(props, "sink_properties")) != NULL) { + if ((str = pw_properties_steal(props, "sink_properties")) != NULL) { module_args_add_props(sink_props, str); - pw_properties_set(props, "sink_properties", NULL); + free(str); } pw_properties_move(aec_props, "aec.method", props, "aec_method", NULL); diff --git a/src/modules/module-protocol-pulse/modules/module-ladspa-sink.c b/src/modules/module-protocol-pulse/modules/module-ladspa-sink.c index f5f1e9c70..a4f40aef4 100644 --- a/src/modules/module-protocol-pulse/modules/module-ladspa-sink.c +++ b/src/modules/module-protocol-pulse/modules/module-ladspa-sink.c @@ -167,9 +167,9 @@ struct module *create_module_ladspa_sink(struct impl *impl, const char *argument struct module *module; struct module_ladspa_sink_data *d; struct pw_properties *props = NULL, *playback_props = NULL, *capture_props = NULL; - const char *str; struct spa_audio_info_raw capture_info = { 0 }; struct spa_audio_info_raw playback_info = { 0 }; + char *str; int res; props = pw_properties_new_dict(&SPA_DICT_INIT_ARRAY(module_ladspa_sink_info)); @@ -184,17 +184,18 @@ struct module *create_module_ladspa_sink(struct impl *impl, const char *argument pw_properties_move(props, PW_KEY_NODE_NAME, props, "sink_name", NULL); - if ((str = pw_properties_get(props, "sink_properties")) != NULL) { + if ((str = pw_properties_steal(props, "sink_properties")) != NULL) { module_args_add_props(capture_props, str); - pw_properties_set(props, "sink_properties", NULL); + free(str); } + if (pw_properties_get(capture_props, PW_KEY_MEDIA_CLASS) == NULL) pw_properties_set(capture_props, PW_KEY_MEDIA_CLASS, "Audio/Sink"); - if ((str = pw_properties_get(props, "master")) != NULL || - (str = pw_properties_get(props, "sink_master")) != NULL) { + if ((str = pw_properties_steal(props, "master")) != NULL || + (str = pw_properties_steal(props, "sink_master")) != NULL) { pw_properties_set(playback_props, PW_KEY_NODE_TARGET, str); - pw_properties_set(props, "master", NULL); + free(str); } if (module_args_to_audioinfo(impl, props, &capture_info) < 0) { diff --git a/src/modules/module-protocol-pulse/modules/module-ladspa-source.c b/src/modules/module-protocol-pulse/modules/module-ladspa-source.c index 9de7e2b8b..aa48d2214 100644 --- a/src/modules/module-protocol-pulse/modules/module-ladspa-source.c +++ b/src/modules/module-protocol-pulse/modules/module-ladspa-source.c @@ -167,9 +167,9 @@ struct module *create_module_ladspa_source(struct impl *impl, const char *argume struct module *module; struct module_ladspa_source_data *d; struct pw_properties *props = NULL, *playback_props = NULL, *capture_props = NULL; - const char *str; struct spa_audio_info_raw capture_info = { 0 }; struct spa_audio_info_raw playback_info = { 0 }; + char *str; int res; props = pw_properties_new_dict(&SPA_DICT_INIT_ARRAY(module_ladspa_source_info)); @@ -184,17 +184,18 @@ struct module *create_module_ladspa_source(struct impl *impl, const char *argume pw_properties_move(props, PW_KEY_NODE_NAME, props, "source_name", NULL); - if ((str = pw_properties_get(props, "source_properties")) != NULL) { + if ((str = pw_properties_steal(props, "source_properties")) != NULL) { module_args_add_props(capture_props, str); - pw_properties_set(props, "source_properties", NULL); + free(str); } + if (pw_properties_get(playback_props, PW_KEY_MEDIA_CLASS) == NULL) pw_properties_set(playback_props, PW_KEY_MEDIA_CLASS, "Audio/Source"); - if ((str = pw_properties_get(props, "master")) != NULL || - (str = pw_properties_get(props, "source_master")) != NULL) { + if ((str = pw_properties_steal(props, "master")) != NULL || + (str = pw_properties_steal(props, "source_master")) != NULL) { pw_properties_set(playback_props, PW_KEY_NODE_TARGET, str); - pw_properties_set(props, "master", NULL); + free(str); } if (module_args_to_audioinfo(impl, props, &capture_info) < 0) { diff --git a/src/modules/module-protocol-pulse/modules/module-loopback.c b/src/modules/module-protocol-pulse/modules/module-loopback.c index 953dcfcab..783d3541f 100644 --- a/src/modules/module-protocol-pulse/modules/module-loopback.c +++ b/src/modules/module-protocol-pulse/modules/module-loopback.c @@ -138,8 +138,8 @@ struct module *create_module_loopback(struct impl *impl, const char *argument) struct module *module; struct module_loopback_data *d; struct pw_properties *props = NULL, *playback_props = NULL, *capture_props = NULL; - const char *str; struct spa_audio_info_raw info = { 0 }; + char *str; int res; props = pw_properties_new_dict(&SPA_DICT_INIT_ARRAY(module_loopback_info)); @@ -156,14 +156,15 @@ struct module *create_module_loopback(struct impl *impl, const char *argument) * adjust_time, max_latency_msec, fast_adjust_threshold_msec: these are just not relevant */ - if ((str = pw_properties_get(props, "source")) != NULL) { + if ((str = pw_properties_steal(props, "source")) != NULL) { if (pw_endswith(str, ".monitor")) { pw_properties_setf(capture_props, PW_KEY_NODE_TARGET, "%.*s", (int)strlen(str)-8, str); } else { pw_properties_set(capture_props, PW_KEY_NODE_TARGET, str); } - pw_properties_set(props, "source", NULL); + + free(str); } pw_properties_move(playback_props, PW_KEY_NODE_TARGET, props, "sink", NULL); @@ -176,31 +177,32 @@ struct module *create_module_loopback(struct impl *impl, const char *argument) pw_properties_move(capture_props, PW_KEY_NODE_DONT_RECONNECT, props, "source_dont_move", NULL); pw_properties_move(playback_props, PW_KEY_NODE_DONT_RECONNECT, props, "sink_dont_move", NULL); - if ((str = pw_properties_get(props, "remix")) != NULL) { + if ((str = pw_properties_steal(props, "remix")) != NULL) { /* Note that the boolean is inverted */ pw_properties_set(playback_props, PW_KEY_STREAM_DONT_REMIX, pw_properties_parse_bool(str) ? "false" : "true"); - pw_properties_set(props, "remix", NULL); + free(str); } - if ((str = pw_properties_get(props, "latency_msec")) != NULL) { + if ((str = pw_properties_steal(props, "latency_msec")) != NULL) { /* Half the latency on each of the playback and capture streams */ pw_properties_setf(capture_props, PW_KEY_NODE_LATENCY, "%s/2000", str); pw_properties_setf(playback_props, PW_KEY_NODE_LATENCY, "%s/2000", str); - pw_properties_set(props, "latency_msec", NULL); + + free(str); } else { pw_properties_set(capture_props, PW_KEY_NODE_LATENCY, "100/1000"); pw_properties_set(playback_props, PW_KEY_NODE_LATENCY, "100/1000"); } - if ((str = pw_properties_get(props, "sink_input_properties")) != NULL) { + if ((str = pw_properties_steal(props, "sink_input_properties")) != NULL) { module_args_add_props(playback_props, str); - pw_properties_set(props, "sink_input_properties", NULL); + free(str); } - if ((str = pw_properties_get(props, "source_output_properties")) != NULL) { + if ((str = pw_properties_steal(props, "source_output_properties")) != NULL) { module_args_add_props(capture_props, str); - pw_properties_set(props, "source_output_properties", NULL); + free(str); } module = module_new(impl, &module_loopback_methods, sizeof(*d)); diff --git a/src/modules/module-protocol-pulse/modules/module-null-sink.c b/src/modules/module-protocol-pulse/modules/module-null-sink.c index a067558c9..c3f30536e 100644 --- a/src/modules/module-protocol-pulse/modules/module-null-sink.c +++ b/src/modules/module-protocol-pulse/modules/module-null-sink.c @@ -129,9 +129,9 @@ struct module *create_module_null_sink(struct impl *impl, const char *argument) struct module *module; struct module_null_sink_data *d; struct pw_properties *props = NULL; - const char *str; struct spa_audio_info_raw info = { 0 }; uint32_t i; + char *str; int res; props = pw_properties_new_dict(&SPA_DICT_INIT_ARRAY(module_null_sink_info)); @@ -144,9 +144,9 @@ struct module *create_module_null_sink(struct impl *impl, const char *argument) pw_properties_move(props, PW_KEY_NODE_NAME, props, "sink_name", "null-sink"); - if ((str = pw_properties_get(props, "sink_properties")) != NULL) { + if ((str = pw_properties_steal(props, "sink_properties")) != NULL) { module_args_add_props(props, str); - pw_properties_set(props, "sink_properties", NULL); + free(str); } if (module_args_to_audioinfo(impl, props, &info) < 0) { diff --git a/src/modules/module-protocol-pulse/modules/module-pipe-sink.c b/src/modules/module-protocol-pulse/modules/module-pipe-sink.c index 6df8e3035..0912d7228 100644 --- a/src/modules/module-protocol-pulse/modules/module-pipe-sink.c +++ b/src/modules/module-protocol-pulse/modules/module-pipe-sink.c @@ -225,11 +225,11 @@ struct module *create_module_pipe_sink(struct impl *impl, const char *argument) struct pw_properties *props = NULL, *capture_props = NULL; struct spa_audio_info_raw info = { 0 }; struct stat st; - const char *str; char *filename = NULL; bool do_unlink_fifo; int res = 0; int fd = -1; + char *str; props = pw_properties_new_dict(&SPA_DICT_INIT_ARRAY(module_pipesink_info)); capture_props = pw_properties_new(NULL, NULL); @@ -245,19 +245,15 @@ struct module *create_module_pipe_sink(struct impl *impl, const char *argument) goto out; } - if ((str = pw_properties_get(props, "format")) != NULL) { + if ((str = pw_properties_steal(props, "format")) != NULL) { info.format = format_paname2id(str, strlen(str)); - pw_properties_set(props, "format", NULL); + free(str); } pw_properties_move(capture_props, PW_KEY_NODE_NAME, props, "sink_name", NULL); - if ((str = pw_properties_get(props, "file")) != NULL) { - filename = strdup(str); - pw_properties_set(props, "file", NULL); - } else { + if ((filename = pw_properties_steal(props, "file")) == NULL) filename = strdup(DEFAULT_FILE_NAME); - } do_unlink_fifo = false; if (mkfifo(filename, 0666) < 0) { @@ -293,7 +289,7 @@ struct module *create_module_pipe_sink(struct impl *impl, const char *argument) goto out; } - if ((str = pw_properties_get(props, PW_KEY_MEDIA_CLASS)) == NULL) + if (pw_properties_get(props, PW_KEY_MEDIA_CLASS) == NULL) pw_properties_set(props, PW_KEY_MEDIA_CLASS, "Audio/Sink"); module = module_new(impl, &module_pipesink_methods, sizeof(*d)); diff --git a/src/modules/module-protocol-pulse/modules/module-pipe-source.c b/src/modules/module-protocol-pulse/modules/module-pipe-source.c index e37050ef0..d651560cf 100644 --- a/src/modules/module-protocol-pulse/modules/module-pipe-source.c +++ b/src/modules/module-protocol-pulse/modules/module-pipe-source.c @@ -232,10 +232,10 @@ struct module *create_module_pipe_source(struct impl *impl, const char *argument struct pw_properties *props = NULL, *playback_props = NULL; struct spa_audio_info_raw info = { 0 }; struct stat st; - const char *str; char *filename = NULL; int stride, res = 0; int fd = -1; + char *str; props = pw_properties_new_dict(&SPA_DICT_INIT_ARRAY(module_pipesource_info)); playback_props = pw_properties_new(NULL, NULL); @@ -251,9 +251,9 @@ struct module *create_module_pipe_source(struct impl *impl, const char *argument goto out; } - if ((str = pw_properties_get(props, "format")) != NULL) { + if ((str = pw_properties_steal(props, "format")) != NULL) { info.format = format_paname2id(str, strlen(str)); - pw_properties_set(props, "format", NULL); + free(str); } switch (info.format) { @@ -289,12 +289,8 @@ struct module *create_module_pipe_source(struct impl *impl, const char *argument pw_properties_move(playback_props, PW_KEY_NODE_NAME, props, "source_name", NULL); - if ((str = pw_properties_get(props, "file")) != NULL) { - filename = strdup(str); - pw_properties_set(props, "file", NULL); - } else { + if ((filename = pw_properties_steal(props, "file")) == NULL) filename = strdup(DEFAULT_FILE_NAME); - } if (mkfifo(filename, 0666) < 0) { if (errno != EEXIST) { @@ -328,7 +324,7 @@ struct module *create_module_pipe_source(struct impl *impl, const char *argument goto out; } - if ((str = pw_properties_get(props, PW_KEY_MEDIA_CLASS)) == NULL) + if (pw_properties_get(props, PW_KEY_MEDIA_CLASS) == NULL) pw_properties_set(props, PW_KEY_MEDIA_CLASS, "Audio/Source"); module = module_new(impl, &module_pipesource_methods, sizeof(*d)); diff --git a/src/modules/module-protocol-pulse/modules/module-remap-sink.c b/src/modules/module-protocol-pulse/modules/module-remap-sink.c index 6fbe5bc44..7d62607c8 100644 --- a/src/modules/module-protocol-pulse/modules/module-remap-sink.c +++ b/src/modules/module-protocol-pulse/modules/module-remap-sink.c @@ -146,9 +146,9 @@ struct module *create_module_remap_sink(struct impl *impl, const char *argument) struct module *module; struct module_remap_sink_data *d; struct pw_properties *props = NULL, *playback_props = NULL, *capture_props = NULL; - const char *str; struct spa_audio_info_raw capture_info = { 0 }; struct spa_audio_info_raw playback_info = { 0 }; + char *str; int res; props = pw_properties_new_dict(&SPA_DICT_INIT_ARRAY(module_remap_sink_info)); @@ -163,9 +163,9 @@ struct module *create_module_remap_sink(struct impl *impl, const char *argument) pw_properties_move(props, PW_KEY_NODE_NAME, props, "sink_name", NULL); - if ((str = pw_properties_get(props, "sink_properties")) != NULL) { + if ((str = pw_properties_steal(props, "sink_properties")) != NULL) { module_args_add_props(capture_props, str); - pw_properties_set(props, "sink_properties", NULL); + free(str); } pw_properties_set(capture_props, PW_KEY_MEDIA_CLASS, "Audio/Sink"); @@ -178,26 +178,30 @@ struct module *create_module_remap_sink(struct impl *impl, const char *argument) } playback_info = capture_info; - if ((str = pw_properties_get(props, "master_channel_map")) != NULL) { + if ((str = pw_properties_steal(props, "master_channel_map")) != NULL) { struct channel_map map; channel_map_parse(str, &map); if (map.channels == 0 || map.channels > SPA_AUDIO_MAX_CHANNELS) { pw_log_error("invalid channel_map '%s'", str); + free(str); res = -EINVAL; goto out; } + channel_map_to_positions(&map, playback_info.position); - pw_properties_set(props, "master_channel_map", NULL); + + free(str); } + position_to_props(&capture_info, capture_props); position_to_props(&playback_info, playback_props); - if ((str = pw_properties_get(props, "remix")) != NULL) { + if ((str = pw_properties_steal(props, "remix")) != NULL) { /* Note that the boolean is inverted */ pw_properties_set(playback_props, PW_KEY_STREAM_DONT_REMIX, pw_properties_parse_bool(str) ? "false" : "true"); - pw_properties_set(props, "remix", NULL); + free(str); } if (pw_properties_get(playback_props, PW_KEY_NODE_PASSIVE) == NULL) diff --git a/src/modules/module-protocol-pulse/modules/module-remap-source.c b/src/modules/module-protocol-pulse/modules/module-remap-source.c index ed775d9b3..b8152a625 100644 --- a/src/modules/module-protocol-pulse/modules/module-remap-source.c +++ b/src/modules/module-protocol-pulse/modules/module-remap-source.c @@ -146,9 +146,9 @@ struct module *create_module_remap_source(struct impl *impl, const char *argumen struct module *module; struct module_remap_source_data *d; struct pw_properties *props = NULL, *playback_props = NULL, *capture_props = NULL; - const char *str; struct spa_audio_info_raw capture_info = { 0 }; struct spa_audio_info_raw playback_info = { 0 }; + char *str; int res; props = pw_properties_new_dict(&SPA_DICT_INIT_ARRAY(module_remap_source_info)); @@ -163,9 +163,9 @@ struct module *create_module_remap_source(struct impl *impl, const char *argumen pw_properties_move(props, PW_KEY_NODE_NAME, props, "source_name", NULL); - if ((str = pw_properties_get(props, "source_properties")) != NULL) { + if ((str = pw_properties_steal(props, "source_properties")) != NULL) { module_args_add_props(playback_props, str); - pw_properties_set(props, "source_properties", NULL); + free(str); } pw_properties_set(playback_props, PW_KEY_MEDIA_CLASS, "Audio/Source"); @@ -178,26 +178,30 @@ struct module *create_module_remap_source(struct impl *impl, const char *argumen } capture_info = playback_info; - if ((str = pw_properties_get(props, "master_channel_map")) != NULL) { + if ((str = pw_properties_steal(props, "master_channel_map")) != NULL) { struct channel_map map; channel_map_parse(str, &map); if (map.channels == 0 || map.channels > SPA_AUDIO_MAX_CHANNELS) { pw_log_error("invalid channel_map '%s'", str); + free(str); res = -EINVAL; goto out; } + channel_map_to_positions(&map, capture_info.position); - pw_properties_set(props, "master_channel_map", NULL); + + free(str); } + position_to_props(&playback_info, playback_props); position_to_props(&capture_info, capture_props); - if ((str = pw_properties_get(props, "remix")) != NULL) { + if ((str = pw_properties_steal(props, "remix")) != NULL) { /* Note that the boolean is inverted */ pw_properties_set(capture_props, PW_KEY_STREAM_DONT_REMIX, pw_properties_parse_bool(str) ? "false" : "true"); - pw_properties_set(props, "remix", NULL); + free(str); } if (pw_properties_get(capture_props, PW_KEY_NODE_PASSIVE) == NULL) diff --git a/src/modules/module-protocol-pulse/modules/module-simple-protocol-tcp.c b/src/modules/module-protocol-pulse/modules/module-simple-protocol-tcp.c index 53e4bf7b7..0ff8454e1 100644 --- a/src/modules/module-protocol-pulse/modules/module-simple-protocol-tcp.c +++ b/src/modules/module-protocol-pulse/modules/module-simple-protocol-tcp.c @@ -132,7 +132,8 @@ struct module *create_module_simple_protocol_tcp(struct impl *impl, const char * struct module *module; struct module_simple_protocol_tcp_data *d; struct pw_properties *props = NULL, *module_props = NULL; - const char *str, *port, *listen; + const char *port, *listen; + char *str; int res; props = pw_properties_new_dict(&SPA_DICT_INIT_ARRAY(module_simple_protocol_tcp_info)); @@ -151,23 +152,24 @@ struct module *create_module_simple_protocol_tcp(struct impl *impl, const char * pw_properties_move(module_props, "audio.rate", props, "rate", NULL); - if ((str = pw_properties_get(props, "format")) != NULL) { + if ((str = pw_properties_steal(props, "format")) != NULL) { pw_properties_set(module_props, "audio.format", format_id2name(format_paname2id(str, strlen(str)))); - pw_properties_set(props, "format", NULL); + free(str); } pw_properties_move(module_props, "audio.channels", props, "channels", NULL); pw_properties_move(module_props, "playback", props, "playback", NULL); pw_properties_move(module_props, "capture", props, "record", NULL); - if ((str = pw_properties_get(props, "source")) != NULL) { + if ((str = pw_properties_steal(props, "source")) != NULL) { if (pw_endswith(str, ".monitor")) { pw_properties_setf(module_props, "capture.node", "%.*s", (int)strlen(str)-8, str); } else { pw_properties_set(module_props, "capture.node", str); } - pw_properties_set(props, "source", NULL); + + free(str); } pw_properties_move(module_props, "playback.node", props, "sink", NULL); diff --git a/src/modules/module-protocol-pulse/modules/module-tunnel-sink.c b/src/modules/module-protocol-pulse/modules/module-tunnel-sink.c index 73a9cb5f5..27485fd3c 100644 --- a/src/modules/module-protocol-pulse/modules/module-tunnel-sink.c +++ b/src/modules/module-protocol-pulse/modules/module-tunnel-sink.c @@ -146,8 +146,9 @@ struct module *create_module_tunnel_sink(struct impl *impl, const char *argument struct module *module; struct module_tunnel_sink_data *d; struct pw_properties *props = NULL, *stream_props = NULL; - const char *str, *server, *remote_sink_name; + const char *server, *remote_sink_name; struct spa_audio_info_raw info = { 0 }; + char *str; int res; props = pw_properties_new_dict(&SPA_DICT_INIT_ARRAY(module_tunnel_sink_info)); @@ -174,17 +175,19 @@ struct module *create_module_tunnel_sink(struct impl *impl, const char *argument remote_sink_name ? remote_sink_name : ""); pw_properties_set(stream_props, PW_KEY_MEDIA_CLASS, "Audio/Sink"); - if ((str = pw_properties_get(props, "sink_name")) != NULL) { + if ((str = pw_properties_steal(props, "sink_name")) != NULL) { pw_properties_set(stream_props, PW_KEY_NODE_NAME, str); - pw_properties_set(props, "sink_name", NULL); + free(str); } else { pw_properties_setf(stream_props, PW_KEY_NODE_NAME, "tunnel-sink.%s", server); } - if ((str = pw_properties_get(props, "sink_properties")) != NULL) { + + if ((str = pw_properties_steal(props, "sink_properties")) != NULL) { module_args_add_props(stream_props, str); - pw_properties_set(props, "sink_properties", NULL); + free(str); } + if (module_args_to_audioinfo(impl, props, &info) < 0) { res = -EINVAL; goto out; diff --git a/src/modules/module-protocol-pulse/modules/module-tunnel-source.c b/src/modules/module-protocol-pulse/modules/module-tunnel-source.c index 7b4fe45b6..be07dd871 100644 --- a/src/modules/module-protocol-pulse/modules/module-tunnel-source.c +++ b/src/modules/module-protocol-pulse/modules/module-tunnel-source.c @@ -146,8 +146,9 @@ struct module *create_module_tunnel_source(struct impl *impl, const char *argume struct module *module; struct module_tunnel_source_data *d; struct pw_properties *props = NULL, *stream_props = NULL; - const char *str, *server, *remote_source_name; + const char *server, *remote_source_name; struct spa_audio_info_raw info = { 0 }; + char *str; int res; props = pw_properties_new_dict(&SPA_DICT_INIT_ARRAY(module_tunnel_source_info)); @@ -174,17 +175,19 @@ struct module *create_module_tunnel_source(struct impl *impl, const char *argume remote_source_name ? remote_source_name : ""); pw_properties_set(stream_props, PW_KEY_MEDIA_CLASS, "Audio/Source"); - if ((str = pw_properties_get(props, "source_name")) != NULL) { + if ((str = pw_properties_steal(props, "source_name")) != NULL) { pw_properties_set(stream_props, PW_KEY_NODE_NAME, str); - pw_properties_set(props, "source_name", NULL); + free(str); } else { pw_properties_setf(stream_props, PW_KEY_NODE_NAME, "tunnel-source.%s", server); } - if ((str = pw_properties_get(props, "source_properties")) != NULL) { + + if ((str = pw_properties_steal(props, "source_properties")) != NULL) { module_args_add_props(stream_props, str); - pw_properties_set(props, "source_properties", NULL); + free(str); } + if (module_args_to_audioinfo(impl, props, &info) < 0) { res = -EINVAL; goto out;