14 * You should have received a copy of the GNU General Public License |
14 * You should have received a copy of the GNU General Public License |
15 * along with this program; if not, write to the Free Software |
15 * along with this program; if not, write to the Free Software |
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
17 */ |
17 */ |
18 |
18 |
19 #ifndef __OLAB_INCLUDES__ |
19 #ifndef _OALB_GLOBALS_H |
20 #define __OLAB_INCLUDES__ |
20 #define _OALB_GLOBALS_H |
21 |
21 |
22 #include <stdio.h> |
22 #include <stdio.h> |
23 #include <stdlib.h> |
23 #include <stdlib.h> |
24 #include "al.h" |
|
25 #include "alc.h" |
|
26 #include "loaders.h" |
|
27 #include "wrappers.h" |
|
28 #include "endianness.h" |
|
29 #include "openalwrap.h" |
|
30 |
24 |
31 #ifndef _WIN32 |
25 #ifndef _WIN32 |
|
26 #include <stdint.h> |
32 #include <pthread.h> |
27 #include <pthread.h> |
33 #include <stdint.h> |
|
34 #else |
28 #else |
35 #define WIN32_LEAN_AND_MEAN |
|
36 #include <process.h> |
29 #include <process.h> |
37 #include "winstdint.h" |
30 #include "winstdint.h" |
38 #endif |
31 #endif |
|
32 |
|
33 #include "al.h" |
39 |
34 |
40 #ifndef _SLEEP_H |
35 #ifndef _SLEEP_H |
41 #define _SLEEP_H |
36 #define _SLEEP_H |
42 /** 1.0 02/03/10 - Defines cross-platform sleep, usleep, etc. * By Wu Yongwei **/ |
37 /** 1.0 02/03/10 - Defines cross-platform sleep, usleep, etc. * By Wu Yongwei **/ |
43 #ifdef _WIN32 |
38 #ifdef _WIN32 |
44 # if defined(_NEED_SLEEP_ONLY) && (defined(_MSC_VER) || defined(__MINGW32__)) |
39 # if defined(_NEED_SLEEP_ONLY) && (defined(_MSC_VER) || defined(__MINGW32__)) |
45 # include <stdlib.h> |
40 # include <stdlib.h> |
46 # define sleep(t) _sleep((t) * 1000) |
41 # define sleep(t) _sleep((t) * 1000) |
47 # else |
42 # else |
|
43 # define WIN32_LEAN_AND_MEAN |
48 # include <windows.h> |
44 # include <windows.h> |
49 # define sleep(t) Sleep((t) * 1000) |
45 # define sleep(t) Sleep((t) * 1000) |
50 # endif |
46 # endif |
51 # ifndef _NEED_SLEEP_ONLY |
47 # ifndef _NEED_SLEEP_ONLY |
52 # define msleep(t) Sleep(t) |
48 # define msleep(t) Sleep(t) |
106 |
102 |
107 /*other defines*/ |
103 /*other defines*/ |
108 #define FADE_IN 11 |
104 #define FADE_IN 11 |
109 #define FADE_OUT 12 |
105 #define FADE_OUT 12 |
110 |
106 |
111 |
|
112 /*data types for ogg and vorbis that are required to be external*/ |
|
113 #ifndef ogg_int64_t |
|
114 #define ogg_int64_t int64_t |
|
115 #endif |
|
116 |
|
117 typedef struct { |
|
118 unsigned char *data; |
|
119 int storage; |
|
120 int fill; |
|
121 int returned; |
|
122 |
|
123 int unsynced; |
|
124 int headerbytes; |
|
125 int bodybytes; |
|
126 } ogg_sync_state; |
|
127 typedef struct vorbis_info{ |
|
128 int version; |
|
129 int channels; |
|
130 long rate; |
|
131 |
|
132 /* The below bitrate declarations are *hints*. |
|
133 Combinations of the three values carry the following implications: |
|
134 |
|
135 all three set to the same value: |
|
136 implies a fixed rate bitstream |
|
137 only nominal set: |
|
138 implies a VBR stream that averages the nominal bitrate. No hard |
|
139 upper/lower limit |
|
140 upper and or lower set: |
|
141 implies a VBR bitstream that obeys the bitrate limits. nominal |
|
142 may also be set to give a nominal rate. |
|
143 none set: |
|
144 the coder does not care to speculate. |
|
145 */ |
|
146 |
|
147 long bitrate_upper; |
|
148 long bitrate_nominal; |
|
149 long bitrate_lower; |
|
150 long bitrate_window; |
|
151 |
|
152 void *codec_setup; |
|
153 } vorbis_info; |
|
154 typedef struct vorbis_comment{ |
|
155 /* unlimited user comment fields. libvorbis writes 'libvorbis' whatever vendor is set to in encode */ |
|
156 char **user_comments; |
|
157 int *comment_lengths; |
|
158 int comments; |
|
159 char *vendor; |
|
160 |
|
161 } vorbis_comment; |
|
162 typedef struct { |
|
163 unsigned char *body_data; /* bytes from packet bodies */ |
|
164 long body_storage; /* storage elements allocated */ |
|
165 long body_fill; /* elements stored; fill mark */ |
|
166 long body_returned; /* elements of fill returned */ |
|
167 |
|
168 |
|
169 int *lacing_vals; /* The values that will go to the segment table */ |
|
170 ogg_int64_t *granule_vals; |
|
171 /* granulepos values for headers. Not compact |
|
172 this way, but it is simple coupled to the lacing fifo */ |
|
173 long lacing_storage; |
|
174 long lacing_fill; |
|
175 long lacing_packet; |
|
176 long lacing_returned; |
|
177 |
|
178 unsigned char header[282]; /* working space for header encode */ |
|
179 int header_fill; |
|
180 |
|
181 int e_o_s; /* set when we have buffered the last packet in the logical bitstream */ |
|
182 int b_o_s; /* set after we've written the initial page of a logical bitstream */ |
|
183 long serialno; |
|
184 long pageno; |
|
185 ogg_int64_t packetno; |
|
186 /* sequence number for decode; the framing |
|
187 knows where there's a hole in the data, |
|
188 but we need coupling so that the codec |
|
189 (which is in a seperate abstraction |
|
190 layer) also knows about the gap */ |
|
191 ogg_int64_t granulepos; |
|
192 |
|
193 } ogg_stream_state; |
|
194 typedef struct vorbis_dsp_state{ |
|
195 int analysisp; |
|
196 vorbis_info *vi; |
|
197 |
|
198 float **pcm; |
|
199 float **pcmret; |
|
200 int pcm_storage; |
|
201 int pcm_current; |
|
202 int pcm_returned; |
|
203 |
|
204 int preextrapolate; |
|
205 int eofflag; |
|
206 |
|
207 long lW; |
|
208 long W; |
|
209 long nW; |
|
210 long centerW; |
|
211 |
|
212 ogg_int64_t granulepos; |
|
213 ogg_int64_t sequence; |
|
214 |
|
215 ogg_int64_t glue_bits; |
|
216 ogg_int64_t time_bits; |
|
217 ogg_int64_t floor_bits; |
|
218 ogg_int64_t res_bits; |
|
219 |
|
220 void *backend_state; |
|
221 } vorbis_dsp_state; |
|
222 typedef struct { |
|
223 long endbyte; |
|
224 int endbit; |
|
225 |
|
226 unsigned char *buffer; |
|
227 unsigned char *ptr; |
|
228 long storage; |
|
229 } oggpack_buffer; |
|
230 typedef struct vorbis_block{ |
|
231 /* necessary stream state for linking to the framing abstraction */ |
|
232 float **pcm; /* this is a pointer into local storage */ |
|
233 oggpack_buffer opb; |
|
234 |
|
235 long lW; |
|
236 long W; |
|
237 long nW; |
|
238 int pcmend; |
|
239 int mode; |
|
240 |
|
241 int eofflag; |
|
242 ogg_int64_t granulepos; |
|
243 ogg_int64_t sequence; |
|
244 vorbis_dsp_state *vd; /* For read-only access of configuration */ |
|
245 |
|
246 /* local storage to avoid remallocing; it's up to the mapping to structure it */ |
|
247 void *localstore; |
|
248 long localtop; |
|
249 long localalloc; |
|
250 long totaluse; |
|
251 struct alloc_chain *reap; |
|
252 |
|
253 /* bitmetrics for the frame */ |
|
254 long glue_bits; |
|
255 long time_bits; |
|
256 long floor_bits; |
|
257 long res_bits; |
|
258 |
|
259 void *internal; |
|
260 |
|
261 } vorbis_block; |
|
262 typedef struct { |
|
263 size_t (*read_func) (void *ptr, size_t size, size_t nmemb, void *datasource); |
|
264 int (*seek_func) (void *datasource, ogg_int64_t offset, int whence); |
|
265 int (*close_func) (void *datasource); |
|
266 long (*tell_func) (void *datasource); |
|
267 } ov_callbacks; |
|
268 typedef struct OggVorbis_File { |
|
269 void *datasource; /* Pointer to a FILE *, etc. */ |
|
270 int seekable; |
|
271 ogg_int64_t offset; |
|
272 ogg_int64_t end; |
|
273 ogg_sync_state oy; |
|
274 |
|
275 /* If the FILE handle isn't seekable (eg, a pipe), only the current stream appears */ |
|
276 int links; |
|
277 ogg_int64_t *offsets; |
|
278 ogg_int64_t *dataoffsets; |
|
279 long *serialnos; |
|
280 ogg_int64_t *pcmlengths; |
|
281 /* overloaded to maintain binary |
|
282 compatability; x2 size, stores both |
|
283 beginning and end values */ |
|
284 vorbis_info *vi; |
|
285 vorbis_comment *vc; |
|
286 |
|
287 /* Decoding working state local storage */ |
|
288 ogg_int64_t pcm_offset; |
|
289 int ready_state; |
|
290 long current_serialno; |
|
291 int current_link; |
|
292 |
|
293 double bittrack; |
|
294 double samptrack; |
|
295 |
|
296 ogg_stream_state os; /* take physical pages, weld into a logical stream of packets */ |
|
297 vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */ |
|
298 vorbis_block vb; /* local working space for packet->PCM decode */ |
|
299 |
|
300 ov_callbacks callbacks; |
|
301 |
|
302 } OggVorbis_File; |
|
303 |
|
304 extern int ov_open(FILE *f,OggVorbis_File *vf,char *initial,long ibytes); |
|
305 extern long ov_read(OggVorbis_File *vf,char *buffer,int length,int bigendianp,int word,int sgned,int *bitstream); |
|
306 extern ogg_int64_t ov_pcm_total(OggVorbis_File *vf,int i); |
|
307 extern long ov_read(OggVorbis_File *vf,char *buffer,int length,int bigendianp,int word,int sgned,int *bitstream); |
|
308 extern vorbis_info *ov_info(OggVorbis_File *vf,int link); |
|
309 extern vorbis_comment *ov_comment(OggVorbis_File *f, int num); |
|
310 |
|
311 #ifdef __CPLUSPLUS |
107 #ifdef __CPLUSPLUS |
312 } |
108 } |
313 #endif |
109 #endif |
314 |
110 |
315 #endif /*__OLAB_INCLUDES__*/ |
111 #endif /*_OALB_GLOBALS_H*/ |