[pulseaudio-commits] r2143 - /branches/prepare-0.9.10/src/pulsecore/endianmacros.h

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Thu Mar 27 14:24:03 PDT 2008


Author: lennart
Date: Thu Mar 27 22:24:03 2008
New Revision: 2143

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=2143&root=pulseaudio&view=rev
Log:
merge r2079 from trunk

Modified:
    branches/prepare-0.9.10/src/pulsecore/endianmacros.h

Modified: branches/prepare-0.9.10/src/pulsecore/endianmacros.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/prepare-0.9.10/src/pulsecore/endianmacros.h?rev=2143&root=pulseaudio&r1=2142&r2=2143&view=diff
==============================================================================
--- branches/prepare-0.9.10/src/pulsecore/endianmacros.h (original)
+++ branches/prepare-0.9.10/src/pulsecore/endianmacros.h Thu Mar 27 22:24:03 2008
@@ -47,11 +47,19 @@
 #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)
@@ -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




More information about the pulseaudio-commits mailing list