openalbridge/globals.h
author koda
Sun, 11 Oct 2009 16:03:56 +0000
changeset 2415 35d09cbf819a
parent 2261 57e99c908e7c
child 2417 f7ed1ea25050
permissions -rw-r--r--
OpenALBridge updates - fix problems when building for PPC targets - gives more precise error messages
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
2257
7eb31efcfb9b updates licence and fix a memory leak (which was consuming iphone memory)
koda
parents: 2216
diff changeset
     6
 * it under the terms of the GNU Lesser General Public License as published by
2212
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
2257
7eb31efcfb9b updates licence and fix a memory leak (which was consuming iphone memory)
koda
parents: 2216
diff changeset
    12
 * GNU Lesser General Public License for more details.
2212
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    13
 *
2257
7eb31efcfb9b updates licence and fix a memory leak (which was consuming iphone memory)
koda
parents: 2216
diff changeset
    14
 * You should have received a copy of the GNU Lesser General Public License
2212
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>
2215
1d78579e06c2 regression of previous commit, stdint.h in use
koda
parents: 2214
diff changeset
    24
#include <stdint.h>
2259
ca42efdce3ce fix indentation and other cosmetic changes to lib
koda
parents: 2257
diff changeset
    25
#include <string.h>
2212
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    26
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    27
#ifndef _WIN32
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    28
#include <pthread.h>
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    29
#else
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    30
#include <process.h>
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    31
#endif
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    32
2213
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents: 2212
diff changeset
    33
#include "al.h"
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents: 2212
diff changeset
    34
2415
35d09cbf819a OpenALBridge updates
koda
parents: 2261
diff changeset
    35
35d09cbf819a OpenALBridge updates
koda
parents: 2261
diff changeset
    36
/** 1.0 02/03/10 - Defines cross-platform sleep, usleep, etc. [Wu Yongwei] **/
2212
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    37
#ifndef _SLEEP_H
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    38
#define _SLEEP_H
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    39
#ifdef _WIN32
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    40
# if defined(_NEED_SLEEP_ONLY) && (defined(_MSC_VER) || defined(__MINGW32__))
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    41
#  include <stdlib.h>
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    42
#  define sleep(t) _sleep((t) * 1000)
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    43
# else
2213
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents: 2212
diff changeset
    44
#  define WIN32_LEAN_AND_MEAN
2212
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    45
#  include <windows.h>
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    46
#  define sleep(t)  Sleep((t) * 1000)
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    47
# endif
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    48
# ifndef _NEED_SLEEP_ONLY
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    49
#  define msleep(t) Sleep(t)
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    50
#  define usleep(t) Sleep((t) / 1000)
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    51
# endif
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    52
#else
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    53
# include <unistd.h>
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    54
# ifndef _NEED_SLEEP_ONLY
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    55
#  define msleep(t) usleep((t) * 1000)
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    56
# endif
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    57
#endif
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    58
#endif /* _SLEEP_H */
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    59
2415
35d09cbf819a OpenALBridge updates
koda
parents: 2261
diff changeset
    60
35d09cbf819a OpenALBridge updates
koda
parents: 2261
diff changeset
    61
