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