openalbridge/globals.h
changeset 2415 35d09cbf819a
parent 2261 57e99c908e7c
child 2417 f7ed1ea25050
equal deleted inserted replaced
2414:fd9ca82077d8 2415:35d09cbf819a
    30 #include <process.h>
    30 #include <process.h>
    31 #endif
    31 #endif
    32 
    32 
    33 #include "al.h"
    33 #include "al.h"
    34 
    34 
       
    35 
       
    36 /** 1.0 02/03/10 - Defines cross-platform sleep, usleep, etc. [Wu Yongwei] **/
    35 #ifndef _SLEEP_H
    37 #ifndef _SLEEP_H
    36 #define _SLEEP_H
    38 #define _SLEEP_H
    37 /** 1.0 02/03/10 - Defines cross-platform sleep, usleep, etc. * By Wu Yongwei **/
       
    38 #ifdef _WIN32
    39 #ifdef _WIN32
    39 # if defined(_NEED_SLEEP_ONLY) && (defined(_MSC_VER) || defined(__MINGW32__))
    40 # if defined(_NEED_SLEEP_ONLY) && (defined(_MSC_VER) || defined(__MINGW32__))
    40 #  include <stdlib.h>
    41 #  include <stdlib.h>
    41 #  define sleep(t) _sleep((t) * 1000)
    42 #  define sleep(t) _sleep((t) * 1000)
    42 # else
    43 # else
    54 #  define msleep(t) usleep((t) * 1000)
    55 #  define msleep(t) usleep((t) * 1000)
    55 # endif
    56 # endif
    56 #endif
    57 #endif
    57 #endif /* _SLEEP_H */
    58 #endif /* _SLEEP_H */
    58 
    59 
    59 #ifdef HAVE_BYTESWAP_H
       
    60 /* use byteswap macros from the host system, hopefully optimized ones ;-) */
       
    61 #include <byteswap.h>
       
    62 #else
       
    63 /* define our own version, simple, stupid, straight-forward... */
       
    64 
    60 
    65 #define bswap_16(x)	((((x) & 0xFF00) >> 8) | (((x) & 0x00FF) << 8))
       
    66 
    61 
    67 #define bswap_32(x)	((((x) & 0xFF000000) >> 24) | (((x) & 0x00FF0000) >> 8)  | \
       
    68                          (((x) & 0x0000FF00) << 8)  | (((x) & 0x000000FF) << 24) )
       
    69 
    62 
    70 #endif /* HAVE_BYTESWAP_H */
    63 
       
    64 
    71 
    65 
    72 #ifdef __CPLUSPLUS
    66 #ifdef __CPLUSPLUS
    73 extern "C" {
    67 extern "C" {
    74 #endif 
    68 #endif 
    75     
    69         
    76     /*data type for WAV header*/
    70 /*data type for WAV header*/
    77 #pragma pack(1)
    71 #pragma pack(1)
    78     typedef struct _WAV_header_t {
    72         typedef struct _WAV_header_t {
    79         uint32_t ChunkID;
    73                 uint32_t ChunkID;
    80         uint32_t ChunkSize;
    74                 uint32_t ChunkSize;
    81         uint32_t Format;
    75                 uint32_t Format;
    82         uint32_t Subchunk1ID;
    76                 uint32_t Subchunk1ID;
    83         uint32_t Subchunk1Size;
    77                 uint32_t Subchunk1Size;
    84         uint16_t AudioFormat;
    78                 uint16_t AudioFormat;
    85         uint16_t NumChannels;
    79                 uint16_t NumChannels;
    86         uint32_t SampleRate;
    80                 uint32_t SampleRate;
    87         uint32_t ByteRate;
    81                 uint32_t ByteRate;
    88         uint16_t BlockAlign;
    82                 uint16_t BlockAlign;
    89         uint16_t BitsPerSample;
    83                 uint16_t BitsPerSample;
    90         uint32_t Subchunk2ID;
    84                 uint32_t Subchunk2ID;
    91         uint32_t Subchunk2Size;
    85                 uint32_t Subchunk2Size;
    92     } WAV_header_t;
    86         } WAV_header_t;
    93 #pragma pack()
    87 #pragma pack()
    94     
    88         
    95     /*data type for passing data between threads*/
    89 /*data type for passing data between threads*/
    96 #pragma pack(1)
    90 #pragma pack(1)
    97     typedef struct _fade_t {
    91         typedef struct _fade_t {
    98         uint32_t index;
    92                 uint32_t index;
    99         uint16_t quantity;
    93                 uint16_t quantity;
   100     } fade_t;
    94         } fade_t;
   101 #pragma pack()
    95 #pragma pack()
   102     
    96 
   103     /*other defines*/
    97         
   104 #define FADE_IN	 AL_TRUE
    98 /*file format defines*/
   105 #define FADE_OUT AL_FALSE
    99 #define OGG_FILE_FORMAT 0x4F676753
   106     
   100 #define WAV_FILE_FORMAT 0x52494646
       
   101 #define WAV_HEADER_SUBCHUNK2ID 0x64617461
       
   102       
       
   103 
       
   104 /*other defines*/
       
   105 #define FADE_IN	 0
       
   106 #define FADE_OUT 1
       
   107         
   107 #ifdef __CPLUSPLUS
   108 #ifdef __CPLUSPLUS
   108 }
   109 }
   109 #endif
   110 #endif
   110 
   111 
   111 #endif /*_OALB_GLOBALS_H*/
   112 #endif /*_OALB_GLOBALS_H*/