[pulseaudio-discuss] [PATCH] pulse: Move PA_CLAMP* to pulse/
arun at accosted.net
arun at accosted.net
Wed Mar 11 04:08:06 PDT 2015
From: Arun Raghavan <git at arunraghavan.net>
We use PA_CLAMP_UNLIKELY in volume.h, which clients might use, so we
need to make sure the macros is available in exported headers.
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=89515
---
src/pulse/util.h | 31 +++++++++++++++++++++++++++++++
src/pulse/volume.h | 1 +
src/pulsecore/macro.h | 28 ----------------------------
src/pulsecore/sconv-s16le.c | 2 ++
src/pulsecore/sconv.c | 2 ++
5 files changed, 36 insertions(+), 28 deletions(-)
diff --git a/src/pulse/util.h b/src/pulse/util.h
index e4a62da..6074638 100644
--- a/src/pulse/util.h
+++ b/src/pulse/util.h
@@ -29,6 +29,37 @@
/** \file
* Assorted utility functions */
+/* The clamp macros aren't meant to be exported, per se, they're just here for our own use */
+
+#ifdef __GNUC__
+#define PA_CLAMP(x, low, high) \
+ __extension__ ({ \
+ typeof(x) _x = (x); \
+ typeof(low) _low = (low); \
+ typeof(high) _high = (high); \
+ ((_x > _high) ? _high : ((_x < _low) ? _low : _x)); \
+ })
+#else
+#define PA_CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
+#endif
+
+#ifdef __GNUC__
+#define PA_CLAMP_UNLIKELY(x, low, high) \
+ __extension__ ({ \
+ typeof(x) _x = (x); \
+ typeof(low) _low = (low); \
+ typeof(high) _high = (high); \
+ (PA_UNLIKELY(_x > _high) ? _high : (PA_UNLIKELY(_x < _low) ? _low : _x)); \
+ })
+#else
+#define PA_CLAMP_UNLIKELY(x, low, high) (PA_UNLIKELY((x) > (high)) ? (high) : (PA_UNLIKELY((x) < (low)) ? (low) : (x)))
+#endif
+
+/* We don't define a PA_CLAMP_LIKELY here, because it doesn't really
+ * make sense: we cannot know if it is more likely that the values is
+ * lower or greater than the boundaries.*/
+
+
PA_C_DECL_BEGIN
/** Return the current username in the specified string buffer. */
diff --git a/src/pulse/volume.h b/src/pulse/volume.h
index ec777b2..a0acde5 100644
--- a/src/pulse/volume.h
+++ b/src/pulse/volume.h
@@ -28,6 +28,7 @@
#include <pulse/gccmacro.h>
#include <pulse/sample.h>
#include <pulse/channelmap.h>
+#include <pulse/util.h>
#include <pulse/version.h>
/** \page volume Volume Control
diff --git a/src/pulsecore/macro.h b/src/pulsecore/macro.h
index 1716f81..bd98708 100644
--- a/src/pulsecore/macro.h
+++ b/src/pulsecore/macro.h
@@ -121,34 +121,6 @@ static inline size_t PA_PAGE_ALIGN(size_t l) {
#endif
#ifdef __GNUC__
-#define PA_CLAMP(x, low, high) \
- __extension__ ({ \
- typeof(x) _x = (x); \
- typeof(low) _low = (low); \
- typeof(high) _high = (high); \
- ((_x > _high) ? _high : ((_x < _low) ? _low : _x)); \
- })
-#else
-#define PA_CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
-#endif
-
-#ifdef __GNUC__
-#define PA_CLAMP_UNLIKELY(x, low, high) \
- __extension__ ({ \
- typeof(x) _x = (x); \
- typeof(low) _low = (low); \
- typeof(high) _high = (high); \
- (PA_UNLIKELY(_x > _high) ? _high : (PA_UNLIKELY(_x < _low) ? _low : _x)); \
- })
-#else
-#define PA_CLAMP_UNLIKELY(x, low, high) (PA_UNLIKELY((x) > (high)) ? (high) : (PA_UNLIKELY((x) < (low)) ? (low) : (x)))
-#endif
-
-/* We don't define a PA_CLAMP_LIKELY here, because it doesn't really
- * make sense: we cannot know if it is more likely that the values is
- * lower or greater than the boundaries.*/
-
-#ifdef __GNUC__
#define PA_ROUND_UP(a, b) \
__extension__ ({ \
typeof(a) _a = (a); \
diff --git a/src/pulsecore/sconv-s16le.c b/src/pulsecore/sconv-s16le.c
index c503e0e..440aba7 100644
--- a/src/pulsecore/sconv-s16le.c
+++ b/src/pulsecore/sconv-s16le.c
@@ -27,6 +27,8 @@
#include <stdio.h>
#include <math.h>
+#include <pulse/util.h>
+
#include <pulsecore/sconv.h>
#include <pulsecore/macro.h>
#include <pulsecore/endianmacros.h>
diff --git a/src/pulsecore/sconv.c b/src/pulsecore/sconv.c
index 0781b6e..24dd54f 100644
--- a/src/pulsecore/sconv.c
+++ b/src/pulsecore/sconv.c
@@ -26,6 +26,8 @@
#include <stdlib.h>
#include <math.h>
+#include <pulse/util.h>
+
#include <pulsecore/g711.h>
#include <pulsecore/macro.h>
#include <pulsecore/endianmacros.h>
--
2.1.0
More information about the pulseaudio-discuss
mailing list