pulse-server: add latency_msec parameter

This commit is contained in:
Wim Taymans 2021-09-30 09:49:09 +02:00
parent 696dbf7cd6
commit 5026645e93
2 changed files with 17 additions and 0 deletions

View file

@ -45,6 +45,8 @@ struct module_tunnel_sink_data {
struct pw_impl_module *mod; struct pw_impl_module *mod;
struct spa_hook mod_listener; struct spa_hook mod_listener;
uint32_t latency_msec;
struct pw_properties *stream_props; struct pw_properties *stream_props;
}; };
@ -76,6 +78,8 @@ static int module_tunnel_sink_load(struct client *client, struct module *module)
pw_properties_serialize_dict(f, &module->props->dict, 0); pw_properties_serialize_dict(f, &module->props->dict, 0);
fprintf(f, " pulse.server.address = \"%s\" ", server); fprintf(f, " pulse.server.address = \"%s\" ", server);
fprintf(f, " tunnel.mode = playback "); fprintf(f, " tunnel.mode = playback ");
if (data->latency_msec > 0)
fprintf(f, " pulse.latency = %u ", data->latency_msec);
fprintf(f, " stream.props = {"); fprintf(f, " stream.props = {");
pw_properties_serialize_dict(f, &data->stream_props->dict, 0); pw_properties_serialize_dict(f, &data->stream_props->dict, 0);
fprintf(f, " } }"); fprintf(f, " } }");
@ -129,6 +133,7 @@ static const struct spa_dict_item module_tunnel_sink_info[] = {
"channels=<number of channels> " "channels=<number of channels> "
"rate=<sample rate> " "rate=<sample rate> "
"channel_map=<channel map> " "channel_map=<channel map> "
"latency_msec=<fixed latency in ms> "
"cookie=<cookie file path>" }, "cookie=<cookie file path>" },
{ PW_KEY_MODULE_VERSION, PACKAGE_VERSION }, { PW_KEY_MODULE_VERSION, PACKAGE_VERSION },
}; };
@ -188,6 +193,7 @@ struct module *create_module_tunnel_sink(struct impl *impl, const char *argument
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_get(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); pw_properties_set(props, "sink_properties", NULL);
@ -210,6 +216,9 @@ struct module *create_module_tunnel_sink(struct impl *impl, const char *argument
d->module = module; d->module = module;
d->stream_props = stream_props; d->stream_props = stream_props;
if ((str = pw_properties_get(props, "latency_msec")) != NULL)
spa_atou32(str, &d->latency_msec, 0);
return module; return module;
out: out:
pw_properties_free(props); pw_properties_free(props);

View file

@ -45,6 +45,8 @@ struct module_tunnel_source_data {
struct pw_impl_module *mod; struct pw_impl_module *mod;
struct spa_hook mod_listener; struct spa_hook mod_listener;
uint32_t latency_msec;
struct pw_properties *stream_props; struct pw_properties *stream_props;
}; };
@ -76,6 +78,8 @@ static int module_tunnel_source_load(struct client *client, struct module *modul
pw_properties_serialize_dict(f, &module->props->dict, 0); pw_properties_serialize_dict(f, &module->props->dict, 0);
fprintf(f, " pulse.server.address = \"%s\" ", server); fprintf(f, " pulse.server.address = \"%s\" ", server);
fprintf(f, " tunnel.mode = capture "); fprintf(f, " tunnel.mode = capture ");
if (data->latency_msec > 0)
fprintf(f, " pulse.latency = %u ", data->latency_msec);
fprintf(f, " stream.props = {"); fprintf(f, " stream.props = {");
pw_properties_serialize_dict(f, &data->stream_props->dict, 0); pw_properties_serialize_dict(f, &data->stream_props->dict, 0);
fprintf(f, " } }"); fprintf(f, " } }");
@ -129,6 +133,7 @@ static const struct spa_dict_item module_tunnel_source_info[] = {
"channels=<number of channels> " "channels=<number of channels> "
"rate=<sample rate> " "rate=<sample rate> "
"channel_map=<channel map> " "channel_map=<channel map> "
"latency_msec=<fixed latency in ms> "
"cookie=<cookie file path>" }, "cookie=<cookie file path>" },
{ PW_KEY_MODULE_VERSION, PACKAGE_VERSION }, { PW_KEY_MODULE_VERSION, PACKAGE_VERSION },
}; };
@ -210,6 +215,9 @@ struct module *create_module_tunnel_source(struct impl *impl, const char *argume
d->module = module; d->module = module;
d->stream_props = stream_props; d->stream_props = stream_props;
if ((str = pw_properties_get(props, "latency_msec")) != NULL)
spa_atou32(str, &d->latency_msec, 0);
return module; return module;
out: out:
pw_properties_free(props); pw_properties_free(props);