summaryrefslogtreecommitdiffstats
path: root/src/pulsecore
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2007-11-24 16:23:19 +0000
committerLennart Poettering <lennart@poettering.net>2007-11-24 16:23:19 +0000
commit7a4242522eb56066e59ce5e40ee5ed6e8b82861e (patch)
tree916b98599902e2e74982f634f63c1c71becca18d /src/pulsecore
parentca0c5af3234740bb0f568b8fe6ced34349906df2 (diff)
add new endianess macros for FLOAT32
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@2079 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src/pulsecore')
-rw-r--r--src/pulsecore/endianmacros.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/pulsecore/endianmacros.h b/src/pulsecore/endianmacros.h
index 05d3262f..6b80246b 100644
--- a/src/pulsecore/endianmacros.h
+++ b/src/pulsecore/endianmacros.h
@@ -47,12 +47,20 @@
#define PA_UINT32_SWAP(x) ( (uint32_t) ( ((uint32_t) x >> 24) | ((uint32_t) x << 24) | (((uint32_t) x & 0xFF00) << 8) | ((((uint32_t) x) >> 8) & 0xFF00) ) )
#endif
+static inline float PA_FLOAT32_SWAP(float x) {
+ uint32_t i = *(uint32_t*) &x;
+ i = PA_UINT32_SWAP(i);
+ return *(float*) &i;
+}
+
#define PA_MAYBE_INT16_SWAP(c,x) ((c) ? PA_INT32_SWAP(x) : x)
#define PA_MAYBE_UINT16_SWAP(c,x) ((c) ? PA_UINT32_SWAP(x) : x)
#define PA_MAYBE_INT32_SWAP(c,x) ((c) ? PA_INT32_SWAP(x) : x)
#define PA_MAYBE_UINT32_SWAP(c,x) ((c) ? PA_UINT32_SWAP(x) : x)
+#define PA_MAYBE_FLOAT32_SWAP(c,x) ((c) ? PA_FLOAT32_SWAP(x) : x)
+
#ifdef WORDS_BIGENDIAN
#define PA_INT16_FROM_LE(x) PA_INT16_SWAP(x)
#define PA_INT16_FROM_BE(x) ((int16_t)(x))
@@ -77,6 +85,9 @@
#define PA_UINT32_TO_LE(x) PA_UINT32_SWAP(x)
#define PA_UINT32_TO_BE(x) ((uint32_t)(x))
+
+ #define PA_FLOAT32_TO_LE(x) PA_FLOAT32_SWAP(x)
+ #define PA_FLOAT32_TO_BE(x) ((float) (x))
#else
#define PA_INT16_FROM_LE(x) ((int16_t)(x))
#define PA_INT16_FROM_BE(x) PA_INT16_SWAP(x)
@@ -101,6 +112,9 @@
#define PA_UINT32_TO_LE(x) ((uint32_t)(x))
#define PA_UINT32_TO_BE(x) PA_UINT32_SWAP(x)
+
+ #define PA_FLOAT32_TO_LE(x) ((float) (x))
+ #define PA_FLOAT32_TO_BE(x) PA_FLOAT32_SWAP(x)
#endif
#endif