openalbridge/globals.h
author koda
Tue, 30 Jun 2009 14:59:25 +0000
changeset 2214 eacb5b19d587
parent 2213 bd51bbf06033
child 2215 1d78579e06c2
permissions -rw-r--r--
-new FindOggVorbis, should work everywhere now -reverted variables types in openalbridge -removal of useless winstdint.h
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2212
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
     1
/*
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
     2
 * OpenAL Bridge - a simple portable library for OpenAL interface
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
     3
 * Copyright (c) 2009 Vittorio Giovara <vittorio.giovara@gmail.com>
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
     4
 *
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
     8
 *
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    12
 * GNU General Public License for more details.
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    13
 *
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    17
 */
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    18
2213
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents: 2212
diff changeset
    19
#ifndef _OALB_GLOBALS_H
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents: 2212
diff changeset
    20
#define _OALB_GLOBALS_H
2212
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    21
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    22
#include <stdio.h>
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    23
#include <stdlib.h>
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    24
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    25
#ifndef _WIN32
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    26
#include <pthread.h>
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    27
#else
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    28
#include <process.h>
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    29
#endif
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    30
2213
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents: 2212
diff changeset
    31
#include "al.h"
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents: 2212
diff changeset
    32
2212
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    33
#ifndef _SLEEP_H
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    34
#define _SLEEP_H
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    35
/** 1.0 02/03/10 - Defines cross-platform sleep, usleep, etc. * By Wu Yongwei **/
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    36
#ifdef _WIN32
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    37
# if defined(_NEED_SLEEP_ONLY) && (defined(_MSC_VER) || defined(__MINGW32__))
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    38
#  include <stdlib.h>
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    39
#  define sleep(t) _sleep((t) * 1000)
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    40
# else
2213
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents: 2212
diff changeset
    41
#  define WIN32_LEAN_AND_MEAN
2212
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    42
#  include <windows.h>
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    43
#  define sleep(t)  Sleep((t) * 1000)
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    44
# endif
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    45
# ifndef _NEED_SLEEP_ONLY
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    46
#  define msleep(t) Sleep(t)
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    47
#  define usleep(t) Sleep((t) / 1000)
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    48
# endif
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    49
#else
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    50
# include <unistd.h>
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    51
# ifndef _NEED_SLEEP_ONLY
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    52
#  define msleep(t) usleep((t) * 1000)
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    53
# endif
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    54
#endif
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    55
#endif /* _SLEEP_H */
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    56
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    57
#ifdef HAVE_BYTESWAP_H
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    58
/* use byteswap macros from the host system, hopefully optimized ones ;-) */
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    59
#include <byteswap.h>
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    60
#else
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    61
/* define our own version, simple, stupid, straight-forward... */
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    62
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    63
#define bswap_16(x)	((((x) & 0xFF00) >> 8) | (((x) & 0x00FF) << 8))
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    64
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    65
#define bswap_32(x)	((((x) & 0xFF000000) >> 24) | \
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    66
(((x) & 0x00FF0000) >> 8)  | \
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    67
(((x) & 0x0000FF00) << 8)  | \
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    68
(((x) & 0x000000FF) << 24) )
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    69
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    70
#endif /* HAVE_BYTESWAP_H */
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    71
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    72
#ifdef __CPLUSPLUS
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    73
extern "C" {
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    74
#endif 
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    75
	
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    76
	/*data type for WAV header*/
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    77
#pragma pack(1)
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    78
	typedef struct _WAV_header_t {
2214
eacb5b19d587 -new FindOggVorbis, should work everywhere now
koda
parents: 2213
diff changeset
    79
		int ChunkID;
eacb5b19d587 -new FindOggVorbis, should work everywhere now
koda
parents: 2213
diff changeset
    80
		int ChunkSize;
eacb5b19d587 -new FindOggVorbis, should work everywhere now
koda
parents: 2213
diff changeset
    81
		int Format;
eacb5b19d587 -new FindOggVorbis, should work everywhere now
koda
parents: 2213
diff changeset
    82
		int Subchunk1ID;
eacb5b19d587 -new FindOggVorbis, should work everywhere now
koda
parents: 2213
diff changeset
    83
		int Subchunk1Size;
eacb5b19d587 -new FindOggVorbis, should work everywhere now
koda
parents: 2213
diff changeset
    84
		short int AudioFormat;
eacb5b19d587 -new FindOggVorbis, should work everywhere now
koda
parents: 2213
diff changeset
    85
		short int NumChannels;
eacb5b19d587 -new FindOggVorbis, should work everywhere now
koda
parents: 2213
diff changeset
    86
		int SampleRate;
eacb5b19d587 -new FindOggVorbis, should work everywhere now
koda
parents: 2213
diff changeset
    87
		int ByteRate;
eacb5b19d587 -new FindOggVorbis, should work everywhere now
koda
parents: 2213
diff changeset
    88
		short int BlockAlign;
eacb5b19d587 -new FindOggVorbis, should work everywhere now
koda
parents: 2213
diff changeset
    89
		short int BitsPerSample;
eacb5b19d587 -new FindOggVorbis, should work everywhere now
koda
parents: 2213
diff changeset
    90
		int Subchunk2ID;
eacb5b19d587 -new FindOggVorbis, should work everywhere now
koda
parents: 2213
diff changeset
    91
		int Subchunk2Size;
2212
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    92
	} WAV_header_t;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    93
#pragma pack()
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    94
	
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    95
	/*data type for passing data between threads*/
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    96
	typedef struct _fade_t {
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    97
		int index;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    98
		unsigned int quantity;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    99
	} fade_t;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   100
	
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   101
	/*other defines*/
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   102
#define FADE_IN		11
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   103
#define FADE_OUT	12
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   104
	
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   105
#ifdef __CPLUSPLUS
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   106
}
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   107
#endif
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   108
2213
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents: 2212
diff changeset
   109
#endif /*_OALB_GLOBALS_H*/