shithub: dumb

Download patch

ref: bdaa547981e512eb1404ba773212cc9b24460a4e
parent: ded26d786f0836bef04f7b23a55581ca2e05d1c9
author: Azamat H. Hackimov <azamat.hackimov@gmail.com>
date: Mon Feb 29 12:51:52 EST 2016

Avoid to clashing with LITTLE_ENDIAN in Linux.

--- a/dumb/examples/dumbout.c
+++ b/dumb/examples/dumbout.c
@@ -9,8 +9,8 @@
 #define is_bigendian() ((*(char*)&endian_test) == 0)
 
 enum ENDIANNESS {
-    LITTLE_ENDIAN = 0,
-    BIG_ENDIAN
+    DUMB_LITTLE_ENDIAN = 0,
+    DUMB_BIG_ENDIAN
 };
 
 typedef struct {
@@ -48,7 +48,7 @@
     settings.freq = 44100;
     settings.n_channels = 2;
     settings.bits = 16;
-    settings.endianness = LITTLE_ENDIAN;
+    settings.endianness = DUMB_LITTLE_ENDIAN;
     settings.is_unsigned = false;
     settings.volume = 1.0f;
     settings.delay = 0.0f;
@@ -107,7 +107,7 @@
     }
 
     // Handle the switch options
-    if(arg_bigendian->count > 0) { settings.endianness = BIG_ENDIAN; }
+    if(arg_bigendian->count > 0) { settings.endianness = DUMB_BIG_ENDIAN; }
     if(arg_eight->count > 0) { settings.bits = 8; }
     if(arg_unsigned->count > 0) { settings.is_unsigned = true; }
     if(arg_mono->count > 0) { settings.n_channels = 1; }
@@ -184,8 +184,8 @@
     int read_bytes;
 
     // If output endianness is different than machine endianness, and output is 16 bits, reorder bytes.
-    int switch_endianness = ((is_bigendian() && settings.endianness == LITTLE_ENDIAN) ||
-                            (!is_bigendian() && settings.endianness == BIG_ENDIAN));
+    int switch_endianness = ((is_bigendian() && settings.endianness == DUMB_LITTLE_ENDIAN) ||
+                            (!is_bigendian() && settings.endianness == DUMB_BIG_ENDIAN));
 
     // Write the initial delay to the file if one was requested.
     long d = ((long)floor(settings.delay * settings.freq + 0.5f)) * settings.n_channels * (settings.bits / 8);
@@ -193,7 +193,7 @@
         // Fill the buffer with silence. Remember to take into account endianness
         if(settings.is_unsigned) {
             if(settings.bits == 16) {
-                if(settings.endianness == BIG_ENDIAN) {
+                if(settings.endianness == DUMB_BIG_ENDIAN) {
                     // Unsigned 16bits big endian
                     for(int i = 0; i < streamer.bufsize; i += 2) {
                         buffer[i  ] = (char)0x80;