2212
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    62
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    63
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    64
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    65
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    66
#ifdef __CPLUSPLUS
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    67
extern "C" {
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    68
#endif 
2415
35d09cbf819a OpenALBridge updates
koda
parents: 2261
diff changeset
    69
        
35d09cbf819a OpenALBridge updates
koda
parents: 2261
diff changeset
    70
/*data type for WAV header*/
2212
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    71
#pragma pack(1)
2415
35d09cbf819a OpenALBridge updates
koda
parents: 2261
diff changeset
    72
        typedef struct _WAV_header_t {
35d09cbf819a OpenALBridge updates
koda
parents: 2261
diff changeset
    73
                uint32_t ChunkID;
35d09cbf819a OpenALBridge updates
koda
parents: 2261
diff changeset
    74
                uint32_t ChunkSize;
35d09cbf819a OpenALBridge updates
koda
parents: 2261
diff changeset
    75
                uint32_t Format;
35d09cbf819a OpenALBridge updates
koda
parents: 2261
diff changeset
    76
                uint32_t Subchunk1ID;
35d09cbf819a OpenALBridge updates
koda
parents: 2261
diff changeset
    77
                uint32_t Subchunk1Size;
35d09cbf819a OpenALBridge updates
koda
parents: 2261
diff changeset
    78
                uint16_t AudioFormat;
35d09cbf819a OpenALBridge updates
koda
parents: 2261
diff changeset
    79
                uint16_t NumChannels;
35d09cbf819a OpenALBridge updates
koda
parents: 2261
diff changeset
    80
                uint32_t SampleRate;
35d09cbf819a OpenALBridge updates
koda
parents: 2261
diff changeset
    81
                uint32_t ByteRate;
35d09cbf819a OpenALBridge updates
koda
parents: 2261
diff changeset
    82
                uint16_t BlockAlign;
35d09cbf819a OpenALBridge updates
koda
parents: 2261
diff changeset
    83
                uint16_t BitsPerSample;
35d09cbf819a OpenALBridge updates
koda
parents: 2261
diff changeset
    84
                uint32_t Subchunk2ID;
35d09cbf819a OpenALBridge updates
koda
parents: 2261
diff changeset
    85
                uint32_t Subchunk2Size;
35d09cbf819a OpenALBridge updates
koda
parents: 2261
diff changeset
    86
        } WAV_header_t;
2212
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    87
#pragma pack()
2415
35d09cbf819a OpenALBridge updates
koda
parents: 2261
diff changeset
    88
        
35d09cbf819a OpenALBridge updates
koda
parents: 2261
diff changeset
    89
/*data type for passing data between threads*/
2216
82e7da49c26a -Smaxx' patch: checks for initialized openal + disables sound options if openal init fails
koda
parents: 2215
diff changeset
    90
#pragma pack(1)
2415
35d09cbf819a OpenALBridge updates
koda
parents: 2261
diff changeset
    91
        typedef struct _fade_t {
35d09cbf819a OpenALBridge updates
koda
parents: 2261
diff changeset
    92
                uint32_t index;
35d09cbf819a OpenALBridge updates
koda
parents: 2261
diff changeset
    93
                uint16_t quantity;
35d09cbf819a OpenALBridge updates
koda
parents: 2261
diff changeset
    94
        } fade_t;
2216
82e7da49c26a -Smaxx' patch: checks for initialized openal + disables sound options if openal init fails
koda
parents: 2215
diff changeset
    95
#pragma pack()
2415
35d09cbf819a OpenALBridge updates
koda
parents: 2261
diff changeset
    96
35d09cbf819a OpenALBridge updates
koda
parents: 2261
diff changeset
    97
        
35d09cbf819a OpenALBridge updates
koda
parents: 2261
diff changeset
    98
/*file format defines*/
35d09cbf819a OpenALBridge updates
koda
parents: 2261
diff changeset
    99
#define OGG_FILE_FORMAT 0x4F676753
35d09cbf819a OpenALBridge updates
koda
parents: 2261
diff changeset
   100
#define WAV_FILE_FORMAT 0x52494646
35d09cbf819a OpenALBridge updates
koda
parents: 2261
diff changeset
   101
#define WAV_HEADER_SUBCHUNK2ID 0x64617461
35d09cbf819a OpenALBridge updates
koda
parents: 2261
diff changeset
   102
      
35d09cbf819a OpenALBridge updates
koda
parents: 2261
diff changeset
   103
35d09cbf819a OpenALBridge updates
koda
parents: 2261
diff changeset
   104
/*other defines*/
35d09cbf819a OpenALBridge updates
koda
parents: 2261
diff changeset
   105
#define FADE_IN	 0
35d09cbf819a OpenALBridge updates
koda
parents: 2261
diff changeset
   106
#define FADE_OUT 1
35d09cbf819a OpenALBridge updates
koda
parents: 2261
diff changeset
   107
        
2212
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   108
#ifdef __CPLUSPLUS
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   109
}
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   110
#endif
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   111
2213
bd51bbf06033 -Smaxx's porting of the library to MSVC compilers
koda
parents: 2212
diff changeset
   112
#endif /*_OALB_GLOBALS_H*/