misc/openalbridge/globals.h
changeset 3516 a8c673657b79
parent 3510 23145a950eae
parent 3515 3e8635f43972
child 3529 0e968ba12a84
equal deleted inserted replaced
3510:23145a950eae 3516:a8c673657b79
     1 /*
       
     2  * OpenAL Bridge - a simple portable library for OpenAL interface
       
     3  * Copyright (c) 2009 Vittorio Giovara <vittorio.giovara@gmail.com>
       
     4  *
       
     5  * This program is free software; you can redistribute it and/or modify
       
     6  * it under the terms of the GNU Lesser General Public License as published by
       
     7  * the Free Software Foundation; version 2 of the License
       
     8  *
       
     9  * This program is distributed in the hope that it will be useful,
       
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    12  * GNU Lesser General Public License for more details.
       
    13  *
       
    14  * You should have received a copy of the GNU Lesser General Public License
       
    15  * along with this program; if not, write to the Free Software
       
    16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
       
    17  */
       
    18 
       
    19 #ifndef _OALB_GLOBALS_H
       
    20 #define _OALB_GLOBALS_H
       
    21 
       
    22 #include <stdio.h>
       
    23 #include <stdlib.h>
       
    24 #include "al.h"
       
    25 
       
    26 #ifndef _WIN32
       
    27 #include <pthread.h>
       
    28 #include <syslog.h>
       
    29 #else
       
    30 #include <process.h>
       
    31 #endif
       
    32 
       
    33 
       
    34 // control debug verbosity
       
    35 #ifdef TRACE
       
    36 #ifndef DEBUG
       
    37 #define DEBUG
       
    38 #endif
       
    39 #endif
       
    40 
       
    41 // 1.0 02/03/10 - Defines cross-platform sleep, usleep, etc. [Wu Yongwei]
       
    42 #ifndef _SLEEP_H
       
    43 #define _SLEEP_H
       
    44 #ifdef _WIN32
       
    45 # if defined(_NEED_SLEEP_ONLY) && (defined(_MSC_VER) || defined(__MINGW32__))
       
    46 #  include <stdlib.h>
       
    47 #  define sleep(t) _sleep((t) * 1000)
       
    48 # else
       
    49 #  define WIN32_LEAN_AND_MEAN
       
    50 #  include <windows.h>
       
    51 #  define sleep(t)  Sleep((t) * 1000)
       
    52 # endif
       
    53 # ifndef _NEED_SLEEP_ONLY
       
    54 #  define msleep(t) Sleep(t)
       
    55 #  define usleep(t) Sleep((t) / 1000)
       
    56 # endif
       
    57 #else
       
    58 # include <unistd.h>
       
    59 # ifndef _NEED_SLEEP_ONLY
       
    60 #  define msleep(t) usleep((t) * 1000)
       
    61 # endif
       
    62 #endif
       
    63 #endif // _SLEEP_H
       
    64 
       
    65 
       
    66 // check compiler requirements
       
    67 #if !defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__)
       
    68 #warning __BIG_ENDIAN__ or __LITTLE_ENDIAN__ not found, going to set __LITTLE_ENDIAN__ as default
       
    69 #define __LITTLE_ENDIAN__ 1
       
    70 #endif
       
    71 
       
    72 /* use byteswap macros from the host system, hopefully optimized ones ;-)
       
    73  * or define our own version, simple, stupid, straight-forward... */
       
    74 #ifdef HAVE_BYTESWAP_H
       
    75 #include <byteswap.h>
       
    76 #else
       
    77 #define bswap_16(x)	(((x & 0xFF00) >> 8) | ((x & 0x00FF) << 8))
       
    78 #define bswap_32(x)	(((x & 0xFF000000) >> 24) | (((x) & 0x00FF0000) >> 8)  | \
       
    79                      ((x & 0x0000FF00) << 8)  | (((x) & 0x000000FF) << 24) )
       
    80 #endif /* HAVE_BYTESWAP_H */
       
    81 
       
    82 /* swap numbers accordingly to architecture automatically */
       
    83 #ifdef __LITTLE_ENDIAN__
       
    84 #define ENDIAN_LITTLE_32(x) x
       
    85 #define ENDIAN_BIG_32(x)    bswap_32(x)
       
    86 #define ENDIAN_LITTLE_16(x) x
       
    87 #define ENDIAN_BIG_16(x)    bswap_16(x)
       
    88 #elif __BIG_ENDIAN__
       
    89 #define ENDIAN_LITTLE_32(x) bswap_32(x)
       
    90 #define ENDIAN_BIG_32(x)    x
       
    91 #define ENDIAN_LITTLE_16(x) bswap_16(x)
       
    92 #define ENDIAN_BIG_16(x)    x
       
    93 #endif
       
    94 
       
    95 /*file format defines*/
       
    96 #define OGG_FILE_FORMAT         0x4F676753
       
    97 #define WAV_FILE_FORMAT         0x52494646
       
    98 #define WAV_HEADER_SUBCHUNK2ID  0x64617461
       
    99 
       
   100 
       
   101 #endif /*_OALB_GLOBALS_H*/