GameApi 28
Library used by GameApi Builder tool
Loading...
Searching...
No Matches
prerequisites.h
Go to the documentation of this file.
1// html5_mixer
2//
3// Copyright (c) 2021 David Apollo (77db70f775fa0b590889c45371a70a1d23e99869d4565976a5207c11606fb6aa)
4//
5// Permission is hereby granted, free of charge, to any person obtaining a copy
6// of this software and associated documentation files (the "Software"), to deal
7// in the Software without restriction, including without limitation the rights
8// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9// copies of the Software, and to permit persons to whom the Software is
10// furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in all
13// copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21// SOFTWARE.
22
23#ifndef PREREQUISITES_H_
24#define PREREQUISITES_H_
25
26// These checks don't work in *.c files.
27
28#ifdef SDL_VERSION
29#define HTML5_MIXER_HAVE_SDL
30#endif
31
32#ifdef MIX_VERSION
33#define HTML5_MIXER_HAVE_MIX
34#endif
35
37// Shims for html5_mixer
39
40#include <stdio.h>
41#include <stdlib.h>
42
43#ifndef HTML5_MIXER_HAVE_SDL
44#define SDL_Error(code) fprintf(stdout, "SDL Error: %d\n", code)
45#define SDL_SetError(...) {fprintf(stdout, __VA_ARGS__); fprintf(stdout, "\n");}
46#define SDL_calloc calloc
47#define SDL_malloc malloc
48#define SDL_free free
49#endif
50
51#ifndef HTML5_MIXER_HAVE_MIX
52#define Mix_SetError SDL_SetError
53#endif
54
56// SDL Prerequisites
57// The header macros (_begin_code_h etc.) are never defined by SDL.h,
58// but we keep them for IDE convenience -- allows code block folding.
60
61#ifndef HTML5_MIXER_HAVE_SDL
62
63#ifndef _begin_code_h
64
65#ifndef DECLSPEC
66# if defined(__WIN32__) || defined(__WINRT__)
67# ifdef __BORLANDC__
68# ifdef BUILD_SDL
69# define DECLSPEC
70# else
71# define DECLSPEC __declspec(dllimport)
72# endif
73# else
74# define DECLSPEC __declspec(dllexport)
75# endif
76# else
77# if defined(__GNUC__) && __GNUC__ >= 4
78# define DECLSPEC __attribute__ ((visibility("default")))
79# elif defined(__GNUC__) && __GNUC__ >= 2
80# define DECLSPEC __declspec(dllexport)
81# else
82# define DECLSPEC
83# endif
84# endif
85#endif
86
87/* By default SDL uses the C calling convention */
88#ifndef SDLCALL
89#if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__)
90#define SDLCALL __cdecl
91#else
92#define SDLCALL
93#endif
94#endif /* SDLCALL */
95
96/* Removed DECLSPEC on Symbian OS because SDL cannot be a DLL in EPOC */
97#ifdef __SYMBIAN32__
98#undef DECLSPEC
99#define DECLSPEC
100#endif /* __SYMBIAN32__ */
101
102#endif // _begin_code_h
103
104#ifndef SDL_config_h_
105
106#define HAVE_STDARG_H 1
107#define HAVE_STDDEF_H 1
108#define HAVE_STDIO_H 1
109
110/* Most everything except Visual Studio 2008 and earlier has stdint.h now */
111#if defined(_MSC_VER) && (_MSC_VER < 1600)
112/* Here are some reasonable defaults */
113typedef unsigned int size_t;
114typedef signed char int8_t;
115typedef unsigned char uint8_t;
116typedef signed short int16_t;
117typedef unsigned short uint16_t;
118typedef signed int int32_t;
119typedef unsigned int uint32_t;
120typedef signed long long int64_t;
121typedef unsigned long long uint64_t;
122typedef unsigned long uintptr_t;
123#else
124#define HAVE_STDINT_H 1
125#endif /* Visual Studio 2008 */
126
127#endif // SDL_config_h_
128
129#ifndef SDL_error_h_
130#define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM)
131
141#endif // SDL_error_h_
142
143#ifndef SDL_stdinc_h_
144#if defined(HAVE_STDINT_H)
145# include <stdint.h>
146#endif
147
148#ifdef __CC_ARM
149/* ARM's compiler throws warnings if we use an enum: like "SDL_bool x = a < b;" */
150#define SDL_FALSE 0
151#define SDL_TRUE 1
152typedef int SDL_bool;
153#else
154typedef enum
155{
158} SDL_bool;
159#endif
160
161typedef int8_t Sint8;
162typedef uint8_t Uint8;
163typedef int16_t Sint16;
164typedef uint16_t Uint16;
165typedef int32_t Sint32;
166typedef uint32_t Uint32;
167typedef int64_t Sint64;
168typedef uint64_t Uint64;
169#endif // SDL_stdinc_h
170
171#ifndef SDL_rwops_h_
172
173#ifdef HAVE_STDDEF_H
174#include <stddef.h>
175#endif
176
177#ifdef HAVE_STDIO_H
178#include <stdio.h>
179#endif
180
181#define SDL_RWOPS_UNKNOWN 0U
182#define SDL_RWOPS_STDFILE 2U
183#define SDL_RWOPS_MEMORY 4U
184#define SDL_RWOPS_MEMORY_RO 5U
185
186typedef struct SDL_RWops
187{
191 Sint64 (SDLCALL * size) (struct SDL_RWops * context);
192
199 Sint64 (SDLCALL * seek) (struct SDL_RWops * context, Sint64 offset,
200 int whence);
201
208 size_t (SDLCALL * read) (struct SDL_RWops * context, void *ptr,
209 size_t size, size_t maxnum);
210
217 size_t (SDLCALL * write) (struct SDL_RWops * context, const void *ptr,
218 size_t size, size_t num);
219
225 int (SDLCALL * close) (struct SDL_RWops * context);
226
228 union
229 {
230#if defined(__ANDROID__)
231 struct
232 {
233 void *fileNameRef;
234 void *inputStreamRef;
235 void *readableByteChannelRef;
236 void *readMethod;
237 void *assetFileDescriptorRef;
238 long position;
239 long size;
240 long offset;
241 int fd;
242 } androidio;
243#elif defined(__WIN32__)
244 struct
245 {
246 SDL_bool append;
247 void *h;
248 struct
249 {
250 void *data;
251 size_t size;
252 size_t left;
253 } buffer;
254 } windowsio;
255#endif
256
257#ifdef HAVE_STDIO_H
258 struct
259 {
261 FILE *fp;
263#endif
264 struct
265 {
270 struct
271 {
272 void *data1;
273 void *data2;
276
278
279extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFile(const char *file,
280 const char *mode);
281
284
287
288#define RW_SEEK_SET 0
289#define RW_SEEK_CUR 1
290#define RW_SEEK_END 2
291
298#define SDL_RWseek(ctx, offset, whence) (ctx)->seek(ctx, offset, whence)
299
300#define SDL_RWclose(ctx) (ctx)->close(ctx)
301
302#ifdef HAVE_FOPEN64
303#define fopen fopen64
304#endif
305#ifdef HAVE_FSEEKO64
306#define fseek_off_t off64_t
307#define fseek fseeko64
308#define ftell ftello64
309#elif defined(HAVE_FSEEKO)
310#if defined(OFF_MIN) && defined(OFF_MAX)
311#define FSEEK_OFF_MIN OFF_MIN
312#define FSEEK_OFF_MAX OFF_MAX
313#elif defined(HAVE_LIMITS_H)
314/* POSIX doesn't specify the minimum and maximum macros for off_t so
315 * we have to improvise and dance around implementation-defined
316 * behavior. This may fail if the off_t type has padding bits or
317 * is not a two's-complement representation. The compilers will detect
318 * and eliminate the dead code if off_t has 64 bits.
319 */
320#define FSEEK_OFF_MAX (((((off_t)1 << (sizeof(off_t) * CHAR_BIT - 2)) - 1) << 1) + 1)
321#define FSEEK_OFF_MIN (-(FSEEK_OFF_MAX) - 1)
322#endif
323#define fseek_off_t off_t
324#define fseek fseeko
325#define ftell ftello
326#elif defined(HAVE__FSEEKI64)
327#define fseek_off_t __int64
328#define fseek _fseeki64
329#define ftell _ftelli64
330#else
331#ifdef HAVE_LIMITS_H
332#define FSEEK_OFF_MIN LONG_MIN
333#define FSEEK_OFF_MAX LONG_MAX
334#endif
335#define fseek_off_t long
336#endif
337
338#endif // SDL_rwops_h_
339
340#ifndef SDL_audio_h_
362
377typedef void (SDLCALL * SDL_AudioCallback) (void *userdata, Uint8 * stream,
378 int len);
379
392#endif // SDL_audio_h_
393
394#endif // HTML5_MIXER_HAVE_SDL
395
397// SDL Mixer Prerequisites
399
400#ifndef HTML5_MIXER_HAVE_MIX
401
402/* The different fading types supported */
408
409/* These are types of music files (not libraries used to load them) */
423
424/* The internal format for a music chunk interpreted via mikmod */
425typedef struct _Mix_Music Mix_Music;
426
427#define SDL_MIX_MAXVOLUME (128)
428#define MIX_MAX_VOLUME SDL_MIX_MAXVOLUME
429
430#endif // HTML5_MIXER_HAVE_MIX
431
432#endif // PREREQUISITES_H_
lazy data
Definition meshpage.php:1583
struct _Mix_Music Mix_Music
Definition prerequisites.h:425
uint8_t Uint8
Definition prerequisites.h:162
int64_t Sint64
Definition prerequisites.h:167
DECLSPEC SDL_RWops *SDLCALL SDL_AllocRW(void)
uint16_t Uint16
Definition prerequisites.h:164
Mix_Fading
Definition prerequisites.h:403
@ MIX_NO_FADING
Definition prerequisites.h:404
@ MIX_FADING_OUT
Definition prerequisites.h:405
@ MIX_FADING_IN
Definition prerequisites.h:406
void(SDLCALL * SDL_AudioCallback)(void *userdata, Uint8 *stream, int len)
Definition prerequisites.h:377
Mix_MusicType
Definition prerequisites.h:410
@ MUS_MP3_MAD_UNUSED
Definition prerequisites.h:419
@ MUS_HTML5
Definition prerequisites.h:412
@ MUS_MODPLUG_UNUSED
Definition prerequisites.h:421
@ MUS_CMD
Definition prerequisites.h:413
@ MUS_MP3
Definition prerequisites.h:418
@ MUS_OGG
Definition prerequisites.h:417
@ MUS_MOD
Definition prerequisites.h:415
@ MUS_FLAC
Definition prerequisites.h:420
@ MUS_MID
Definition prerequisites.h:416
@ MUS_WAV
Definition prerequisites.h:414
@ MUS_NONE
Definition prerequisites.h:411
Uint16 SDL_AudioFormat
Audio format flags.
Definition prerequisites.h:361
SDL_errorcode
Definition prerequisites.h:133
@ SDL_EFSEEK
Definition prerequisites.h:137
@ SDL_LASTERROR
Definition prerequisites.h:139
@ SDL_EFWRITE
Definition prerequisites.h:136
@ SDL_UNSUPPORTED
Definition prerequisites.h:138
@ SDL_EFREAD
Definition prerequisites.h:135
@ SDL_ENOMEM
Definition prerequisites.h:134
int8_t Sint8
Definition prerequisites.h:161
int32_t Sint32
Definition prerequisites.h:165
#define SDLCALL
Definition prerequisites.h:92
DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFile(const char *file, const char *mode)
SDL_bool
Definition prerequisites.h:155
@ SDL_TRUE
Definition prerequisites.h:157
@ SDL_FALSE
Definition prerequisites.h:156
int16_t Sint16
Definition prerequisites.h:163
#define DECLSPEC
Definition prerequisites.h:82
uint64_t Uint64
Definition prerequisites.h:168
DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops *area)
DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFP(FILE *fp, SDL_bool autoclose)
uint32_t Uint32
Definition prerequisites.h:166
Definition prerequisites.h:381
Uint32 size
Definition prerequisites.h:388
SDL_AudioCallback callback
Definition prerequisites.h:389
Uint16 samples
Definition prerequisites.h:386
Uint8 channels
Definition prerequisites.h:384
Uint16 padding
Definition prerequisites.h:387
int freq
Definition prerequisites.h:382
Uint8 silence
Definition prerequisites.h:385
SDL_AudioFormat format
Definition prerequisites.h:383
void * userdata
Definition prerequisites.h:390
Definition prerequisites.h:187
Uint32 type
Definition prerequisites.h:227
struct SDL_RWops::@347321050133103066241012124176165134045107312112::@377161323357010341362137046242254315363057261247 mem
FILE * fp
Definition prerequisites.h:261
SDL_bool autoclose
Definition prerequisites.h:260
void * ptr
Definition prerequisites.h:208
Uint8 * stop
Definition prerequisites.h:268
Sint64(SDLCALL *size)(struct SDL_RWops *context)
union SDL_RWops::@347321050133103066241012124176165134045107312112 hidden
struct SDL_RWops::@347321050133103066241012124176165134045107312112::@365311005130337276032004163346361276270376074335 stdio
const void size_t size_t num
Definition prerequisites.h:218
Uint8 * here
Definition prerequisites.h:267
void size_t size_t maxnum
Definition prerequisites.h:209
Sint64 int whence
Definition prerequisites.h:200
struct SDL_RWops::@347321050133103066241012124176165134045107312112::@211174164316127235035274101117346221131265240366 unknown
void size_t size
Definition prerequisites.h:209
Sint64 offset
Definition prerequisites.h:199
int(SDLCALL *close)(struct SDL_RWops *context)
void * data1
Definition prerequisites.h:272
void * data2
Definition prerequisites.h:273
size_t(SDLCALL *read)(struct SDL_RWops *context
Uint8 * base
Definition prerequisites.h:266
Definition music.h:114