author | nemo |
Mon, 25 Feb 2013 12:54:50 -0500 | |
branch | icegun |
changeset 8576 | 286ebfcb3d97 |
parent 3697 | d5b30d6373fc |
permissions | -rw-r--r-- |
3353 | 1 |
/* |
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3353
diff
changeset
|
2 |
* OpenAL Bridge - a simple portable library for OpenAL interface |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3353
diff
changeset
|
3 |
* Copyright (c) 2009 Vittorio Giovara <vittorio.giovara@gmail.com> |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3353
diff
changeset
|
4 |
* |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3353
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3353
diff
changeset
|
6 |
* it under the terms of the GNU Lesser General Public License as published by |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3353
diff
changeset
|
7 |
* the Free Software Foundation; version 2 of the License |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3353
diff
changeset
|
8 |
* |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3353
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3353
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3353
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3353
diff
changeset
|
12 |
* GNU Lesser General Public License for more details. |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3353
diff
changeset
|
13 |
* |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3353
diff
changeset
|
14 |
* You should have received a copy of the GNU Lesser General Public License |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3353
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3353
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3353
diff
changeset
|
17 |
*/ |
3353 | 18 |
|
19 |
#include "wrappers.h" |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3353
diff
changeset
|
20 |
#include "openalbridge_t.h" |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3353
diff
changeset
|
21 |
|
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3353
diff
changeset
|
22 |
|
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3353
diff
changeset
|
23 |
void *Malloc (size_t nbytes) { |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3353
diff
changeset
|
24 |
void *aptr; |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3353
diff
changeset
|
25 |
|
3364 | 26 |
if ((aptr = malloc(nbytes)) == NULL) { |
3513
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3487
diff
changeset
|
27 |
fprintf(stderr,"(Bridge FATAL) - not enough memory\n"); |
3364 | 28 |
abort(); |
29 |
} |
|
3513
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3487
diff
changeset
|
30 |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3353
diff
changeset
|
31 |
return aptr; |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3353
diff
changeset
|
32 |
} |
3353 | 33 |
|
34 |
||
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3353
diff
changeset
|
35 |
void *Realloc (void *aptr, size_t nbytes) { |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3353
diff
changeset
|
36 |
aptr = realloc(aptr, nbytes); |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3353
diff
changeset
|
37 |
|
3364 | 38 |
if (aptr == NULL) { |
3513
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3487
diff
changeset
|
39 |
fprintf(stderr,"(Bridge FATAL) - not enough memory\n"); |
3364 | 40 |
abort(); |
41 |
} |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3353
diff
changeset
|
42 |
|
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3353
diff
changeset
|
43 |
return aptr; |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3353
diff
changeset
|
44 |
} |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3353
diff
changeset
|
45 |
|
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3353
diff
changeset
|
46 |
|
3529 | 47 |
FILE *Fopen (const char *fname, char *mode) { |
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3353
diff
changeset
|
48 |
FILE *fp; |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3353
diff
changeset
|
49 |
|
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3353
diff
changeset
|
50 |
fp = fopen(fname,mode); |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3353
diff
changeset
|
51 |
if (fp == NULL) |
3513
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3487
diff
changeset
|
52 |
fprintf(stderr,"(Bridge Error) - can't open file %s in mode '%s'\n", fname, mode); |
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3353
diff
changeset
|
53 |
|
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3353
diff
changeset
|
54 |
return fp; |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3353
diff
changeset
|
55 |
} |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3353
diff
changeset
|
56 |
|
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3353
diff
changeset
|
57 |
|
3529 | 58 |
al_sound_t new_sound_el (void) { |
59 |
al_sound_t sound; |
|
3697 | 60 |
|
3529 | 61 |
sound.filename = NULL; |
62 |
sound.buffer = -1; |
|
63 |
sound.source_index = -1; |
|
64 |
sound.is_used = AL_FALSE; |
|
65 |
||
66 |
return sound; |
|
67 |
} |
|
68 |
||
69 |
al_sound_t init_sound_el (const char *str) { |
|
70 |
al_sound_t sound; |
|
3697 | 71 |
|
3529 | 72 |
sound.filename = str; |
73 |
sound.source_index = -1; |
|
74 |
sound.is_used = AL_TRUE; |
|
75 |
alGenBuffers(1, &sound.buffer); |
|
76 |
||
77 |
return sound; |
|
78 |
} |