mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-23 06:59:58 -05:00
add per type API defines
This commit is contained in:
parent
b03f2f7afa
commit
31802d4994
85 changed files with 1137 additions and 509 deletions
|
|
@ -18,6 +18,7 @@
|
|||
#include <spa/utils/ringbuffer.h>
|
||||
#include <spa/param/profiler.h>
|
||||
|
||||
#define PW_API_PROFILER SPA_EXPORT
|
||||
#include <pipewire/private.h>
|
||||
#include <pipewire/impl.h>
|
||||
#include <pipewire/extensions/profiler.h>
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@
|
|||
#include <pipewire/pipewire.h>
|
||||
#include <pipewire/impl.h>
|
||||
#include <pipewire/private.h>
|
||||
|
||||
#define PW_API_SECURITY_CONTEXT SPA_EXPORT
|
||||
#include <pipewire/extensions/security-context.h>
|
||||
|
||||
PW_LOG_TOPIC_EXTERN(mod_topic);
|
||||
|
|
|
|||
|
|
@ -13,6 +13,11 @@ extern "C" {
|
|||
|
||||
#include <spa/utils/defs.h>
|
||||
|
||||
#ifndef PW_API_ARRAY
|
||||
#define PW_API_ARRAY static inline
|
||||
#endif
|
||||
|
||||
|
||||
/** \defgroup pw_array Array
|
||||
*
|
||||
* \brief An array object
|
||||
|
|
@ -71,7 +76,7 @@ struct pw_array {
|
|||
|
||||
/** Initialize the array with given extend. Extend needs to be > 0 or else
|
||||
* the array will not be able to expand. */
|
||||
SPA_API_IMPL void pw_array_init(struct pw_array *arr, size_t extend)
|
||||
PW_API_ARRAY void pw_array_init(struct pw_array *arr, size_t extend)
|
||||
{
|
||||
arr->data = NULL;
|
||||
arr->size = arr->alloc = 0;
|
||||
|
|
@ -79,7 +84,7 @@ SPA_API_IMPL void pw_array_init(struct pw_array *arr, size_t extend)
|
|||
}
|
||||
|
||||
/** Clear the array. This should be called when pw_array_init() was called. */
|
||||
SPA_API_IMPL void pw_array_clear(struct pw_array *arr)
|
||||
PW_API_ARRAY void pw_array_clear(struct pw_array *arr)
|
||||
{
|
||||
if (arr->extend > 0)
|
||||
free(arr->data);
|
||||
|
|
@ -87,7 +92,7 @@ SPA_API_IMPL void pw_array_clear(struct pw_array *arr)
|
|||
}
|
||||
|
||||
/** Initialize a static array. */
|
||||
SPA_API_IMPL void pw_array_init_static(struct pw_array *arr, void *data, size_t size)
|
||||
PW_API_ARRAY void pw_array_init_static(struct pw_array *arr, void *data, size_t size)
|
||||
{
|
||||
arr->data = data;
|
||||
arr->alloc = size;
|
||||
|
|
@ -95,13 +100,13 @@ SPA_API_IMPL void pw_array_init_static(struct pw_array *arr, void *data, size_t
|
|||
}
|
||||
|
||||
/** Reset the array */
|
||||
SPA_API_IMPL void pw_array_reset(struct pw_array *arr)
|
||||
PW_API_ARRAY void pw_array_reset(struct pw_array *arr)
|
||||
{
|
||||
arr->size = 0;
|
||||
}
|
||||
|
||||
/** Make sure \a size bytes can be added to the array */
|
||||
SPA_API_IMPL int pw_array_ensure_size(struct pw_array *arr, size_t size)
|
||||
PW_API_ARRAY int pw_array_ensure_size(struct pw_array *arr, size_t size)
|
||||
{
|
||||
size_t alloc, need;
|
||||
|
||||
|
|
@ -124,7 +129,7 @@ SPA_API_IMPL int pw_array_ensure_size(struct pw_array *arr, size_t size)
|
|||
/** Add \a ref size bytes to \a arr. A pointer to memory that can
|
||||
* hold at least \a size bytes is returned or NULL when an error occurred
|
||||
* and errno will be set.*/
|
||||
SPA_API_IMPL void *pw_array_add(struct pw_array *arr, size_t size)
|
||||
PW_API_ARRAY void *pw_array_add(struct pw_array *arr, size_t size)
|
||||
{
|
||||
void *p;
|
||||
|
||||
|
|
@ -139,7 +144,7 @@ SPA_API_IMPL void *pw_array_add(struct pw_array *arr, size_t size)
|
|||
|
||||
/** Add a pointer to array. Returns 0 on success and a negative errno style
|
||||
* error on failure. */
|
||||
SPA_API_IMPL int pw_array_add_ptr(struct pw_array *arr, void *ptr)
|
||||
PW_API_ARRAY int pw_array_add_ptr(struct pw_array *arr, void *ptr)
|
||||
{
|
||||
void **p = (void **)pw_array_add(arr, sizeof(void*));
|
||||
if (p == NULL)
|
||||
|
|
|
|||
|
|
@ -24,6 +24,10 @@ extern "C" {
|
|||
#define PW_VERSION_PROFILER 3
|
||||
struct pw_profiler;
|
||||
|
||||
#ifndef PW_API_PROFILER
|
||||
#define PW_API_PROFILER static inline
|
||||
#endif
|
||||
|
||||
#define PW_EXTENSION_MODULE_PROFILER PIPEWIRE_MODULE_PREFIX "module-profiler"
|
||||
|
||||
#define PW_PROFILER_PERM_MASK PW_PERM_R
|
||||
|
|
@ -53,7 +57,7 @@ struct pw_profiler_methods {
|
|||
void *data);
|
||||
};
|
||||
|
||||
SPA_API_IMPL int pw_profiler_add_listener(struct pw_profiler *object,
|
||||
PW_API_PROFILER int pw_profiler_add_listener(struct pw_profiler *object,
|
||||
struct spa_hook *listener,
|
||||
const struct pw_profiler_events *events,
|
||||
void *data)
|
||||
|
|
|
|||
|
|
@ -26,6 +26,10 @@ extern "C" {
|
|||
#define PW_VERSION_SECURITY_CONTEXT 3
|
||||
struct pw_security_context;
|
||||
|
||||
#ifndef PW_API_SECURITY_CONTEXT
|
||||
#define PW_API_SECURITY_CONTEXT static inline
|
||||
#endif
|
||||
|
||||
#define PW_EXTENSION_MODULE_SECURITY_CONTEXT PIPEWIRE_MODULE_PREFIX "module-security-context"
|
||||
|
||||
#define PW_SECURITY_CONTEXT_EVENT_NUM 0
|
||||
|
|
@ -94,7 +98,7 @@ struct pw_security_context_methods {
|
|||
const struct spa_dict *props);
|
||||
};
|
||||
|
||||
SPA_API_IMPL int pw_security_context_add_listener(struct pw_security_context *object,
|
||||
PW_API_SECURITY_CONTEXT int pw_security_context_add_listener(struct pw_security_context *object,
|
||||
struct spa_hook *listener,
|
||||
const struct pw_security_context_events *events,
|
||||
void *data)
|
||||
|
|
@ -104,7 +108,7 @@ SPA_API_IMPL int pw_security_context_add_listener(struct pw_security_context *ob
|
|||
listener, events, data);
|
||||
}
|
||||
|
||||
SPA_API_IMPL int pw_security_context_create(struct pw_security_context *object,
|
||||
PW_API_SECURITY_CONTEXT int pw_security_context_create(struct pw_security_context *object,
|
||||
int listen_fd, int close_fd, const struct spa_dict *props)
|
||||
{
|
||||
return spa_api_method_r(int, -ENOTSUP,
|
||||
|
|
|
|||
|
|
@ -15,6 +15,10 @@ extern "C" {
|
|||
#include <spa/utils/defs.h>
|
||||
#include <pipewire/array.h>
|
||||
|
||||
#ifndef PW_API_MAP
|
||||
#define PW_API_MAP static inline
|
||||
#endif
|
||||
|
||||
/** \defgroup pw_map Map
|
||||
*
|
||||
* \brief A map that holds pointers to objects indexed by id
|
||||
|
|
@ -93,7 +97,7 @@ struct pw_map {
|
|||
* \param size the initial size of the map
|
||||
* \param extend the amount to bytes to grow the map with when needed
|
||||
*/
|
||||
SPA_API_IMPL void pw_map_init(struct pw_map *map, size_t size, size_t extend)
|
||||
PW_API_MAP void pw_map_init(struct pw_map *map, size_t size, size_t extend)
|
||||
{
|
||||
pw_array_init(&map->items, extend * sizeof(union pw_map_item));
|
||||
pw_array_ensure_size(&map->items, size * sizeof(union pw_map_item));
|
||||
|
|
@ -103,7 +107,7 @@ SPA_API_IMPL void pw_map_init(struct pw_map *map, size_t size, size_t extend)
|
|||
/** Clear a map and free the data storage. All previously returned ids
|
||||
* must be treated as invalid.
|
||||
*/
|
||||
SPA_API_IMPL void pw_map_clear(struct pw_map *map)
|
||||
PW_API_MAP void pw_map_clear(struct pw_map *map)
|
||||
{
|
||||
pw_array_clear(&map->items);
|
||||
}
|
||||
|
|
@ -111,7 +115,7 @@ SPA_API_IMPL void pw_map_clear(struct pw_map *map)
|
|||
/** Reset a map but keep previously allocated storage. All previously
|
||||
* returned ids must be treated as invalid.
|
||||
*/
|
||||
SPA_API_IMPL void pw_map_reset(struct pw_map *map)
|
||||
PW_API_MAP void pw_map_reset(struct pw_map *map)
|
||||
{
|
||||
pw_array_reset(&map->items);
|
||||
map->free_list = SPA_ID_INVALID;
|
||||
|
|
@ -123,7 +127,7 @@ SPA_API_IMPL void pw_map_reset(struct pw_map *map)
|
|||
* \return the id where the item was inserted or SPA_ID_INVALID when the
|
||||
* item can not be inserted.
|
||||
*/
|
||||
SPA_API_IMPL uint32_t pw_map_insert_new(struct pw_map *map, void *data)
|
||||
PW_API_MAP uint32_t pw_map_insert_new(struct pw_map *map, void *data)
|
||||
{
|
||||
union pw_map_item *start, *item;
|
||||
uint32_t id;
|
||||
|
|
@ -150,7 +154,7 @@ SPA_API_IMPL uint32_t pw_map_insert_new(struct pw_map *map, void *data)
|
|||
* \param data the data to insert
|
||||
* \return 0 on success, -ENOSPC value when the index is invalid or a negative errno
|
||||
*/
|
||||
SPA_API_IMPL int pw_map_insert_at(struct pw_map *map, uint32_t id, void *data)
|
||||
PW_API_MAP int pw_map_insert_at(struct pw_map *map, uint32_t id, void *data)
|
||||
{
|
||||
size_t size = pw_map_get_size(map);
|
||||
union pw_map_item *item;
|
||||
|
|
@ -175,7 +179,7 @@ SPA_API_IMPL int pw_map_insert_at(struct pw_map *map, uint32_t id, void *data)
|
|||
* \param map the map to remove from
|
||||
* \param id the index to remove
|
||||
*/
|
||||
SPA_API_IMPL void pw_map_remove(struct pw_map *map, uint32_t id)
|
||||
PW_API_MAP void pw_map_remove(struct pw_map *map, uint32_t id)
|
||||
{
|
||||
if (pw_map_id_is_free(map, id))
|
||||
return;
|
||||
|
|
@ -189,7 +193,7 @@ SPA_API_IMPL void pw_map_remove(struct pw_map *map, uint32_t id)
|
|||
* \param id the index to look at
|
||||
* \return the item at \a id or NULL when no such item exists
|
||||
*/
|
||||
SPA_API_IMPL void *pw_map_lookup(const struct pw_map *map, uint32_t id)
|
||||
PW_API_MAP void *pw_map_lookup(const struct pw_map *map, uint32_t id)
|
||||
{
|
||||
if (SPA_LIKELY(pw_map_check_id(map, id))) {
|
||||
union pw_map_item *item = pw_map_get_item(map, id);
|
||||
|
|
@ -207,7 +211,7 @@ SPA_API_IMPL void *pw_map_lookup(const struct pw_map *map, uint32_t id)
|
|||
* \param data data to pass to \a func
|
||||
* \return the result of the last call to \a func or 0 when all callbacks returned 0.
|
||||
*/
|
||||
SPA_API_IMPL int pw_map_for_each(const struct pw_map *map,
|
||||
PW_API_MAP int pw_map_for_each(const struct pw_map *map,
|
||||
int (*func) (void *item_data, void *data), void *data)
|
||||
{
|
||||
union pw_map_item *item;
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
#include <spa/utils/list.h>
|
||||
#include <spa/buffer/buffer.h>
|
||||
|
||||
#define PW_API_MEM SPA_EXPORT
|
||||
#include <pipewire/log.h>
|
||||
#include <pipewire/map.h>
|
||||
#include <pipewire/mem.h>
|
||||
|
|
|
|||
|
|
@ -11,6 +11,10 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef PW_API_MEM
|
||||
#define PW_API_MEM static inline
|
||||
#endif
|
||||
|
||||
/** \defgroup pw_memblock Memory Blocks
|
||||
* Memory allocation and pools.
|
||||
*/
|
||||
|
|
@ -123,7 +127,7 @@ struct pw_memblock * pw_mempool_import(struct pw_mempool *pool,
|
|||
void pw_memblock_free(struct pw_memblock *mem);
|
||||
|
||||
/** Unref a memblock */
|
||||
SPA_API_IMPL void pw_memblock_unref(struct pw_memblock *mem)
|
||||
PW_API_MEM void pw_memblock_unref(struct pw_memblock *mem)
|
||||
{
|
||||
if (--mem->ref == 0)
|
||||
pw_memblock_free(mem);
|
||||
|
|
@ -173,7 +177,7 @@ struct pw_map_range {
|
|||
|
||||
/** Calculate parameters to mmap() memory into \a range so that
|
||||
* \a size bytes at \a offset can be mapped with mmap(). */
|
||||
SPA_API_IMPL void pw_map_range_init(struct pw_map_range *range,
|
||||
PW_API_MEM void pw_map_range_init(struct pw_map_range *range,
|
||||
uint32_t offset, uint32_t size,
|
||||
uint32_t page_size)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#include <spa/utils/result.h>
|
||||
#include <spa/debug/log.h>
|
||||
|
||||
#define PW_API_PROPERTIES SPA_EXPORT
|
||||
#include "pipewire/array.h"
|
||||
#include "pipewire/log.h"
|
||||
#include "pipewire/utils.h"
|
||||
|
|
|
|||
|
|
@ -15,6 +15,10 @@ extern "C" {
|
|||
#include <spa/utils/dict.h>
|
||||
#include <spa/utils/string.h>
|
||||
|
||||
#ifndef PW_API_PROPERTIES
|
||||
#define PW_API_PROPERTIES static inline
|
||||
#endif
|
||||
|
||||
/** \defgroup pw_properties Properties
|
||||
*
|
||||
* Properties are used to pass around arbitrary key/value pairs.
|
||||
|
|
@ -101,7 +105,7 @@ pw_properties_fetch_int64(const struct pw_properties *properties, const char *ke
|
|||
int
|
||||
pw_properties_fetch_bool(const struct pw_properties *properties, const char *key, bool *value);
|
||||
|
||||
SPA_API_IMPL uint32_t
|
||||
PW_API_PROPERTIES uint32_t
|
||||
pw_properties_get_uint32(const struct pw_properties *properties, const char *key, uint32_t deflt)
|
||||
{
|
||||
uint32_t val = deflt;
|
||||
|
|
@ -109,7 +113,7 @@ pw_properties_get_uint32(const struct pw_properties *properties, const char *key
|
|||
return val;
|
||||
}
|
||||
|
||||
SPA_API_IMPL int32_t
|
||||
PW_API_PROPERTIES int32_t
|
||||
pw_properties_get_int32(const struct pw_properties *properties, const char *key, int32_t deflt)
|
||||
{
|
||||
int32_t val = deflt;
|
||||
|
|
@ -117,7 +121,7 @@ pw_properties_get_int32(const struct pw_properties *properties, const char *key,
|
|||
return val;
|
||||
}
|
||||
|
||||
SPA_API_IMPL uint64_t
|
||||
PW_API_PROPERTIES uint64_t
|
||||
pw_properties_get_uint64(const struct pw_properties *properties, const char *key, uint64_t deflt)
|
||||
{
|
||||
uint64_t val = deflt;
|
||||
|
|
@ -125,7 +129,7 @@ pw_properties_get_uint64(const struct pw_properties *properties, const char *key
|
|||
return val;
|
||||
}
|
||||
|
||||
SPA_API_IMPL int64_t
|
||||
PW_API_PROPERTIES int64_t
|
||||
pw_properties_get_int64(const struct pw_properties *properties, const char *key, int64_t deflt)
|
||||
{
|
||||
int64_t val = deflt;
|
||||
|
|
@ -134,7 +138,7 @@ pw_properties_get_int64(const struct pw_properties *properties, const char *key,
|
|||
}
|
||||
|
||||
|
||||
SPA_API_IMPL bool
|
||||
PW_API_PROPERTIES bool
|
||||
pw_properties_get_bool(const struct pw_properties *properties, const char *key, bool deflt)
|
||||
{
|
||||
bool val = deflt;
|
||||
|
|
@ -152,31 +156,31 @@ pw_properties_iterate(const struct pw_properties *properties, void **state);
|
|||
#define PW_PROPERTIES_FLAG_COLORS (1<<4)
|
||||
int pw_properties_serialize_dict(FILE *f, const struct spa_dict *dict, uint32_t flags);
|
||||
|
||||
SPA_API_IMPL bool pw_properties_parse_bool(const char *value) {
|
||||
PW_API_PROPERTIES bool pw_properties_parse_bool(const char *value) {
|
||||
return spa_atob(value);
|
||||
}
|
||||
|
||||
SPA_API_IMPL int pw_properties_parse_int(const char *value) {
|
||||
PW_API_PROPERTIES int pw_properties_parse_int(const char *value) {
|
||||
int v;
|
||||
return spa_atoi32(value, &v, 0) ? v: 0;
|
||||
}
|
||||
|
||||
SPA_API_IMPL int64_t pw_properties_parse_int64(const char *value) {
|
||||
PW_API_PROPERTIES int64_t pw_properties_parse_int64(const char *value) {
|
||||
int64_t v;
|
||||
return spa_atoi64(value, &v, 0) ? v : 0;
|
||||
}
|
||||
|
||||
SPA_API_IMPL uint64_t pw_properties_parse_uint64(const char *value) {
|
||||
PW_API_PROPERTIES uint64_t pw_properties_parse_uint64(const char *value) {
|
||||
uint64_t v;
|
||||
return spa_atou64(value, &v, 0) ? v : 0;
|
||||
}
|
||||
|
||||
SPA_API_IMPL float pw_properties_parse_float(const char *value) {
|
||||
PW_API_PROPERTIES float pw_properties_parse_float(const char *value) {
|
||||
float v;
|
||||
return spa_atof(value, &v) ? v : 0.0f;
|
||||
}
|
||||
|
||||
SPA_API_IMPL double pw_properties_parse_double(const char *value) {
|
||||
PW_API_PROPERTIES double pw_properties_parse_double(const char *value) {
|
||||
double v;
|
||||
return spa_atod(value, &v) ? v : 0.0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue