From a8c3dc6a8a3734f1efdfc534302ce8f8139bed03 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 6 Dec 2019 22:12:38 +0100 Subject: [PATCH] improve properties on stream and filter --- src/pipewire/core-proxy.c | 2 ++ src/pipewire/filter.c | 15 +++++++++++---- src/pipewire/pipewire.c | 6 +++--- src/pipewire/pipewire.h | 2 +- src/pipewire/stream.c | 13 ++++++++++--- 5 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/pipewire/core-proxy.c b/src/pipewire/core-proxy.c index cd380b418..b5fac42dc 100644 --- a/src/pipewire/core-proxy.c +++ b/src/pipewire/core-proxy.c @@ -286,6 +286,8 @@ static struct pw_core_proxy *core_proxy_new(struct pw_core *core, if (properties == NULL) goto error_properties; + pw_fill_connect_properties(core, properties); + p->proxy.core_proxy = p; p->core = core; p->properties = properties; diff --git a/src/pipewire/filter.c b/src/pipewire/filter.c index ca4c8d22e..55da6c511 100644 --- a/src/pipewire/filter.c +++ b/src/pipewire/filter.c @@ -896,7 +896,7 @@ static const struct pw_core_proxy_events core_events = { static struct filter * filter_new(struct pw_core *core, const char *name, - struct pw_properties *props, struct pw_properties *extra) + struct pw_properties *props, const struct pw_properties *extra) { struct filter *impl; struct pw_filter *this; @@ -964,9 +964,9 @@ struct pw_filter * pw_filter_new(struct pw_core_proxy *core_proxy, const char *n { struct filter *impl; struct pw_filter *this; - struct pw_core *core = pw_core_proxy_get_core(core_proxy); + struct pw_core *core = core_proxy->core; - impl = filter_new(core, name, props, NULL); + impl = filter_new(core, name, props, core_proxy->properties); if (impl == NULL) return NULL; @@ -992,9 +992,16 @@ pw_filter_new_simple(struct pw_loop *loop, struct pw_core *core; int res; + if (props == NULL) + props = pw_properties_new(NULL, NULL); + if (props == NULL) + return NULL; + core = pw_core_new(loop, NULL, 0); - impl = filter_new(core, name, props, NULL); + pw_fill_connect_properties(core, props); + + impl = filter_new(core, name, props, props); if (impl == NULL) { res = -errno; goto error_cleanup; diff --git a/src/pipewire/pipewire.c b/src/pipewire/pipewire.c index de9c18431..677ceee59 100644 --- a/src/pipewire/pipewire.c +++ b/src/pipewire/pipewire.c @@ -496,15 +496,15 @@ const char *pw_get_client_name(void) } } -/** Fill remote properties +/** Fill connectremote properties * \param properties a \ref pw_properties * - * Fill \a properties with a set of default remote properties. + * Fill \a properties with a set of default properties for connecting to a PipeWire instance. * * \memberof pw_pipewire */ SPA_EXPORT -void pw_fill_remote_properties(struct pw_core *core, struct pw_properties *properties) +void pw_fill_connect_properties(struct pw_core *core, struct pw_properties *properties) { const char *val; diff --git a/src/pipewire/pipewire.h b/src/pipewire/pipewire.h index 90aa69860..647a2403b 100644 --- a/src/pipewire/pipewire.h +++ b/src/pipewire/pipewire.h @@ -129,7 +129,7 @@ const char * pw_get_client_name(void); void -pw_fill_remote_properties(struct pw_core *core, struct pw_properties *properties); +pw_fill_connect_properties(struct pw_core *core, struct pw_properties *properties); void pw_fill_stream_properties(struct pw_core *core, struct pw_properties *properties); diff --git a/src/pipewire/stream.c b/src/pipewire/stream.c index 483c551ea..a56dcb4cd 100644 --- a/src/pipewire/stream.c +++ b/src/pipewire/stream.c @@ -1014,7 +1014,7 @@ static const struct pw_core_proxy_events core_events = { static struct stream * stream_new(struct pw_core *core, const char *name, - struct pw_properties *props, struct pw_properties *extra) + struct pw_properties *props, const struct pw_properties *extra) { struct stream *impl; struct pw_stream *this; @@ -1083,9 +1083,9 @@ struct pw_stream * pw_stream_new(struct pw_core_proxy *core_proxy, const char *n { struct stream *impl; struct pw_stream *this; - struct pw_core *core = pw_core_proxy_get_core(core_proxy); + struct pw_core *core = core_proxy->core; - impl = stream_new(core, name, props, NULL); + impl = stream_new(core, name, props, core_proxy->properties); if (impl == NULL) return NULL; @@ -1111,8 +1111,15 @@ pw_stream_new_simple(struct pw_loop *loop, struct pw_core *core; int res; + if (props == NULL) + props = pw_properties_new(NULL, NULL); + if (props == NULL) + return NULL; + core = pw_core_new(loop, NULL, 0); + pw_fill_connect_properties(core, props); + impl = stream_new(core, name, props, NULL); if (impl == NULL) { res = -errno;