annotate Isolated/ALmixer_RWops.h @ 70:7d63f5149d40

Enhanced endian detection code in SoundDecoder.h after reviewing ANDROID_NDK changes.
author Eric Wing <ewing . public |-at-| gmail . com>
date Wed, 20 Jun 2012 10:41:06 -0700
parents 208a9ed20087
children 36644b1b940b
rev   line source
38
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
1 #ifndef ALMIXER_RWOPS
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
2 #define ALMIXER_RWOPS
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
3
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
4 #if defined(_WIN32)
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
5 #if defined(ALMIXER_RWOPS_BUILD_LIBRARY)
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
6 #define ALMIXER_RWOPS_DECLSPEC __declspec(dllexport)
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
7 #else
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
8 #define ALMIXER_RWOPS_DECLSPEC __declspec(dllimport)
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
9 #endif
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
10 #else
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
11 #if defined(ALMIXER_RWOPS_BUILD_LIBRARY)
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
12 #if defined (__GNUC__) && __GNUC__ >= 4
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
13 #define ALMIXER_RWOPS_DECLSPEC __attribute__((visibility("default")))
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
14 #else
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
15 #define ALMIXER_RWOPS_DECLSPEC
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
16 #endif
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
17 #else
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
18 #define ALMIXER_RWOPS_DECLSPEC
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
19 #endif
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
20 #endif
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
21
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
22 #if defined(_WIN32)
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
23 #define ALMIXER_RWOPS_CALL __cdecl
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
24 #else
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
25 #define ALMIXER_RWOPS_CALL
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
26 #endif
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
27
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
28 #ifdef __cplusplus
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
29 extern "C" {
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
30 #endif
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
31
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
32 /* Trying to keep compatibility with SDL_RWops,
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
33 * but I don't plan on reimplementing everything.
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
34 */
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
35 #include <stdio.h>
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
36 #include <stddef.h>
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
37 /* The 'type' parameter needs to be 32-bits to match SDL_RWops.
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
38 * <stdint.h> has been problematic for Visual Studio for years.
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
39 * It appears that Visual Studio 2010 finally includes this.
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
40 */
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
41 #include <stdint.h>
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
42 typedef struct ALmixer_RWops
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
43 {
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
44 /** Seek to 'offset' relative to whence, one of stdio's whence values:
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
45 * SEEK_SET, SEEK_CUR, SEEK_END
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
46 * Returns the final offset in the data source.
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
47 * (Note this is different than stdio's seek. This returns ftell.)
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
48 */
56
208a9ed20087 Added explicit symbol visibility markers to audio support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 38
diff changeset
49 long (ALMIXER_RWOPS_CALL *seek)(struct ALmixer_RWops* the_context, long offset, int whence);
38
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
50
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
51 /** Read up to 'nitems' objects each of size 'size' from the data
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
52 * source to the area pointed at by 'ptr'.
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
53 * Returns the number of objects read, or -1 if the read failed.
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
54 */
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
55 size_t (ALMIXER_RWOPS_CALL *read)(struct ALmixer_RWops* the_context, void* ptr, size_t size, size_t nitems);
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
56
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
57 /** Write exactly 'nitems' objects each of size 'size' from the area
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
58 * pointed at by 'ptr' to data source.
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
59 * Returns 'num', or -1 if the write failed.
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
60 */
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
61 size_t (ALMIXER_RWOPS_CALL *write)(struct ALmixer_RWops* the_context, const void* ptr, size_t size, size_t nitems);
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
62
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
63 /** Close and free an allocated ALmixer_RWops structure */
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
64 int (ALMIXER_RWOPS_CALL *close)(struct ALmixer_RWops* the_context);
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
65
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
66 /* type Needs to be a 32-bit to be compatible with SDL */
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
67 uint32_t type;
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
68 union
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
69 {
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
70 #if defined(__WIN32__) && !defined(__SYMBIAN32__)
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
71 /* Chances are that I will not implement this path.
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
72 * But I want the padding to be the same as SDL.
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
73 */
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
74 struct
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
75 {
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
76 int append;
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
77 void *h;
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
78 struct
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
79 {
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
80 void *data;
56
208a9ed20087 Added explicit symbol visibility markers to audio support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 38
diff changeset
81 size_t size;
208a9ed20087 Added explicit symbol visibility markers to audio support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 38
diff changeset
82 size_t left;
38
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
83 } buffer;
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
84 } win32io;
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
85 #endif
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
86 struct
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
87 {
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
88 int autoclose;
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
89 FILE* fp;
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
90 } stdio;
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
91 struct
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
92 {
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
93 unsigned char* base;
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
94 unsigned char* here;
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
95 unsigned char* stop;
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
96 } mem;
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
97 struct
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
98 {
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
99 void* data1;
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
100 } unknown;
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
101 } hidden;
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
102 } ALmixer_RWops;
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
103
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
104 extern ALMIXER_RWOPS_DECLSPEC ALmixer_RWops* ALMIXER_RWOPS_CALL ALmixer_RWFromFile(const char* file_name, const char* file_mode);
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
105 extern ALMIXER_RWOPS_DECLSPEC ALmixer_RWops* ALMIXER_RWOPS_CALL ALmixer_RWFromFP(FILE* file_pointer, char autoclose_flag);
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
106
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
107 #define ALmixer_RWseek(rwops, offset, whence) (rwops)->seek(rwops, offset, whence)
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
108 #define ALmixer_RWtell(rwops) (rwops)->seek(rwops, 0, SEEK_CUR)
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
109 #define ALmixer_RWread(rwops, ptr, size, nitems) (rwops)->read(rwops, ptr, size, nitems)
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
110
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
111 /* Ends C function definitions when using C++ */
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
112 #ifdef __cplusplus
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
113 }
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
114 #endif
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
115
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
116 #endif
71b465ff0622 Added support files.
Eric Wing <ewing@anscamobile.com>
parents:
diff changeset
117