spa-pod: make the wrap functions public, remove private.h and sort out the rest

This commit is contained in:
George Kiagiadakis 2020-11-16 11:01:18 +02:00
parent 94213310a3
commit ea0b96073f
6 changed files with 62 additions and 63 deletions

View file

@ -14,7 +14,6 @@
#include "debug.h"
#include "spa-pod.h"
#include "proxy.h"
#include "private.h"
#include <pipewire/pipewire.h>
#include <spa/support/log.h>

View file

@ -1,44 +0,0 @@
/* WirePlumber
*
* Copyright © 2019 Collabora Ltd.
* @author George Kiagiadakis <george.kiagiadakis@collabora.com>
*
* SPDX-License-Identifier: MIT
*/
#ifndef __WIREPLUMBER_PRIVATE_H__
#define __WIREPLUMBER_PRIVATE_H__
#include "props.h"
#include "spa-type.h"
#include <pipewire/pipewire.h>
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

View file

@ -13,7 +13,6 @@
#include "spa-type.h"
#include "spa-pod.h"
#include "debug.h"
#include "private.h"
#include <pipewire/pipewire.h>
#include <spa/utils/result.h>

View file

@ -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

View file

@ -8,14 +8,13 @@
#define G_LOG_DOMAIN "wp-spa-pod"
#include "spa-pod.h"
#include "spa-type.h"
#include <spa/utils/type-info.h>
#include <spa/pod/builder.h>
#include <spa/pod/parser.h>
#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)
{

View file

@ -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);