From ea0b96073fbf63029059e02090f35385cc80a814 Mon Sep 17 00:00:00 2001 From: George Kiagiadakis Date: Mon, 16 Nov 2020 11:01:18 +0200 Subject: [PATCH] spa-pod: make the wrap functions public, remove private.h and sort out the rest --- lib/wp/debug.c | 1 - lib/wp/private.h | 44 ------------------ lib/wp/private/pipewire-object-mixin.h | 1 - lib/wp/props.h | 4 ++ lib/wp/spa-pod.c | 64 +++++++++++++++++++------- lib/wp/spa-pod.h | 11 +++++ 6 files changed, 62 insertions(+), 63 deletions(-) delete mode 100644 lib/wp/private.h diff --git a/lib/wp/debug.c b/lib/wp/debug.c index 78ac2cbd..2dd21481 100644 --- a/lib/wp/debug.c +++ b/lib/wp/debug.c @@ -14,7 +14,6 @@ #include "debug.h" #include "spa-pod.h" #include "proxy.h" -#include "private.h" #include #include diff --git a/lib/wp/private.h b/lib/wp/private.h deleted file mode 100644 index 54d83bbd..00000000 --- a/lib/wp/private.h +++ /dev/null @@ -1,44 +0,0 @@ -/* WirePlumber - * - * Copyright © 2019 Collabora Ltd. - * @author George Kiagiadakis - * - * SPDX-License-Identifier: MIT - */ - -#ifndef __WIREPLUMBER_PRIVATE_H__ -#define __WIREPLUMBER_PRIVATE_H__ - -#include "props.h" -#include "spa-type.h" - -#include - -G_BEGIN_DECLS - -struct spa_pod; -struct spa_pod_builder; - -/* props */ - -void wp_props_handle_proxy_param_event (WpProps * self, guint32 id, - WpSpaPod * pod); - -/* spa pod */ - -typedef struct _WpSpaPod WpSpaPod; -WpSpaPod * wp_spa_pod_new_wrap (struct spa_pod *pod); -WpSpaPod * wp_spa_pod_new_wrap_const (const struct spa_pod *pod); -WpSpaPod * wp_spa_pod_new_property_wrap (WpSpaTypeTable table, guint32 key, - guint32 flags, struct spa_pod *pod); -WpSpaPod * wp_spa_pod_new_property_wrap_const (WpSpaTypeTable table, - guint32 key, guint32 flags, const struct spa_pod *pod); -WpSpaPod * wp_spa_pod_new_control_wrap (guint32 offset, guint32 type, - struct spa_pod *pod); -WpSpaPod * wp_spa_pod_new_control_wrap_const (guint32 offset, guint32 type, - const struct spa_pod *pod); -const struct spa_pod *wp_spa_pod_get_spa_pod (const WpSpaPod *self); - -G_END_DECLS - -#endif diff --git a/lib/wp/private/pipewire-object-mixin.h b/lib/wp/private/pipewire-object-mixin.h index a329f8d8..fc86101a 100644 --- a/lib/wp/private/pipewire-object-mixin.h +++ b/lib/wp/private/pipewire-object-mixin.h @@ -13,7 +13,6 @@ #include "spa-type.h" #include "spa-pod.h" #include "debug.h" -#include "private.h" #include #include diff --git a/lib/wp/props.h b/lib/wp/props.h index 2ba4a301..2fbc44f5 100644 --- a/lib/wp/props.h +++ b/lib/wp/props.h @@ -59,6 +59,10 @@ void wp_props_set (WpProps * self, const gchar * name, WpSpaPod * value); WP_API void wp_props_store (WpProps * self, const gchar * name, WpSpaPod * value); +WP_PRIVATE_API +void wp_props_handle_proxy_param_event (WpProps * self, guint32 id, + WpSpaPod * pod); + G_END_DECLS #endif diff --git a/lib/wp/spa-pod.c b/lib/wp/spa-pod.c index 61a372f1..bb765f36 100644 --- a/lib/wp/spa-pod.c +++ b/lib/wp/spa-pod.c @@ -8,14 +8,13 @@ #define G_LOG_DOMAIN "wp-spa-pod" +#include "spa-pod.h" +#include "spa-type.h" + #include #include #include -#include "private.h" -#include "spa-pod.h" -#include "spa-type.h" - #define WP_SPA_POD_BUILDER_REALLOC_STEP_SIZE 64 enum { @@ -190,12 +189,29 @@ wp_spa_pod_new (const struct spa_pod *pod, WpSpaPodType type, guint32 flags) return self; } +/** + * wp_spa_pod_new_wrap: + * @pod: a spa_pod + * + * Returns: a new #WpSpaPod that references the data in @pod. @pod is not + * copied, so it needs to stay alive. The returned #WpSpaPod can be modified + * by using the setter functions, in which case @pod will be modified + * underneath. + */ WpSpaPod * wp_spa_pod_new_wrap (struct spa_pod *pod) { return wp_spa_pod_new (pod, WP_SPA_POD_REGULAR, FLAG_NO_OWNERSHIP); } +/** + * wp_spa_pod_new_wrap_const: + * @pod: a constant spa_pod + * + * Returns: a new #WpSpaPod that references the data in @pod. @pod is not + * copied, so it needs to stay alive. The returned #WpSpaPod cannot be + * modified, unless it's copied first. + */ WpSpaPod * wp_spa_pod_new_wrap_const (const struct spa_pod *pod) { @@ -203,7 +219,7 @@ wp_spa_pod_new_wrap_const (const struct spa_pod *pod) FLAG_NO_OWNERSHIP | FLAG_CONSTANT); } -WpSpaPod * +static WpSpaPod * wp_spa_pod_new_property_wrap (WpSpaTypeTable table, guint32 key, guint32 flags, struct spa_pod *pod) { @@ -214,7 +230,20 @@ wp_spa_pod_new_property_wrap (WpSpaTypeTable table, guint32 key, guint32 flags, return self; } -WpSpaPod * +static WpSpaPod * +wp_spa_pod_new_control_wrap (guint32 offset, guint32 type, + struct spa_pod *pod) +{ + WpSpaPod *self = wp_spa_pod_new (pod, WP_SPA_POD_CONTROL, FLAG_NO_OWNERSHIP); + self->static_pod.data_control.offset = offset; + self->static_pod.data_control.type = type; + return self; +} + +#if 0 +/* there is no use for these _const variants, but let's keep them just in case */ + +static WpSpaPod * wp_spa_pod_new_property_wrap_const (WpSpaTypeTable table, guint32 key, guint32 flags, const struct spa_pod *pod) { @@ -226,17 +255,7 @@ wp_spa_pod_new_property_wrap_const (WpSpaTypeTable table, guint32 key, return self; } -WpSpaPod * -wp_spa_pod_new_control_wrap (guint32 offset, guint32 type, - struct spa_pod *pod) -{ - WpSpaPod *self = wp_spa_pod_new (pod, WP_SPA_POD_CONTROL, FLAG_NO_OWNERSHIP); - self->static_pod.data_control.offset = offset; - self->static_pod.data_control.type = type; - return self; -} - -WpSpaPod * +static WpSpaPod * wp_spa_pod_new_control_wrap_const (guint32 offset, guint32 type, const struct spa_pod *pod) { @@ -246,6 +265,7 @@ wp_spa_pod_new_control_wrap_const (guint32 offset, guint32 type, self->static_pod.data_control.type = type; return self; } +#endif static WpSpaPod * wp_spa_pod_new_wrap_copy (const struct spa_pod *pod) @@ -274,6 +294,16 @@ wp_spa_pod_new_control_wrap_copy (guint32 offset, guint32 type, return self; } +/** + * wp_spa_pod_get_spa_pod: + * @self: a spa pod object + * + * Converts a #WpSpaPod pointer to a `struct spa_pod` one, for use with + * native pipewire & spa functions. The returned pointer is owned by #WpSpaPod + * and may not be modified or freed. + * + * Returns: a const pointer to the underlying spa_pod structure + */ const struct spa_pod * wp_spa_pod_get_spa_pod (const WpSpaPod *self) { diff --git a/lib/wp/spa-pod.h b/lib/wp/spa-pod.h index f0726e85..f66c7879 100644 --- a/lib/wp/spa-pod.h +++ b/lib/wp/spa-pod.h @@ -16,6 +16,8 @@ G_BEGIN_DECLS +struct spa_pod; + /** * WP_TYPE_SPA_POD: * @@ -33,6 +35,15 @@ WpSpaPod *wp_spa_pod_ref (WpSpaPod *self); WP_API void wp_spa_pod_unref (WpSpaPod *self); +WP_API +WpSpaPod * wp_spa_pod_new_wrap (struct spa_pod *pod); + +WP_API +WpSpaPod * wp_spa_pod_new_wrap_const (const struct spa_pod *pod); + +WP_API +const struct spa_pod * wp_spa_pod_get_spa_pod (const WpSpaPod *self); + WP_API const char *wp_spa_pod_get_type_name (WpSpaPod *self);