Apply .editorconfig

This commit is contained in:
Frank Krick 2025-08-16 21:30:43 -04:00
parent 255bf4cdb4
commit 5783cf865f

View file

@ -1110,20 +1110,25 @@ static const struct spa_dict_item module_props[] = {
{PW_KEY_MODULE_DESCRIPTION, "Create filter chain streams"}, {PW_KEY_MODULE_DESCRIPTION, "Create filter chain streams"},
{ {
PW_KEY_MODULE_USAGE, PW_KEY_MODULE_USAGE,
" ( remote.name=<remote> ) " "( node.latency=<latency as fraction> ) " " ( remote.name=<remote> ) "
"( node.latency=<latency as fraction> ) "
"( node.description=<description of the nodes> ) " "( node.description=<description of the nodes> ) "
"( audio.rate=<sample rate> ) " "( audio.channels=<number of channels> ) " "( audio.rate=<sample rate> ) "
"( audio.position=<channel map> ) " "filter.graph = [ " " nodes = [ " "( audio.channels=<number of channels> ) "
" { " " type = <ladspa | lv2 | builtin | sofa> " "( audio.position=<channel map> ) " "filter.graph = [ "
" nodes = [ " " { "
" type = <ladspa | lv2 | builtin | sofa> "
" name = <name> " " plugin = <plugin> " " name = <name> " " plugin = <plugin> "
" label = <label> " " config = { " " label = <label> " " config = { "
" <configkey> = <value> ... " " } " " <configkey> = <value> ... " " } "
" control = { " " control = { "
" <controlname|controlindex> = <value> ... " " } " " <controlname|controlindex> = <value> ... "
" } " " ] " " links = [ " " } " " } " " ] " " links = [ "
" { output = <portname> input = <portname> } ... " " ] " " { output = <portname> input = <portname> } ... "
" inputs = [ <portname> ... ] " " outputs = [ <portname> ... ] " "] " " ] " " inputs = [ <portname> ... ] "
"( capture.props=<properties> ) " "( playback.props=<properties> ) " " outputs = [ <portname> ... ] " "] "
"( capture.props=<properties> ) "
"( playback.props=<properties> ) "
}, },
{PW_KEY_MODULE_VERSION, PACKAGE_VERSION}, {PW_KEY_MODULE_VERSION, PACKAGE_VERSION},
}; };
@ -1204,7 +1209,8 @@ static void capture_process(void *d) {
pw_log_debug("playback trigger error: %s", spa_strerror(res)); pw_log_debug("playback trigger error: %s", spa_strerror(res));
while (true) { while (true) {
struct pw_buffer *t; struct pw_buffer *t;
if ((t = pw_stream_dequeue_buffer(impl->capture)) == NULL) break; if ((t = pw_stream_dequeue_buffer(impl->capture)) ==
NULL) break;
/* playback part is not ready, consume, discard and recycle /* playback part is not ready, consume, discard and recycle
* the capture buffers */ * the capture buffers */
pw_stream_queue_buffer(impl->capture, t); pw_stream_queue_buffer(impl->capture, t);
@ -1226,22 +1232,29 @@ static void control_process(void *d) {
struct pw_buffer *control = pw_stream_dequeue_buffer(impl->control); struct pw_buffer *control = pw_stream_dequeue_buffer(impl->control);
if (control == NULL) goto done; if (control == NULL) goto done;
if (control->buffer->n_datas > 0) { if (control->buffer->n_datas > 0) {
struct spa_pod *pod = spa_pod_from_data(control->buffer->datas[0].data, struct spa_pod *pod = spa_pod_from_data(
control->buffer->datas[0].data,
control->buffer->datas[0].maxsize, control->buffer->datas[0].maxsize,
control->buffer->datas[0].chunk-> control->buffer->datas[0].chunk->offset,
offset, control->buffer->datas[0].chunk->size);
control->buffer->datas[0].chunk->
size);
if (spa_pod_is_sequence(pod)) { if (spa_pod_is_sequence(pod)) {
struct spa_pod_sequence *sequence = (struct spa_pod_sequence*)pod; struct spa_pod_sequence *sequence = (struct
spa_pod_sequence*)pod;
struct spa_pod_control *pod_control; struct spa_pod_control *pod_control;
SPA_POD_SEQUENCE_FOREACH(sequence, pod_control) { SPA_POD_SEQUENCE_FOREACH(sequence, pod_control) {
if (pod_control->type == SPA_CONTROL_Properties) { if (pod_control->type ==
struct pw_loop *loop = pw_context_get_main_loop(impl->context); SPA_CONTROL_Properties) {
pw_loop_invoke(loop, apply_props, 0, &pod_control->value, struct pw_loop *loop =
SPA_POD_SIZE(&pod_control->value), false, impl); pw_context_get_main_loop(
impl->context);
pw_loop_invoke(
loop, apply_props, 0,
&pod_control->value,
SPA_POD_SIZE(
&pod_control->value),
false, impl);
} }
} }
} }
@ -1263,7 +1276,8 @@ static void playback_process(void *d) {
in = NULL; in = NULL;
while (true) { while (true) {
struct pw_buffer *t; struct pw_buffer *t;
if ((t = pw_stream_dequeue_buffer(impl->capture)) == NULL) break; if ((t = pw_stream_dequeue_buffer(impl->capture)) == NULL) break
;
if (in) pw_stream_queue_buffer(impl->capture, in); if (in) pw_stream_queue_buffer(impl->capture, in);
in = t; in = t;
} }
@ -1303,11 +1317,13 @@ static void playback_process(void *d) {
} }
for (; i < impl->n_outputs; i++) cout[i] = NULL; for (; i < impl->n_outputs; i++) cout[i] = NULL;
pw_log_trace_fp("%p: stride:%d size:%d requested:%"PRIu64" (%"PRIu64")", impl, pw_log_trace_fp("%p: stride:%d size:%d requested:%"PRIu64" (%"PRIu64")",
stride, data_size, out->requested, out->requested * stride); impl, stride, data_size, out->requested,
out->requested * stride);
if (impl->graph_active) spa_filter_graph_process( if (impl->graph_active)
impl->graph, cin, cout, data_size / sizeof(float)); spa_filter_graph_process(impl->graph, cin, cout,
data_size / sizeof(float));
done: done:
if (in != NULL) pw_stream_queue_buffer(impl->capture, in); if (in != NULL) pw_stream_queue_buffer(impl->capture, in);
@ -1323,10 +1339,12 @@ static int activate_graph(struct impl *impl) {
snprintf(rate, sizeof(rate), "%lu", impl->rate); snprintf(rate, sizeof(rate), "%lu", impl->rate);
res = spa_filter_graph_activate(impl->graph, res = spa_filter_graph_activate(impl->graph,
&SPA_DICT_ITEMS( &SPA_DICT_ITEMS(
SPA_DICT_ITEM(SPA_KEY_AUDIO_RATE, rate))); SPA_DICT_ITEM(SPA_KEY_AUDIO_RATE
, rate)));
if (res >= 0) { if (res >= 0) {
struct pw_loop *data_loop = pw_stream_get_data_loop(impl->playback); struct pw_loop *data_loop = pw_stream_get_data_loop(
impl->playback);
pw_loop_lock(data_loop); pw_loop_lock(data_loop);
impl->graph_active = true; impl->graph_active = true;
pw_loop_unlock(data_loop); pw_loop_unlock(data_loop);
@ -1413,8 +1431,8 @@ static void param_process_latency_changed(struct impl *impl,
if (param == NULL) if (param == NULL)
spa_zero(process_latency); spa_zero(process_latency);
else if (spa_process_latency_parse(param, &process_latency) < 0) return; else if (spa_process_latency_parse(param, &process_latency) < 0) return;
if (spa_process_latency_info_compare(&impl->process_latency, &process_latency) if (spa_process_latency_info_compare(&impl->process_latency,
== 0) return; &process_latency) == 0) return;
impl->process_latency = process_latency; impl->process_latency = process_latency;
update_latencies(impl, true); update_latencies(impl, true);
@ -1428,8 +1446,8 @@ static void param_tag_changed(struct impl *impl, const struct spa_pod *param,
if (param == 0 || spa_tag_parse(param, &tag, &state) < 0) return; if (param == 0 || spa_tag_parse(param, &tag, &state) < 0) return;
if (tag.direction == SPA_DIRECTION_INPUT) pw_stream_update_params( if (tag.direction == SPA_DIRECTION_INPUT)
impl->capture, params, 1); pw_stream_update_params(impl->capture, params, 1);
else pw_stream_update_params(impl->playback, params, 1); else pw_stream_update_params(impl->playback, params, 1);
} }
@ -1442,10 +1460,12 @@ static void capture_state_changed(void *data, enum pw_stream_state old,
case PW_STREAM_STATE_PAUSED: case PW_STREAM_STATE_PAUSED:
pw_stream_flush(impl->capture, false); pw_stream_flush(impl->capture, false);
break; break;
case PW_STREAM_STATE_UNCONNECTED: pw_log_info("module %p: unconnected", impl); case PW_STREAM_STATE_UNCONNECTED: pw_log_info(
"module %p: unconnected", impl);
pw_impl_module_schedule_destroy(impl->module); pw_impl_module_schedule_destroy(impl->module);
break; break;
case PW_STREAM_STATE_ERROR: pw_log_info("module %p: error: %s", impl, error); case PW_STREAM_STATE_ERROR: pw_log_info("module %p: error: %s", impl,
error);
break; break;
case PW_STREAM_STATE_STREAMING: default: case PW_STREAM_STATE_STREAMING: default:
break; break;
@ -1476,18 +1496,21 @@ static void param_changed(struct impl *impl, uint32_t id,
struct spa_audio_info_raw info; struct spa_audio_info_raw info;
spa_zero(info); spa_zero(info);
if (param == NULL) { if (param == NULL) {
pw_log_info("module %p: filter deactivate", impl); pw_log_info("module %p: filter deactivate",
if (direction == SPA_DIRECTION_OUTPUT) deactivate_graph(impl); impl);
if (direction == SPA_DIRECTION_OUTPUT)
deactivate_graph(impl);
impl->rate = 0; impl->rate = 0;
} else { } else {
if ((res = spa_format_audio_raw_parse(param, &info)) < 0) goto error; if ((res = spa_format_audio_raw_parse(
param, &info)) < 0) goto error;
} }
impl->info = info; impl->info = info;
break; break;
} }
case SPA_PARAM_Props: case SPA_PARAM_Props:
if (param != NULL) if (param != NULL) spa_filter_graph_set_props(
spa_filter_graph_set_props(impl->graph, direction, param); impl->graph, direction, param);
break; break;
case SPA_PARAM_Latency: case SPA_PARAM_Latency:
param_latency_changed(impl, param, direction); param_latency_changed(impl, param, direction);
@ -1503,8 +1526,10 @@ static void param_changed(struct impl *impl, uint32_t id,
error: error:
pw_stream_set_error( pw_stream_set_error(
direction == SPA_DIRECTION_INPUT ? impl->capture : impl->playback, res, direction == SPA_DIRECTION_INPUT
"can't start graph: %s", spa_strerror(res)); ? impl->capture
: impl->playback, res, "can't start graph: %s",
spa_strerror(res));
} }
static void capture_param_changed(void *data, uint32_t id, static void capture_param_changed(void *data, uint32_t id,
@ -1517,7 +1542,8 @@ static void capture_param_changed(void *data, uint32_t id,
static const struct pw_stream_events in_stream_events = { static const struct pw_stream_events in_stream_events = {
PW_VERSION_STREAM_EVENTS, .destroy = capture_destroy, PW_VERSION_STREAM_EVENTS, .destroy = capture_destroy,
.process = capture_process, .io_changed = io_changed, .process = capture_process, .io_changed = io_changed,
.state_changed = capture_state_changed, .param_changed = capture_param_changed .state_changed = capture_state_changed,
.param_changed = capture_param_changed
}; };
static void playback_state_changed(void *data, enum pw_stream_state old, static void playback_state_changed(void *data, enum pw_stream_state old,
@ -1531,17 +1557,20 @@ static void playback_state_changed(void *data, enum pw_stream_state old,
pw_stream_flush(impl->playback, false); pw_stream_flush(impl->playback, false);
reset_graph(impl); reset_graph(impl);
break; break;
case PW_STREAM_STATE_UNCONNECTED: pw_log_info("module %p: unconnected", impl); case PW_STREAM_STATE_UNCONNECTED: pw_log_info(
"module %p: unconnected", impl);
pw_impl_module_schedule_destroy(impl->module); pw_impl_module_schedule_destroy(impl->module);
break; break;
case PW_STREAM_STATE_ERROR: pw_log_info("module %p: error: %s", impl, error); case PW_STREAM_STATE_ERROR: pw_log_info("module %p: error: %s", impl,
error);
break; break;
case PW_STREAM_STATE_STREAMING: case PW_STREAM_STATE_STREAMING:
{ {
uint32_t target = impl->info.rate; uint32_t target = impl->info.rate;
if (target == 0) if (target == 0)
target = impl->position target = impl->position
? impl->position->clock.target_rate.denom ? impl->position->clock.
target_rate.denom
: DEFAULT_RATE; : DEFAULT_RATE;
if (target == 0) { if (target == 0) {
res = -EINVAL; res = -EINVAL;
@ -1598,7 +1627,8 @@ static void control_state_changed(void *data, enum pw_stream_state old,
case PW_STREAM_STATE_PAUSED: case PW_STREAM_STATE_PAUSED:
pw_stream_flush(impl->control, false); pw_stream_flush(impl->control, false);
break; break;
case PW_STREAM_STATE_ERROR: pw_log_info("module %p: error: %s", impl, error); case PW_STREAM_STATE_ERROR: pw_log_info("module %p: error: %s", impl,
error);
break; break;
case PW_STREAM_STATE_STREAMING: default: case PW_STREAM_STATE_STREAMING: default:
break; break;
@ -1630,18 +1660,20 @@ static int setup_streams(struct impl *impl) {
&control_stream_events, impl); &control_stream_events, impl);
uint8_t buffer[256]; uint8_t buffer[256];
struct spa_pod_builder bt = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer)); struct spa_pod_builder bt = SPA_POD_BUILDER_INIT(
buffer, sizeof(buffer));
const struct spa_pod *param[1]; const struct spa_pod *param[1];
param[0] = spa_pod_builder_add_object(&bt, SPA_TYPE_OBJECT_Format, param[0] = spa_pod_builder_add_object(
SPA_PARAM_EnumFormat, &bt, SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
SPA_FORMAT_mediaType, SPA_FORMAT_mediaType,
SPA_POD_Id(SPA_MEDIA_TYPE_application SPA_POD_Id(SPA_MEDIA_TYPE_application ),
), SPA_FORMAT_mediaSubtype, SPA_FORMAT_mediaSubtype,
SPA_POD_Id(SPA_MEDIA_SUBTYPE_control)); SPA_POD_Id(SPA_MEDIA_SUBTYPE_control));
pw_stream_connect(impl->control, PW_DIRECTION_INPUT, PW_ID_ANY, pw_stream_connect(impl->control, PW_DIRECTION_INPUT, PW_ID_ANY,
PW_STREAM_FLAG_AUTOCONNECT | PW_STREAM_FLAG_MAP_BUFFERS | PW_STREAM_FLAG_AUTOCONNECT |
PW_STREAM_FLAG_MAP_BUFFERS |
PW_STREAM_FLAG_RT_PROCESS, param, 1); PW_STREAM_FLAG_RT_PROCESS, param, 1);
} }
@ -1669,20 +1701,23 @@ static int setup_streams(struct impl *impl) {
goto done; goto done;
} }
*offs = b.b.state.offset; *offs = b.b.state.offset;
spa_format_audio_raw_build(&b.b, SPA_PARAM_EnumFormat, &impl->capture_info); spa_format_audio_raw_build(&b.b, SPA_PARAM_EnumFormat,
&impl->capture_info);
for (i = 0;; i++) { for (i = 0;; i++) {
uint32_t save = b.b.state.offset; uint32_t save = b.b.state.offset;
if (spa_filter_graph_enum_prop_info(graph, i, &b.b, NULL) != 1) break; if (spa_filter_graph_enum_prop_info(graph, i, &b.b, NULL) != 1)
if ((offs = pw_array_add(&offsets, sizeof(uint32_t))) != NULL) *offs = save; break;
if ((offs = pw_array_add(&offsets, sizeof(uint32_t))) != NULL) *
offs = save;
} }
if ((offs = pw_array_add(&offsets, sizeof(uint32_t))) != NULL) *offs = b.b. if ((offs = pw_array_add(&offsets, sizeof(uint32_t))) != NULL)
state.offset; *offs = b.b.state.offset;
spa_filter_graph_get_props(graph, &b.b, NULL); spa_filter_graph_get_props(graph, &b.b, NULL);
if ((offs = pw_array_add(&offsets, sizeof(uint32_t))) != NULL) *offs = b.b. if ((offs = pw_array_add(&offsets, sizeof(uint32_t))) != NULL)
state.offset; *offs = b.b.state.offset;
spa_process_latency_build(&b.b, SPA_PARAM_ProcessLatency, spa_process_latency_build(&b.b, SPA_PARAM_ProcessLatency,
&impl->process_latency); &impl->process_latency);
@ -1697,13 +1732,14 @@ static int setup_streams(struct impl *impl) {
} }
offs = offsets.data; offs = offsets.data;
for (i = 0; i < n_params; i++) params[i] = spa_pod_builder_deref( for (i = 0; i < n_params; i++)
&b.b, offs[i]); params[i] = spa_pod_builder_deref(&b.b, offs[i]);
res = pw_stream_connect(impl->capture, PW_DIRECTION_INPUT, PW_ID_ANY, res = pw_stream_connect(impl->capture, PW_DIRECTION_INPUT, PW_ID_ANY,
PW_STREAM_FLAG_AUTOCONNECT | PW_STREAM_FLAG_AUTOCONNECT |
PW_STREAM_FLAG_MAP_BUFFERS | PW_STREAM_FLAG_RT_PROCESS PW_STREAM_FLAG_MAP_BUFFERS |
| PW_STREAM_FLAG_ASYNC, params, n_params); PW_STREAM_FLAG_RT_PROCESS |
PW_STREAM_FLAG_ASYNC, params, n_params);
spa_pod_dynamic_builder_clean(&b); spa_pod_dynamic_builder_clean(&b);
if (res < 0) goto done; if (res < 0) goto done;
@ -1715,8 +1751,9 @@ static int setup_streams(struct impl *impl) {
res = pw_stream_connect(impl->playback, PW_DIRECTION_OUTPUT, PW_ID_ANY, res = pw_stream_connect(impl->playback, PW_DIRECTION_OUTPUT, PW_ID_ANY,
PW_STREAM_FLAG_AUTOCONNECT | PW_STREAM_FLAG_AUTOCONNECT |
PW_STREAM_FLAG_MAP_BUFFERS | PW_STREAM_FLAG_RT_PROCESS PW_STREAM_FLAG_MAP_BUFFERS |
| PW_STREAM_FLAG_TRIGGER, params, n_params); PW_STREAM_FLAG_RT_PROCESS |
PW_STREAM_FLAG_TRIGGER, params, n_params);
spa_pod_dynamic_builder_clean(&b); spa_pod_dynamic_builder_clean(&b);
done: done:
@ -1730,8 +1767,8 @@ static void copy_position(struct spa_audio_info_raw *dst,
const struct spa_audio_info_raw *src) { const struct spa_audio_info_raw *src) {
if (SPA_FLAG_IS_SET(dst->flags, SPA_AUDIO_FLAG_UNPOSITIONED) && ! if (SPA_FLAG_IS_SET(dst->flags, SPA_AUDIO_FLAG_UNPOSITIONED) && !
SPA_FLAG_IS_SET(src->flags, SPA_AUDIO_FLAG_UNPOSITIONED)) { SPA_FLAG_IS_SET(src->flags, SPA_AUDIO_FLAG_UNPOSITIONED)) {
for (uint32_t i = 0; i < src->channels; i++) dst->position[i] = src-> for (uint32_t i = 0; i < src->channels; i++)
position[i]; dst->position[i] = src->position[i];
SPA_FLAG_CLEAR(dst->flags, SPA_AUDIO_FLAG_UNPOSITIONED); SPA_FLAG_CLEAR(dst->flags, SPA_AUDIO_FLAG_UNPOSITIONED);
} }
} }
@ -1741,10 +1778,10 @@ static void graph_info(void *object, const struct spa_filter_graph_info *info) {
struct spa_dict *props = info->props; struct spa_dict *props = info->props;
uint32_t i; uint32_t i;
if (impl->capture_info.channels == 0) impl->capture_info.channels = info-> if (impl->capture_info.channels == 0)
n_inputs; impl->capture_info.channels = info->n_inputs;
if (impl->playback_info.channels == 0) impl->playback_info.channels = info-> if (impl->playback_info.channels == 0)
n_outputs; impl->playback_info.channels = info->n_outputs;
impl->n_inputs = info->n_inputs; impl->n_inputs = info->n_inputs;
impl->n_outputs = info->n_outputs; impl->n_outputs = info->n_outputs;
@ -1760,8 +1797,10 @@ static void graph_info(void *object, const struct spa_filter_graph_info *info) {
if (spa_streq(k, "latency")) { if (spa_streq(k, "latency")) {
double latency; double latency;
if (spa_atod(s, &latency)) { if (spa_atod(s, &latency)) {
if (impl->process_latency.rate != (int32_t)latency) { if (impl->process_latency.rate != (int32_t)
impl->process_latency.rate = (int32_t)latency; latency) {
impl->process_latency.rate = (int32_t)
latency;
update_latencies(impl, true); update_latencies(impl, true);
} }
} }
@ -1773,8 +1812,9 @@ static void graph_apply_props(void *object, enum spa_direction direction,
const struct spa_pod *props) { const struct spa_pod *props) {
struct impl *impl = object; struct impl *impl = object;
pw_stream_set_param( pw_stream_set_param(
direction == SPA_DIRECTION_INPUT ? impl->capture : impl->playback, direction == SPA_DIRECTION_INPUT
SPA_PARAM_Props, props); ? impl->capture
: impl->playback, SPA_PARAM_Props, props);
} }
static void graph_props_changed(void *object, enum spa_direction direction) { static void graph_props_changed(void *object, enum spa_direction direction) {
@ -1801,15 +1841,15 @@ static void core_error(void *data, uint32_t id, int seq, int res,
struct impl *impl = data; struct impl *impl = data;
if (res == -ENOENT) { if (res == -ENOENT) {
pw_log_info("message id:%u seq:%d res:%d (%s): %s", id, seq, res, pw_log_info("message id:%u seq:%d res:%d (%s): %s", id, seq,
spa_strerror(res), message); res, spa_strerror(res), message);
} else { } else {
pw_log_warn("error id:%u seq:%d res:%d (%s): %s", id, seq, res, pw_log_warn("error id:%u seq:%d res:%d (%s): %s", id, seq, res,
spa_strerror(res), message); spa_strerror(res), message);
} }
if (id == PW_ID_CORE && res == -EPIPE) pw_impl_module_schedule_destroy( if (id == PW_ID_CORE && res == -EPIPE)
impl->module); pw_impl_module_schedule_destroy(impl->module);
} }
static const struct pw_core_events core_events = { static const struct pw_core_events core_events = {
@ -1859,7 +1899,8 @@ static const struct pw_impl_module_events module_events = {
static void parse_audio_info(struct pw_properties *props, static void parse_audio_info(struct pw_properties *props,
struct spa_audio_info_raw *info) { struct spa_audio_info_raw *info) {
spa_audio_info_raw_init_dict_keys( spa_audio_info_raw_init_dict_keys(
info, &SPA_DICT_ITEMS(SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, "F32P")), info,
&SPA_DICT_ITEMS(SPA_DICT_ITEM(SPA_KEY_AUDIO_FORMAT, "F32P")),
&props->dict, SPA_KEY_AUDIO_RATE, SPA_KEY_AUDIO_CHANNELS, &props->dict, SPA_KEY_AUDIO_RATE, SPA_KEY_AUDIO_CHANNELS,
SPA_KEY_AUDIO_POSITION, NULL); SPA_KEY_AUDIO_POSITION, NULL);
} }
@ -1868,10 +1909,10 @@ static void copy_props(struct impl *impl, struct pw_properties *props,
const char *key) { const char *key) {
const char *str; const char *str;
if ((str = pw_properties_get(props, key)) != NULL) { if ((str = pw_properties_get(props, key)) != NULL) {
if (pw_properties_get(impl->capture_props, key) == NULL) pw_properties_set( if (pw_properties_get(impl->capture_props, key) == NULL)
impl->capture_props, key, str); pw_properties_set(impl->capture_props, key, str);
if (pw_properties_get(impl->playback_props, key) == NULL) pw_properties_set( if (pw_properties_get(impl->playback_props, key) == NULL)
impl->playback_props, key, str); pw_properties_set(impl->playback_props, key, str);
} }
} }
@ -1907,8 +1948,8 @@ SPA_EXPORT int pipewire__module_init(struct pw_impl_module *module,
impl->capture_props = pw_properties_new(NULL, NULL); impl->capture_props = pw_properties_new(NULL, NULL);
impl->playback_props = pw_properties_new(NULL, NULL); impl->playback_props = pw_properties_new(NULL, NULL);
impl->control_props = pw_properties_new(NULL, NULL); impl->control_props = pw_properties_new(NULL, NULL);
if (impl->capture_props == NULL || impl->playback_props == NULL || impl-> if (impl->capture_props == NULL || impl->playback_props == NULL || impl
control_props == NULL) { ->control_props == NULL) {
res = -errno; res = -errno;
pw_log_error("can't create properties: %m"); pw_log_error("can't create properties: %m");
goto error; goto error;
@ -1916,28 +1957,34 @@ SPA_EXPORT int pipewire__module_init(struct pw_impl_module *module,
impl->module = module; impl->module = module;
impl->context = context; impl->context = context;
impl->latency[SPA_DIRECTION_INPUT] = SPA_LATENCY_INFO(SPA_DIRECTION_INPUT); impl->latency[SPA_DIRECTION_INPUT] = SPA_LATENCY_INFO(
impl->latency[SPA_DIRECTION_OUTPUT] = SPA_LATENCY_INFO(SPA_DIRECTION_OUTPUT); SPA_DIRECTION_INPUT);
impl->latency[SPA_DIRECTION_OUTPUT] = SPA_LATENCY_INFO(
SPA_DIRECTION_OUTPUT);
if (pw_properties_get(props, PW_KEY_NODE_GROUP) == NULL) pw_properties_setf( if (pw_properties_get(props, PW_KEY_NODE_GROUP) == NULL)
props, PW_KEY_NODE_GROUP, "filter-chain-%u-%u", pid, id); pw_properties_setf(props, PW_KEY_NODE_GROUP,
"filter-chain-%u-%u", pid, id);
if (pw_properties_get(props, PW_KEY_NODE_LINK_GROUP) == NULL) if (pw_properties_get(props, PW_KEY_NODE_LINK_GROUP) == NULL)
pw_properties_setf(props, PW_KEY_NODE_LINK_GROUP, "filter-chain-%u-%u", pid, pw_properties_setf(props, PW_KEY_NODE_LINK_GROUP,
id); "filter-chain-%u-%u", pid, id);
if (pw_properties_get(props, PW_KEY_NODE_VIRTUAL) == NULL) pw_properties_set( if (pw_properties_get(props, PW_KEY_NODE_VIRTUAL) == NULL)
props, PW_KEY_NODE_VIRTUAL, "true"); pw_properties_set(props, PW_KEY_NODE_VIRTUAL, "true");
if (pw_properties_get(props, "resample.prefill") == NULL) pw_properties_set( if (pw_properties_get(props, "resample.prefill") == NULL)
props, "resample.prefill", "true"); pw_properties_set(props, "resample.prefill", "true");
if (pw_properties_get(props, PW_KEY_NODE_DESCRIPTION) == NULL) if (pw_properties_get(props, PW_KEY_NODE_DESCRIPTION) == NULL)
pw_properties_setf(props, PW_KEY_NODE_DESCRIPTION, "filter-chain-%u-%u", pw_properties_setf(props, PW_KEY_NODE_DESCRIPTION,
pid, id); "filter-chain-%u-%u", pid, id);
if ((str = pw_properties_get(props, "capture.props")) != NULL) if ((str = pw_properties_get(props, "capture.props")) != NULL)
pw_properties_update_string(impl->capture_props, str, strlen(str)); pw_properties_update_string(impl->capture_props, str,
strlen(str));
if ((str = pw_properties_get(props, "playback.props")) != NULL) if ((str = pw_properties_get(props, "playback.props")) != NULL)
pw_properties_update_string(impl->playback_props, str, strlen(str)); pw_properties_update_string(impl->playback_props, str,
strlen(str));
if ((str = pw_properties_get(props, "control.props")) != NULL) if ((str = pw_properties_get(props, "control.props")) != NULL)
pw_properties_update_string(impl->control_props, str, strlen(str)); pw_properties_update_string(impl->control_props, str,
strlen(str));
copy_props(impl, props, PW_KEY_AUDIO_RATE); copy_props(impl, props, PW_KEY_AUDIO_RATE);
copy_props(impl, props, PW_KEY_AUDIO_CHANNELS); copy_props(impl, props, PW_KEY_AUDIO_CHANNELS);
@ -1954,14 +2001,16 @@ SPA_EXPORT int pipewire__module_init(struct pw_impl_module *module,
parse_audio_info(impl->playback_props, &impl->playback_info); parse_audio_info(impl->playback_props, &impl->playback_info);
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")
pw_properties_set(impl->playback_props, "resample.disable", "true"); == NULL) pw_properties_set(
if (pw_properties_get(impl->capture_props, "resample.disable") == NULL) impl->playback_props, "resample.disable", "true");
pw_properties_set(impl->capture_props, "resample.disable", "true"); if (pw_properties_get(impl->capture_props, "resample.disable")
} else if (impl->capture_info.rate && !impl->playback_info.rate) impl-> == NULL) pw_properties_set(
playback_info.rate = impl->capture_info.rate; impl->capture_props, "resample.disable", "true");
else if (impl->playback_info.rate && !impl->capture_info.rate) impl-> } else if (impl->capture_info.rate && !impl->playback_info.rate)
capture_info.rate = !impl->playback_info.rate; impl->playback_info.rate = impl->capture_info.rate;
else if (impl->playback_info.rate && !impl->capture_info.rate)
impl->capture_info.rate = !impl->playback_info.rate;
else if (impl->capture_info.rate != impl->playback_info.rate) { else if (impl->capture_info.rate != impl->playback_info.rate) {
pw_log_warn( pw_log_warn(
"Both capture and playback rate are set, but" "Both capture and playback rate are set, but"
@ -1972,21 +2021,25 @@ SPA_EXPORT int pipewire__module_init(struct pw_impl_module *module,
} }
if ((str = pw_properties_get(props, PW_KEY_NODE_NAME)) == NULL) { if ((str = pw_properties_get(props, PW_KEY_NODE_NAME)) == NULL) {
pw_properties_setf(props, PW_KEY_NODE_NAME, "filter-chain-%u-%u", pid, id); pw_properties_setf(props, PW_KEY_NODE_NAME,
"filter-chain-%u-%u", pid, id);
str = pw_properties_get(props, PW_KEY_NODE_NAME); str = pw_properties_get(props, PW_KEY_NODE_NAME);
} }
if (pw_properties_get(impl->capture_props, PW_KEY_NODE_NAME) == NULL) if (pw_properties_get(impl->capture_props, PW_KEY_NODE_NAME) == NULL)
pw_properties_setf(impl->capture_props, PW_KEY_NODE_NAME, "input.%s", str); pw_properties_setf(impl->capture_props, PW_KEY_NODE_NAME,
"input.%s", str);
if (pw_properties_get(impl->playback_props, PW_KEY_NODE_NAME) == NULL) if (pw_properties_get(impl->playback_props, PW_KEY_NODE_NAME) == NULL)
pw_properties_setf(impl->playback_props, PW_KEY_NODE_NAME, "output.%s", pw_properties_setf(impl->playback_props, PW_KEY_NODE_NAME,
str); "output.%s", str);
if (pw_properties_get(impl->capture_props, PW_KEY_MEDIA_NAME) == NULL) if (pw_properties_get(impl->capture_props, PW_KEY_MEDIA_NAME) == NULL)
pw_properties_setf(impl->capture_props, PW_KEY_MEDIA_NAME, "%s input", pw_properties_setf(impl->capture_props, PW_KEY_MEDIA_NAME,
"%s input",
pw_properties_get(impl->capture_props, pw_properties_get(impl->capture_props,
PW_KEY_NODE_DESCRIPTION)); PW_KEY_NODE_DESCRIPTION));
if (pw_properties_get(impl->playback_props, PW_KEY_MEDIA_NAME) == NULL) if (pw_properties_get(impl->playback_props, PW_KEY_MEDIA_NAME) == NULL)
pw_properties_setf(impl->playback_props, PW_KEY_MEDIA_NAME, "%s output", pw_properties_setf(impl->playback_props, PW_KEY_MEDIA_NAME,
"%s output",
pw_properties_get(impl->playback_props, pw_properties_get(impl->playback_props,
PW_KEY_NODE_DESCRIPTION)); PW_KEY_NODE_DESCRIPTION));
@ -2008,8 +2061,8 @@ SPA_EXPORT int pipewire__module_init(struct pw_impl_module *module,
goto error; goto error;
} }
res = spa_handle_get_interface(impl->handle, SPA_TYPE_INTERFACE_FilterGraph, res = spa_handle_get_interface(impl->handle,
&iface); SPA_TYPE_INTERFACE_FilterGraph, &iface);
if (res < 0 || iface == NULL) goto error; if (res < 0 || iface == NULL) goto error;
impl->graph = iface; impl->graph = iface;
@ -2017,12 +2070,14 @@ SPA_EXPORT int pipewire__module_init(struct pw_impl_module *module,
spa_filter_graph_add_listener(impl->graph, &impl->graph_listener, spa_filter_graph_add_listener(impl->graph, &impl->graph_listener,
&graph_events, impl); &graph_events, impl);
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) {
str = pw_properties_get(props, PW_KEY_REMOTE_NAME); str = pw_properties_get(props, PW_KEY_REMOTE_NAME);
impl->core = pw_context_connect(impl->context, impl->core = pw_context_connect(impl->context,
pw_properties_new( pw_properties_new(
PW_KEY_REMOTE_NAME, str, NULL), 0); PW_KEY_REMOTE_NAME, str,
NULL), 0);
impl->do_disconnect = true; impl->do_disconnect = true;
} }
if (impl->core == NULL) { if (impl->core == NULL) {
@ -2032,25 +2087,28 @@ SPA_EXPORT int pipewire__module_init(struct pw_impl_module *module,
} }
pw_proxy_add_listener((struct pw_proxy*)impl->core, pw_proxy_add_listener((struct pw_proxy*)impl->core,
&impl->core_proxy_listener, &core_proxy_events, impl); &impl->core_proxy_listener, &core_proxy_events,
pw_core_add_listener(impl->core, &impl->core_listener, &core_events, impl); impl);
pw_core_add_listener(impl->core, &impl->core_listener, &core_events,
impl);
if (pw_properties_get(impl->control_props, "enabled") == NULL) { if (pw_properties_get(impl->control_props, "enabled") == NULL) {
impl->control_stream_active = false; impl->control_stream_active = false;
} else if (strcmp(pw_properties_get(impl->control_props, "enabled"), "true") } else if (strcmp(pw_properties_get(impl->control_props, "enabled"),
== 0) { "true") == 0) {
impl->control_stream_active = true; impl->control_stream_active = true;
} else if (strcmp(pw_properties_get(impl->control_props, "enabled"), "false") } else if (strcmp(pw_properties_get(impl->control_props, "enabled"),
== 0) { "false") == 0) {
impl->control_stream_active = false; impl->control_stream_active = false;
} }
setup_streams(impl); setup_streams(impl);
pw_impl_module_add_listener(module, &impl->module_listener, &module_events, pw_impl_module_add_listener(module, &impl->module_listener,
impl); &module_events, impl);
pw_impl_module_update_properties(module, &SPA_DICT_INIT_ARRAY(module_props)); pw_impl_module_update_properties(
module, &SPA_DICT_INIT_ARRAY(module_props));
return 0; return 0;