misc/openalbridge/globals.h
changeset 3362 8d3b4d19ce27
parent 3360 717b4e46e855
child 3364 e5403e2bf02c
equal deleted inserted replaced
3361:cfc6cd502f85 3362:8d3b4d19ce27
    38 
    38 
    39 #include "al.h"
    39 #include "al.h"
    40 #include "errlib.h"
    40 #include "errlib.h"
    41 
    41 
    42 
    42 
    43 /*control debug verbosity*/
    43 // control debug verbosity
    44 #ifdef TRACE
    44 #ifdef TRACE
    45 #ifndef DEBUG
    45 #ifndef DEBUG
    46 #define DEBUG
    46 #define DEBUG
    47 #endif
    47 #endif
    48 #endif
    48 #endif
    49 
    49 
    50 /** 1.0 02/03/10 - Defines cross-platform sleep, usleep, etc. [Wu Yongwei] **/
    50 // 1.0 02/03/10 - Defines cross-platform sleep, usleep, etc. [Wu Yongwei]
    51 #ifndef _SLEEP_H
    51 #ifndef _SLEEP_H
    52 #define _SLEEP_H
    52 #define _SLEEP_H
    53 #ifdef _WIN32
    53 #ifdef _WIN32
    54 # if defined(_NEED_SLEEP_ONLY) && (defined(_MSC_VER) || defined(__MINGW32__))
    54 # if defined(_NEED_SLEEP_ONLY) && (defined(_MSC_VER) || defined(__MINGW32__))
    55 #  include <stdlib.h>
    55 #  include <stdlib.h>
    67 # include <unistd.h>
    67 # include <unistd.h>
    68 # ifndef _NEED_SLEEP_ONLY
    68 # ifndef _NEED_SLEEP_ONLY
    69 #  define msleep(t) usleep((t) * 1000)
    69 #  define msleep(t) usleep((t) * 1000)
    70 # endif
    70 # endif
    71 #endif
    71 #endif
    72 #endif /* _SLEEP_H */
    72 #endif // _SLEEP_H
    73 
    73 
    74 
    74 
    75 /* check compiler requirements */    /*FIXME*/
    75 // check compiler requirements
    76 #if !defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__)
    76 #if !defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__)
    77 #warning __BIG_ENDIAN__ or __LITTLE_ENDIAN__ not found, going to set __LITTLE_ENDIAN__ as default
    77 #warning __BIG_ENDIAN__ or __LITTLE_ENDIAN__ not found, going to set __LITTLE_ENDIAN__ as default
    78 #define __LITTLE_ENDIAN__ 1
    78 #define __LITTLE_ENDIAN__ 1
    79 //#error Do not know the endianess of this architecture
       
    80 #endif
    79 #endif
    81 
    80 
    82 /* use byteswap macros from the host system, hopefully optimized ones ;-) 
    81 /* use byteswap macros from the host system, hopefully optimized ones ;-)
    83  * or define our own version, simple, stupid, straight-forward... */
    82  * or define our own version, simple, stupid, straight-forward... */
    84 #ifdef HAVE_BYTESWAP_H
    83 #ifdef HAVE_BYTESWAP_H
    85 #include <byteswap.h>
    84 #include <byteswap.h>
    86 #else        
    85 #else
    87 #define bswap_16(x)	((((x) & 0xFF00) >> 8) | (((x) & 0x00FF) << 8))
    86 #define bswap_16(x)	((((x) & 0xFF00) >> 8) | (((x) & 0x00FF) << 8))
    88 #define bswap_32(x)	((((x) & 0xFF000000) >> 24) | (((x) & 0x00FF0000) >> 8)  | \
    87 #define bswap_32(x)	((((x) & 0xFF000000) >> 24) | (((x) & 0x00FF0000) >> 8)  | \
    89 (((x) & 0x0000FF00) << 8)  | (((x) & 0x000000FF) << 24) )
    88 (((x) & 0x0000FF00) << 8)  | (((x) & 0x000000FF) << 24) )
    90 #endif /* HAVE_BYTESWAP_H */
    89 #endif /* HAVE_BYTESWAP_H */
    91 
    90 
    97 #define ENDIAN_BIG_16(x)    bswap_16(x)
    96 #define ENDIAN_BIG_16(x)    bswap_16(x)
    98 #elif __BIG_ENDIAN__
    97 #elif __BIG_ENDIAN__
    99 #define ENDIAN_LITTLE_32(x) bswap_32(x)
    98 #define ENDIAN_LITTLE_32(x) bswap_32(x)
   100 #define ENDIAN_BIG_32(x)    x
    99 #define ENDIAN_BIG_32(x)    x
   101 #define ENDIAN_LITTLE_16(x) bswap_16(x)
   100 #define ENDIAN_LITTLE_16(x) bswap_16(x)
   102 #define ENDIAN_BIG_16(x)    x    
   101 #define ENDIAN_BIG_16(x)    x
   103 #endif
   102 #endif
   104 
   103 
   105 
   104 /*file format defines*/
   106 #ifdef __CPLUSPLUS
       
   107 extern "C" {
       
   108 #endif 
       
   109     
       
   110     /*data type for WAV header*/
       
   111 #pragma pack(1)
       
   112     typedef struct _WAV_header_t {
       
   113         uint32_t ChunkID;
       
   114         uint32_t ChunkSize;
       
   115         uint32_t Format;
       
   116         uint32_t Subchunk1ID;
       
   117         uint32_t Subchunk1Size;
       
   118         uint16_t AudioFormat;
       
   119         uint16_t NumChannels;
       
   120         uint32_t SampleRate;
       
   121         uint32_t ByteRate;
       
   122         uint16_t BlockAlign;
       
   123         uint16_t BitsPerSample;
       
   124         uint32_t Subchunk2ID;
       
   125         uint32_t Subchunk2Size;
       
   126     } WAV_header_t;
       
   127 #pragma pack()
       
   128     
       
   129     /*data type for passing data between threads*/
       
   130 #pragma pack(1)
       
   131     typedef struct _fade_t {
       
   132         uint32_t index;
       
   133         uint16_t quantity;
       
   134     } fade_t;
       
   135 #pragma pack()
       
   136     
       
   137     
       
   138     /*file format defines*/
       
   139 #define OGG_FILE_FORMAT 0x4F676753
   105 #define OGG_FILE_FORMAT 0x4F676753
   140 #define WAV_FILE_FORMAT 0x52494646
   106 #define WAV_FILE_FORMAT 0x52494646
   141 #define WAV_HEADER_SUBCHUNK2ID 0x64617461
   107 #define WAV_HEADER_SUBCHUNK2ID 0x64617461
   142     
   108 
   143     char *prog;
   109 char *prog = "OpenAL subsystem";
   144     
       
   145 #ifdef __CPLUSPLUS
       
   146 }
       
   147 #endif
       
   148 
   110 
   149 #endif /*_OALB_GLOBALS_H*/
   111 #endif /*_OALB_GLOBALS_H*/