mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-06-06 03:02:54 -04:00
pulse-server: use pw_properties_steal() in modules
This commit is contained in:
parent
33e3e47fb6
commit
525017cb02
13 changed files with 97 additions and 89 deletions
|
|
@ -411,8 +411,7 @@ struct module *create_module_combine_sink(struct impl *impl, const char *argumen
|
||||||
struct module *module;
|
struct module *module;
|
||||||
struct module_combine_sink_data *d;
|
struct module_combine_sink_data *d;
|
||||||
struct pw_properties *props = NULL;
|
struct pw_properties *props = NULL;
|
||||||
const char *str;
|
char *str, *sink_name = NULL, **sink_names = NULL;
|
||||||
char *sink_name = NULL, **sink_names = NULL;
|
|
||||||
struct spa_audio_info_raw info = { 0 };
|
struct spa_audio_info_raw info = { 0 };
|
||||||
int i, n, res;
|
int i, n, res;
|
||||||
|
|
||||||
|
|
@ -424,16 +423,12 @@ struct module *create_module_combine_sink(struct impl *impl, const char *argumen
|
||||||
if (argument)
|
if (argument)
|
||||||
module_args_add_props(props, argument);
|
module_args_add_props(props, argument);
|
||||||
|
|
||||||
if ((str = pw_properties_get(props, "sink_name")) != NULL) {
|
if ((sink_name = pw_properties_steal(props, "sink_name")) == NULL)
|
||||||
sink_name = strdup(str);
|
|
||||||
pw_properties_set(props, "sink_name", NULL);
|
|
||||||
} else {
|
|
||||||
sink_name = strdup("combined");
|
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);
|
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)
|
if (pw_properties_set(props, "adjust_time", NULL) != 0)
|
||||||
|
|
|
||||||
|
|
@ -160,8 +160,8 @@ struct module *create_module_echo_cancel(struct impl *impl, const char *argument
|
||||||
struct module *module;
|
struct module *module;
|
||||||
struct module_echo_cancel_data *d;
|
struct module_echo_cancel_data *d;
|
||||||
struct pw_properties *props = NULL, *aec_props = NULL, *sink_props = NULL, *source_props = NULL;
|
struct pw_properties *props = NULL, *aec_props = NULL, *sink_props = NULL, *source_props = NULL;
|
||||||
const char *str;
|
|
||||||
struct spa_audio_info_raw info = { 0 };
|
struct spa_audio_info_raw info = { 0 };
|
||||||
|
char *str;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
props = pw_properties_new_dict(&SPA_DICT_INIT_ARRAY(module_echo_cancel_info));
|
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(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");
|
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")) {
|
if (pw_endswith(str, ".monitor")) {
|
||||||
pw_properties_setf(source_props, PW_KEY_NODE_TARGET,
|
pw_properties_setf(source_props, PW_KEY_NODE_TARGET,
|
||||||
"%.*s", (int)strlen(str)-8, str);
|
"%.*s", (int)strlen(str)-8, str);
|
||||||
} else {
|
} else {
|
||||||
pw_properties_set(source_props, PW_KEY_NODE_TARGET, str);
|
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);
|
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;
|
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);
|
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);
|
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);
|
pw_properties_move(aec_props, "aec.method", props, "aec_method", NULL);
|
||||||
|
|
|
||||||
|
|
@ -167,9 +167,9 @@ struct module *create_module_ladspa_sink(struct impl *impl, const char *argument
|
||||||
struct module *module;
|
struct module *module;
|
||||||
struct module_ladspa_sink_data *d;
|
struct module_ladspa_sink_data *d;
|
||||||
struct pw_properties *props = NULL, *playback_props = NULL, *capture_props = NULL;
|
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 capture_info = { 0 };
|
||||||
struct spa_audio_info_raw playback_info = { 0 };
|
struct spa_audio_info_raw playback_info = { 0 };
|
||||||
|
char *str;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
props = pw_properties_new_dict(&SPA_DICT_INIT_ARRAY(module_ladspa_sink_info));
|
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);
|
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);
|
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)
|
if (pw_properties_get(capture_props, PW_KEY_MEDIA_CLASS) == NULL)
|
||||||
pw_properties_set(capture_props, PW_KEY_MEDIA_CLASS, "Audio/Sink");
|
pw_properties_set(capture_props, PW_KEY_MEDIA_CLASS, "Audio/Sink");
|
||||||
|
|
||||||
if ((str = pw_properties_get(props, "master")) != NULL ||
|
if ((str = pw_properties_steal(props, "master")) != NULL ||
|
||||||
(str = pw_properties_get(props, "sink_master")) != NULL) {
|
(str = pw_properties_steal(props, "sink_master")) != NULL) {
|
||||||
pw_properties_set(playback_props, PW_KEY_NODE_TARGET, str);
|
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) {
|
if (module_args_to_audioinfo(impl, props, &capture_info) < 0) {
|
||||||
|
|
|
||||||
|
|
@ -167,9 +167,9 @@ struct module *create_module_ladspa_source(struct impl *impl, const char *argume
|
||||||
struct module *module;
|
struct module *module;
|
||||||
struct module_ladspa_source_data *d;
|
struct module_ladspa_source_data *d;
|
||||||
struct pw_properties *props = NULL, *playback_props = NULL, *capture_props = NULL;
|
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 capture_info = { 0 };
|
||||||
struct spa_audio_info_raw playback_info = { 0 };
|
struct spa_audio_info_raw playback_info = { 0 };
|
||||||
|
char *str;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
props = pw_properties_new_dict(&SPA_DICT_INIT_ARRAY(module_ladspa_source_info));
|
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);
|
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);
|
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)
|
if (pw_properties_get(playback_props, PW_KEY_MEDIA_CLASS) == NULL)
|
||||||
pw_properties_set(playback_props, PW_KEY_MEDIA_CLASS, "Audio/Source");
|
pw_properties_set(playback_props, PW_KEY_MEDIA_CLASS, "Audio/Source");
|
||||||
|
|
||||||
if ((str = pw_properties_get(props, "master")) != NULL ||
|
if ((str = pw_properties_steal(props, "master")) != NULL ||
|
||||||
(str = pw_properties_get(props, "source_master")) != NULL) {
|
(str = pw_properties_steal(props, "source_master")) != NULL) {
|
||||||
pw_properties_set(playback_props, PW_KEY_NODE_TARGET, str);
|
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) {
|
if (module_args_to_audioinfo(impl, props, &capture_info) < 0) {
|
||||||
|
|
|
||||||
|
|
@ -138,8 +138,8 @@ struct module *create_module_loopback(struct impl *impl, const char *argument)
|
||||||
struct module *module;
|
struct module *module;
|
||||||
struct module_loopback_data *d;
|
struct module_loopback_data *d;
|
||||||
struct pw_properties *props = NULL, *playback_props = NULL, *capture_props = NULL;
|
struct pw_properties *props = NULL, *playback_props = NULL, *capture_props = NULL;
|
||||||
const char *str;
|
|
||||||
struct spa_audio_info_raw info = { 0 };
|
struct spa_audio_info_raw info = { 0 };
|
||||||
|
char *str;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
props = pw_properties_new_dict(&SPA_DICT_INIT_ARRAY(module_loopback_info));
|
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
|
* 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")) {
|
if (pw_endswith(str, ".monitor")) {
|
||||||
pw_properties_setf(capture_props, PW_KEY_NODE_TARGET,
|
pw_properties_setf(capture_props, PW_KEY_NODE_TARGET,
|
||||||
"%.*s", (int)strlen(str)-8, str);
|
"%.*s", (int)strlen(str)-8, str);
|
||||||
} else {
|
} else {
|
||||||
pw_properties_set(capture_props, PW_KEY_NODE_TARGET, str);
|
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);
|
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(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);
|
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 */
|
/* Note that the boolean is inverted */
|
||||||
pw_properties_set(playback_props, PW_KEY_STREAM_DONT_REMIX,
|
pw_properties_set(playback_props, PW_KEY_STREAM_DONT_REMIX,
|
||||||
pw_properties_parse_bool(str) ? "false" : "true");
|
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 */
|
/* 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(capture_props, PW_KEY_NODE_LATENCY, "%s/2000", str);
|
||||||
pw_properties_setf(playback_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 {
|
} else {
|
||||||
pw_properties_set(capture_props, PW_KEY_NODE_LATENCY, "100/1000");
|
pw_properties_set(capture_props, PW_KEY_NODE_LATENCY, "100/1000");
|
||||||
pw_properties_set(playback_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);
|
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);
|
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));
|
module = module_new(impl, &module_loopback_methods, sizeof(*d));
|
||||||
|
|
|
||||||
|
|
@ -129,9 +129,9 @@ struct module *create_module_null_sink(struct impl *impl, const char *argument)
|
||||||
struct module *module;
|
struct module *module;
|
||||||
struct module_null_sink_data *d;
|
struct module_null_sink_data *d;
|
||||||
struct pw_properties *props = NULL;
|
struct pw_properties *props = NULL;
|
||||||
const char *str;
|
|
||||||
struct spa_audio_info_raw info = { 0 };
|
struct spa_audio_info_raw info = { 0 };
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
char *str;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
props = pw_properties_new_dict(&SPA_DICT_INIT_ARRAY(module_null_sink_info));
|
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");
|
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);
|
module_args_add_props(props, str);
|
||||||
pw_properties_set(props, "sink_properties", NULL);
|
free(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (module_args_to_audioinfo(impl, props, &info) < 0) {
|
if (module_args_to_audioinfo(impl, props, &info) < 0) {
|
||||||
|
|
|
||||||
|
|
@ -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 pw_properties *props = NULL, *capture_props = NULL;
|
||||||
struct spa_audio_info_raw info = { 0 };
|
struct spa_audio_info_raw info = { 0 };
|
||||||
struct stat st;
|
struct stat st;
|
||||||
const char *str;
|
|
||||||
char *filename = NULL;
|
char *filename = NULL;
|
||||||
bool do_unlink_fifo;
|
bool do_unlink_fifo;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
|
char *str;
|
||||||
|
|
||||||
props = pw_properties_new_dict(&SPA_DICT_INIT_ARRAY(module_pipesink_info));
|
props = pw_properties_new_dict(&SPA_DICT_INIT_ARRAY(module_pipesink_info));
|
||||||
capture_props = pw_properties_new(NULL, NULL);
|
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;
|
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));
|
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);
|
pw_properties_move(capture_props, PW_KEY_NODE_NAME, props, "sink_name", NULL);
|
||||||
|
|
||||||
if ((str = pw_properties_get(props, "file")) != NULL) {
|
if ((filename = pw_properties_steal(props, "file")) == NULL)
|
||||||
filename = strdup(str);
|
|
||||||
pw_properties_set(props, "file", NULL);
|
|
||||||
} else {
|
|
||||||
filename = strdup(DEFAULT_FILE_NAME);
|
filename = strdup(DEFAULT_FILE_NAME);
|
||||||
}
|
|
||||||
|
|
||||||
do_unlink_fifo = false;
|
do_unlink_fifo = false;
|
||||||
if (mkfifo(filename, 0666) < 0) {
|
if (mkfifo(filename, 0666) < 0) {
|
||||||
|
|
@ -293,7 +289,7 @@ struct module *create_module_pipe_sink(struct impl *impl, const char *argument)
|
||||||
goto out;
|
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");
|
pw_properties_set(props, PW_KEY_MEDIA_CLASS, "Audio/Sink");
|
||||||
|
|
||||||
module = module_new(impl, &module_pipesink_methods, sizeof(*d));
|
module = module_new(impl, &module_pipesink_methods, sizeof(*d));
|
||||||
|
|
|
||||||
|
|
@ -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 pw_properties *props = NULL, *playback_props = NULL;
|
||||||
struct spa_audio_info_raw info = { 0 };
|
struct spa_audio_info_raw info = { 0 };
|
||||||
struct stat st;
|
struct stat st;
|
||||||
const char *str;
|
|
||||||
char *filename = NULL;
|
char *filename = NULL;
|
||||||
int stride, res = 0;
|
int stride, res = 0;
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
|
char *str;
|
||||||
|
|
||||||
props = pw_properties_new_dict(&SPA_DICT_INIT_ARRAY(module_pipesource_info));
|
props = pw_properties_new_dict(&SPA_DICT_INIT_ARRAY(module_pipesource_info));
|
||||||
playback_props = pw_properties_new(NULL, NULL);
|
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;
|
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));
|
info.format = format_paname2id(str, strlen(str));
|
||||||
pw_properties_set(props, "format", NULL);
|
free(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (info.format) {
|
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);
|
pw_properties_move(playback_props, PW_KEY_NODE_NAME, props, "source_name", NULL);
|
||||||
|
|
||||||
if ((str = pw_properties_get(props, "file")) != NULL) {
|
if ((filename = pw_properties_steal(props, "file")) == NULL)
|
||||||
filename = strdup(str);
|
|
||||||
pw_properties_set(props, "file", NULL);
|
|
||||||
} else {
|
|
||||||
filename = strdup(DEFAULT_FILE_NAME);
|
filename = strdup(DEFAULT_FILE_NAME);
|
||||||
}
|
|
||||||
|
|
||||||
if (mkfifo(filename, 0666) < 0) {
|
if (mkfifo(filename, 0666) < 0) {
|
||||||
if (errno != EEXIST) {
|
if (errno != EEXIST) {
|
||||||
|
|
@ -328,7 +324,7 @@ struct module *create_module_pipe_source(struct impl *impl, const char *argument
|
||||||
goto out;
|
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");
|
pw_properties_set(props, PW_KEY_MEDIA_CLASS, "Audio/Source");
|
||||||
|
|
||||||
module = module_new(impl, &module_pipesource_methods, sizeof(*d));
|
module = module_new(impl, &module_pipesource_methods, sizeof(*d));
|
||||||
|
|
|
||||||
|
|
@ -146,9 +146,9 @@ struct module *create_module_remap_sink(struct impl *impl, const char *argument)
|
||||||
struct module *module;
|
struct module *module;
|
||||||
struct module_remap_sink_data *d;
|
struct module_remap_sink_data *d;
|
||||||
struct pw_properties *props = NULL, *playback_props = NULL, *capture_props = NULL;
|
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 capture_info = { 0 };
|
||||||
struct spa_audio_info_raw playback_info = { 0 };
|
struct spa_audio_info_raw playback_info = { 0 };
|
||||||
|
char *str;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
props = pw_properties_new_dict(&SPA_DICT_INIT_ARRAY(module_remap_sink_info));
|
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);
|
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);
|
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");
|
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;
|
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;
|
struct channel_map map;
|
||||||
|
|
||||||
channel_map_parse(str, &map);
|
channel_map_parse(str, &map);
|
||||||
if (map.channels == 0 || map.channels > SPA_AUDIO_MAX_CHANNELS) {
|
if (map.channels == 0 || map.channels > SPA_AUDIO_MAX_CHANNELS) {
|
||||||
pw_log_error("invalid channel_map '%s'", str);
|
pw_log_error("invalid channel_map '%s'", str);
|
||||||
|
free(str);
|
||||||
res = -EINVAL;
|
res = -EINVAL;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
channel_map_to_positions(&map, playback_info.position);
|
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(&capture_info, capture_props);
|
||||||
position_to_props(&playback_info, playback_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 */
|
/* Note that the boolean is inverted */
|
||||||
pw_properties_set(playback_props, PW_KEY_STREAM_DONT_REMIX,
|
pw_properties_set(playback_props, PW_KEY_STREAM_DONT_REMIX,
|
||||||
pw_properties_parse_bool(str) ? "false" : "true");
|
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)
|
if (pw_properties_get(playback_props, PW_KEY_NODE_PASSIVE) == NULL)
|
||||||
|
|
|
||||||
|
|
@ -146,9 +146,9 @@ struct module *create_module_remap_source(struct impl *impl, const char *argumen
|
||||||
struct module *module;
|
struct module *module;
|
||||||
struct module_remap_source_data *d;
|
struct module_remap_source_data *d;
|
||||||
struct pw_properties *props = NULL, *playback_props = NULL, *capture_props = NULL;
|
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 capture_info = { 0 };
|
||||||
struct spa_audio_info_raw playback_info = { 0 };
|
struct spa_audio_info_raw playback_info = { 0 };
|
||||||
|
char *str;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
props = pw_properties_new_dict(&SPA_DICT_INIT_ARRAY(module_remap_source_info));
|
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);
|
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);
|
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");
|
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;
|
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;
|
struct channel_map map;
|
||||||
|
|
||||||
channel_map_parse(str, &map);
|
channel_map_parse(str, &map);
|
||||||
if (map.channels == 0 || map.channels > SPA_AUDIO_MAX_CHANNELS) {
|
if (map.channels == 0 || map.channels > SPA_AUDIO_MAX_CHANNELS) {
|
||||||
pw_log_error("invalid channel_map '%s'", str);
|
pw_log_error("invalid channel_map '%s'", str);
|
||||||
|
free(str);
|
||||||
res = -EINVAL;
|
res = -EINVAL;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
channel_map_to_positions(&map, capture_info.position);
|
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(&playback_info, playback_props);
|
||||||
position_to_props(&capture_info, capture_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 */
|
/* Note that the boolean is inverted */
|
||||||
pw_properties_set(capture_props, PW_KEY_STREAM_DONT_REMIX,
|
pw_properties_set(capture_props, PW_KEY_STREAM_DONT_REMIX,
|
||||||
pw_properties_parse_bool(str) ? "false" : "true");
|
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)
|
if (pw_properties_get(capture_props, PW_KEY_NODE_PASSIVE) == NULL)
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,8 @@ struct module *create_module_simple_protocol_tcp(struct impl *impl, const char *
|
||||||
struct module *module;
|
struct module *module;
|
||||||
struct module_simple_protocol_tcp_data *d;
|
struct module_simple_protocol_tcp_data *d;
|
||||||
struct pw_properties *props = NULL, *module_props = NULL;
|
struct pw_properties *props = NULL, *module_props = NULL;
|
||||||
const char *str, *port, *listen;
|
const char *port, *listen;
|
||||||
|
char *str;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
props = pw_properties_new_dict(&SPA_DICT_INIT_ARRAY(module_simple_protocol_tcp_info));
|
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);
|
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(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, "audio.channels", props, "channels", NULL);
|
||||||
pw_properties_move(module_props, "playback", props, "playback", NULL);
|
pw_properties_move(module_props, "playback", props, "playback", NULL);
|
||||||
pw_properties_move(module_props, "capture", props, "record", 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")) {
|
if (pw_endswith(str, ".monitor")) {
|
||||||
pw_properties_setf(module_props, "capture.node",
|
pw_properties_setf(module_props, "capture.node",
|
||||||
"%.*s", (int)strlen(str)-8, str);
|
"%.*s", (int)strlen(str)-8, str);
|
||||||
} else {
|
} else {
|
||||||
pw_properties_set(module_props, "capture.node", str);
|
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);
|
pw_properties_move(module_props, "playback.node", props, "sink", NULL);
|
||||||
|
|
|
||||||
|
|
@ -146,8 +146,9 @@ struct module *create_module_tunnel_sink(struct impl *impl, const char *argument
|
||||||
struct module *module;
|
struct module *module;
|
||||||
struct module_tunnel_sink_data *d;
|
struct module_tunnel_sink_data *d;
|
||||||
struct pw_properties *props = NULL, *stream_props = NULL;
|
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 };
|
struct spa_audio_info_raw info = { 0 };
|
||||||
|
char *str;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
props = pw_properties_new_dict(&SPA_DICT_INIT_ARRAY(module_tunnel_sink_info));
|
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 : "");
|
remote_sink_name ? remote_sink_name : "");
|
||||||
pw_properties_set(stream_props, PW_KEY_MEDIA_CLASS, "Audio/Sink");
|
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(stream_props, PW_KEY_NODE_NAME, str);
|
||||||
pw_properties_set(props, "sink_name", NULL);
|
free(str);
|
||||||
} else {
|
} else {
|
||||||
pw_properties_setf(stream_props, PW_KEY_NODE_NAME,
|
pw_properties_setf(stream_props, PW_KEY_NODE_NAME,
|
||||||
"tunnel-sink.%s", server);
|
"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);
|
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) {
|
if (module_args_to_audioinfo(impl, props, &info) < 0) {
|
||||||
res = -EINVAL;
|
res = -EINVAL;
|
||||||
goto out;
|
goto out;
|
||||||
|
|
|
||||||
|
|
@ -146,8 +146,9 @@ struct module *create_module_tunnel_source(struct impl *impl, const char *argume
|
||||||
struct module *module;
|
struct module *module;
|
||||||
struct module_tunnel_source_data *d;
|
struct module_tunnel_source_data *d;
|
||||||
struct pw_properties *props = NULL, *stream_props = NULL;
|
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 };
|
struct spa_audio_info_raw info = { 0 };
|
||||||
|
char *str;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
props = pw_properties_new_dict(&SPA_DICT_INIT_ARRAY(module_tunnel_source_info));
|
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 : "");
|
remote_source_name ? remote_source_name : "");
|
||||||
pw_properties_set(stream_props, PW_KEY_MEDIA_CLASS, "Audio/Source");
|
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(stream_props, PW_KEY_NODE_NAME, str);
|
||||||
pw_properties_set(props, "source_name", NULL);
|
free(str);
|
||||||
} else {
|
} else {
|
||||||
pw_properties_setf(stream_props, PW_KEY_NODE_NAME,
|
pw_properties_setf(stream_props, PW_KEY_NODE_NAME,
|
||||||
"tunnel-source.%s", server);
|
"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);
|
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) {
|
if (module_args_to_audioinfo(impl, props, &info) < 0) {
|
||||||
res = -EINVAL;
|
res = -EINVAL;
|
||||||
goto out;
|
goto out;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue