keys: don't remove deprecated symbols by default

Add a new macro to mark deprecated keys. The macro will emit a warning
about the symbol being deprecated.
PW_ENABLE_DEPRECATED will suppress the deprecation warning.
Add PW_REMOVE_DEPRECATED to completely remove the deprecated symbols.

Fixes #2952
This commit is contained in:
Wim Taymans 2023-01-17 11:58:04 +01:00
parent ccedf1722a
commit a979c0f430
2 changed files with 12 additions and 5 deletions

View file

@ -29,6 +29,7 @@
extern "C" { extern "C" {
#endif #endif
#include <pipewire/utils.h>
/** /**
* \defgroup pw_keys Key Names * \defgroup pw_keys Key Names
* *
@ -337,14 +338,14 @@ extern "C" {
#define PW_KEY_VIDEO_FORMAT "video.format" /**< a video format */ #define PW_KEY_VIDEO_FORMAT "video.format" /**< a video format */
#define PW_KEY_VIDEO_SIZE "video.size" /**< a video size as "<width>x<height" */ #define PW_KEY_VIDEO_SIZE "video.size" /**< a video size as "<width>x<height" */
#ifdef PW_ENABLE_DEPRECATED
#define PW_KEY_PRIORITY_MASTER "priority.master" /**< deprecated */
#define PW_KEY_NODE_TARGET "node.target" /**< deprecated since 0.3.64, use target.object. */
#endif /* PW_ENABLE_DEPRECATED */
#define PW_KEY_TARGET_OBJECT "target.object" /**< a target object to link to. This can be #define PW_KEY_TARGET_OBJECT "target.object" /**< a target object to link to. This can be
* and object name or object.serial */ * and object name or object.serial */
#ifndef PW_REMOVE_DEPRECATED
#define PW_KEY_PRIORITY_MASTER PW_DEPRECATED("priority.master") /**< deprecated, use priority.driver */
#define PW_KEY_NODE_TARGET PW_DEPRECATED("node.target") /**< deprecated since 0.3.64, use target.object. */
#endif /* PW_REMOVE_DEPRECATED */
/** \} /** \}
*/ */

View file

@ -94,6 +94,12 @@ ssize_t pw_getrandom(void *buf, size_t buflen, unsigned int flags);
void* pw_reallocarray(void *ptr, size_t nmemb, size_t size); void* pw_reallocarray(void *ptr, size_t nmemb, size_t size);
#ifdef PW_ENABLE_DEPRECATED
#define PW_DEPRECATED(v) (v)
#else
#define PW_DEPRECATED(v) ({ __typeof__(v) _v SPA_DEPRECATED = (v); (void)_v; (v); })
#endif /* PW_ENABLE_DEPRECATED */
/** /**
* \} * \}
*/ */