openalbridge/wrappers.h
author koda
Mon, 29 Jun 2009 20:01:05 +0000
changeset 2211 288360b78f30
parent 2210 1cb7118a77dd
child 2212 6b5da1a2765a
permissions -rw-r--r--
- fade in/out functions merged, but kept binary compatibility - reworked memory initialization, now uses less memory and allocates more only when needed - other fixes to openalbridge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2191
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
     1
/*
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
     2
 * OpenAL Bridge - a simple portable library for OpenAL interface
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
     3
 * Copyright (c) 2009 Vittorio Giovara <vittorio.giovara@gmail.com>
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
     4
 *
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
     8
 *
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    12
 * GNU General Public License for more details.
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    13
 *
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    17
 */
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    18
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    19
#include <stdio.h>
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    20
#include <stdlib.h>
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    21
#include "al.h"
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    22
2210
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    23
#ifndef _WIN32
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    24
#include <pthread.h>
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    25
#include <stdint.h>
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    26
#else
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    27
#define WIN32_LEAN_AND_MEAN
2211
288360b78f30 - fade in/out functions merged, but kept binary compatibility
koda
parents: 2210
diff changeset
    28
#include <process.h>
2210
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    29
#include "winstdint.h"
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    30
#endif
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    31
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    32
#ifndef _SLEEP_H
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    33
#define _SLEEP_H
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    34
/** 1.0 02/03/10 - Defines cross-platform sleep, usleep, etc. * By Wu Yongwei **/
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    35
#ifdef _WIN32
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    36
# if defined(_NEED_SLEEP_ONLY) && (defined(_MSC_VER) || defined(__MINGW32__))
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    37
#  include <stdlib.h>
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    38
#  define sleep(t) _sleep((t) * 1000)
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    39
# else
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    40
#  include <windows.h>
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    41
#  define sleep(t)  Sleep((t) * 1000)
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    42
# endif
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    43
# ifndef _NEED_SLEEP_ONLY
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    44
#  define msleep(t) Sleep(t)
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    45
#  define usleep(t) Sleep((t) / 1000)
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    46
# endif
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    47
#else
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    48
# include <unistd.h>
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    49
# ifndef _NEED_SLEEP_ONLY
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    50
#  define msleep(t) usleep((t) * 1000)
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    51
# endif
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    52
#endif
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    53
#endif /* _SLEEP_H */
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    54
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    55
#pragma once
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    56
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    57
typedef struct _fade_t {
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    58
	int index;
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    59
	unsigned int quantity;
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    60
} fade_t;
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    61
2191
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    62
void *Malloc (size_t nbytes);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    63
FILE *Fopen (const char *fname, char *mode);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    64
ALint AlGetError (const char *str);
2210
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    65
#ifndef _WIN32
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    66
void *helper_fadein (void *tmp);
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    67
void *helper_fadeout (void *tmp); 
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    68
#else
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    69
void WINAPI helper_fadein (void *tmp); 
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    70
void WINAPI helper_fadeout (void *tmp); 	
1cb7118a77dd initial bugfix for volume setup
koda
parents: 2191
diff changeset
    71
#endif