shithub: dumb

Download patch

ref: 8fdb02e9d7d831b6589665d7a849df0510afde35
parent: ded26d786f0836bef04f7b23a55581ca2e05d1c9
parent: 250580dbe710a99d40fb75d3393d31b05f452912
author: Christopher Snowhill <kode54@gmail.com>
date: Tue Mar 1 15:21:53 EST 2016

Merge pull request #26 from winterheart/examples

Fixing compilation examples on Linux

--- a/dumb/cmake/CMakeLists.txt
+++ b/dumb/cmake/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 2.6)
+cmake_minimum_required(VERSION 3.1)
 project(libdumb C)
 
 set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake-scripts)
@@ -121,7 +121,8 @@
 if(BUILD_EXAMPLES)
     add_executable(dumbout ../examples/dumbout.c)
     add_executable(dumbplay ../examples/dumbplay.c)
-
+    set_property(TARGET dumbout PROPERTY C_STANDARD 99)
+    set_property(TARGET dumbplay PROPERTY C_STANDARD 99)
     if(MINGW)
         target_link_libraries(dumbplay mingw32)
     endif()
--- 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;