Debian Codegraph @

addons/acodec/dumb.c

raw
1 /*
2 * Allegro MOD reader
3 * author: Matthew Leverton
4 */
5
6 #define _FILE_OFFSET_BITS 64
7 #include <ctype.h>
8
9 #define ALLEGRO_INTERNAL_UNSTABLE
10 #include "allegro5/allegro.h"
11 #include "allegro5/allegro_acodec.h"
12 #include "allegro5/allegro_audio.h"
13 #include "allegro5/internal/aintern_audio.h"
14 #include "allegro5/internal/aintern_exitfunc.h"
15 #include "allegro5/internal/aintern_system.h"
16 #include "acodec.h"
17 #include "helper.h"
18
19 #ifndef ALLEGRO_CFG_ACODEC_DUMB
20 #error configuration problem, ALLEGRO_CFG_ACODEC_DUMB not set
21 #endif
22
23 // We use the deprecated duh_render in DUMB 2.
24 #define DUMB_DECLARE_DEPRECATED
25 #include <dumb.h>
26 #include <stdio.h>
27
28 ALLEGRO_DEBUG_CHANNEL("acodec")
29
30 /* In addition to DUMB 0.9.3 at http://dumb.sourceforge.net/,
31 * we support kode54's fork of DUMB at https://github.com/kode54/dumb.
32 * The newest version before kode54's fork was DUMB 0.9.3, and the first
33 * forked version that A5 supports is already 2.0.0.
34 */
35
36 /* forward declarations */
37 static bool init_libdumb(void);
38 static size_t modaudio_stream_update(ALLEGRO_AUDIO_STREAM *stream, void *data,
39 size_t buf_size);
40 static bool modaudio_stream_rewind(ALLEGRO_AUDIO_STREAM *stream);
41 static bool modaudio_stream_seek(ALLEGRO_AUDIO_STREAM *stream, double time);
42 static double modaudio_stream_get_position(ALLEGRO_AUDIO_STREAM *stream);
43 static double modaudio_stream_get_length(ALLEGRO_AUDIO_STREAM *stream);
44 static bool modaudio_stream_set_loop(ALLEGRO_AUDIO_STREAM *stream,
45 double start, double end);
46 static void modaudio_stream_close(ALLEGRO_AUDIO_STREAM *stream);
47
48
49 typedef struct MOD_FILE
50 {
51 DUH *duh;
52 DUH_SIGRENDERER *sig;
53 ALLEGRO_FILE *fh;
54 double length;
55 long loop_start, loop_end;
56 } MOD_FILE;
57
58
59 static bool libdumb_loaded = false;
60
61
62 /* dynamic loading support (Windows only currently) */
63 #ifdef ALLEGRO_CFG_ACODEC_DUMB_DLL
64 static void *dumb_dll = NULL;
65 #endif
66
67 /*
68 * dumb_off_t is introduced in DUMB 2.0, it's a signed 64+ bit integer.
69 * dumb_ssize_t is a platform-independent signed size_t.
70 * DUMB 0.9.3 expects long wherever dumb_off_t or dumb_ssize_t appear.
71 *
72 * _al_dumb_size_t takes care of another, less documented, difference
73 * between the versions.
74 */
75 #if (DUMB_MAJOR_VERSION) < 2
76 typedef long dumb_off_t;
77 typedef long dumb_ssize_t;
78 typedef long _al_dumb_size_t;
79 #else
80 typedef size_t _al_dumb_size_t;
81 #endif
82
83 static struct
84 {
85 long (*duh_sigrenderer_get_position)(DUH_SIGRENDERER *);
86 void (*duh_end_sigrenderer)(DUH_SIGRENDERER *);
87 void (*unload_duh)(DUH *);
88 DUH_SIGRENDERER *(*duh_start_sigrenderer)(DUH *, int, int, long);
89 dumb_off_t (*duh_get_length)(DUH *);
90 void (*dumb_exit)(void);
91 DUMB_IT_SIGRENDERER *(*duh_get_it_sigrenderer)(DUH_SIGRENDERER *);
92 void (*dumb_it_set_loop_callback)(DUMB_IT_SIGRENDERER *, int (*)(void *), void *);
93 void (*dumb_it_set_xm_speed_zero_callback)(DUMB_IT_SIGRENDERER *, int (*)(void *), void *);
94 int (*dumb_it_callback_terminate)(void *);
95
96 #if (DUMB_MAJOR_VERSION) >= 2
97 /*
98 * DUMB 2.0 deprecates duh_render, and suggests instead duh_render_int
99 * and duh_render_float. But I (Simon N.) don't know how to use those.
100 * I have already written some documentation for DUMB 2.0 that got merged
101 * upstream, but I haven't gotten around to this issue yet.
102 */
103 long (*duh_render)(DUH_SIGRENDERER *,
104 int, int, float, float, long, void *); /* deprecated */
105 void (*register_dumbfile_system)(const DUMBFILE_SYSTEM *);
106 DUMBFILE *(*dumbfile_open_ex)(void *, const DUMBFILE_SYSTEM *);
107 DUH *(*dumb_read_any)(DUMBFILE *, int, int);
108 #else
109 long (*duh_render)(DUH_SIGRENDERER *,
110 int, int, float, float, long, void *);
111 void (*register_dumbfile_system)(DUMBFILE_SYSTEM *);
112 DUMBFILE *(*dumbfile_open_ex)(void *, DUMBFILE_SYSTEM *);
113 DUH *(*dumb_read_mod)(DUMBFILE *);
114 DUH *(*dumb_read_it)(DUMBFILE *);
115 DUH *(*dumb_read_xm)(DUMBFILE *);
116 DUH *(*dumb_read_s3m)(DUMBFILE *);
117 #endif
118 } lib;
119
120 /* Set up DUMB's file system */
121 static DUMBFILE_SYSTEM dfs, dfs_f;
122
123 static void *dfs_open(const char *filename)
124 {
125 return al_fopen(filename, "rb");
126 }
127
128 static int dfs_skip(void *f, dumb_off_t n)
129 {
130 return al_fseek(f, n, ALLEGRO_SEEK_CUR) ? 0 : -1;
131 }
132
133 static int dfs_getc(void *f)
134 {
135 return al_fgetc(f);
136 }
137
138 static dumb_ssize_t dfs_getnc(char *ptr, _al_dumb_size_t n, void *f)
139 {
140 return al_fread(f, ptr, n);
141 }
142
143 static void dfs_close(void *f)
144 {
145 /* Don't actually close f here. */
146 (void)f;
147 }
148
149 #if (DUMB_MAJOR_VERSION) >= 2
150 static int dfs_seek(void *f, dumb_off_t n)
151 {
152 return al_fseek(f, n, ALLEGRO_SEEK_SET) ? 0 : -1;
153 }
154
155 static dumb_off_t dfs_get_size(void *f)
156 {
157 return al_fsize(f);
158 }
159 #endif
160
161 /* Stream Functions */
162
163 static int loop_callback(void *data)
164 {
165 bool *internal_loop = (bool *)data;
166 *internal_loop = true;
167 return 0;
168 }
169
170 static size_t modaudio_stream_update(ALLEGRO_AUDIO_STREAM *stream, void *data,
171 size_t buf_size)
172 {
173 MOD_FILE *const df = stream->extra;
174
175 /* the mod files are stereo and 16-bit */
176 const int sample_size = 4;
177 size_t written = 0;
178 size_t i;
179 bool internal_loop = false;
180
181 DUMB_IT_SIGRENDERER *it_sig = lib.duh_get_it_sigrenderer(df->sig);
182 if (it_sig) {
183 lib.dumb_it_set_loop_callback(it_sig,
184 stream->spl.loop == _ALLEGRO_PLAYMODE_STREAM_ONCE
185 ? lib.dumb_it_callback_terminate : loop_callback, &internal_loop);
186 }
187
188 while (written < buf_size) {
189 long size_to_read = (buf_size - written) / sample_size;
190 long position = lib.duh_sigrenderer_get_position(df->sig);
191 bool manual_loop = false;
192 internal_loop = false;
193 /* If manual looping is not enabled, then we need to implement
194 * short-stopping manually. */
195 if (stream->spl.loop != _ALLEGRO_PLAYMODE_STREAM_ONCE && df->loop_end != -1 &&
196 position + 65536 * size_to_read / 44100 >= df->loop_end) {
197 size_to_read = (df->loop_end - position) * 44100 / 65536;
198 if (size_to_read < 0)
199 size_to_read = 0;
200 manual_loop = true;
201 }
202 written += lib.duh_render(df->sig, 16, 0, 1.0, 65536.0 / 44100.0,
203 size_to_read, &(((char *)data)[written])) * sample_size;
204 /* For internal loops, we don't rewind. */
205 if (!internal_loop &&
206 ((long)written < size_to_read * sample_size || manual_loop)) {
207 break;
208 }
209 }
210
211 /* Fill the remainder with silence */
212 for (i = written; i < buf_size; ++i)
213 ((char *)data)[i] = 0;
214
215 return written;
216 }
217
218 static void modaudio_stream_close(ALLEGRO_AUDIO_STREAM *stream)
219 {
220 MOD_FILE *const df = stream->extra;
221 _al_acodec_stop_feed_thread(stream);
222
223 lib.duh_end_sigrenderer(df->sig);
224 lib.unload_duh(df->duh);
225 if (df->fh)
226 al_fclose(df->fh);
227 }
228
229 static bool modaudio_stream_rewind(ALLEGRO_AUDIO_STREAM *stream)
230 {
231 MOD_FILE *const df = stream->extra;
232 lib.duh_end_sigrenderer(df->sig);
233 df->sig = lib.duh_start_sigrenderer(df->duh, 0, 2, df->loop_start);
234 return true;
235 }
236
237 static bool modaudio_stream_seek(ALLEGRO_AUDIO_STREAM *stream, double time)
238 {
239 MOD_FILE *const df = stream->extra;
240
241 if (df->loop_end != -1 && (long)(time * 65336) > df->loop_end) {
242 return false;
243 }
244
245 lib.duh_end_sigrenderer(df->sig);
246 df->sig = lib.duh_start_sigrenderer(df->duh, 0, 2, time * 65536);
247
248 return true;
249 }
250
251 static double modaudio_stream_get_position(ALLEGRO_AUDIO_STREAM *stream)
252 {
253 MOD_FILE *const df = stream->extra;
254 return lib.duh_sigrenderer_get_position(df->sig) / 65536.0;
255 }
256
257 static double modaudio_stream_get_length(ALLEGRO_AUDIO_STREAM *stream)
258 {
259 MOD_FILE *const df = stream->extra;
260 return df->length;
261 }
262
263 static bool modaudio_stream_set_loop(ALLEGRO_AUDIO_STREAM *stream,
264 double start, double end)
265 {
266 MOD_FILE *const df = stream->extra;
267
268 df->loop_start = start * 65536;
269 df->loop_end = end * 65536;
270
271 return true;
272 }
273
274 static ALLEGRO_AUDIO_STREAM *modaudio_stream_init(ALLEGRO_FILE* f,
275 size_t buffer_count, unsigned int samples
276 #if (DUMB_MAJOR_VERSION) < 2
277 /* For DUMB 0.9.3, we must choose a loader function ourselves. */
278 , DUH *(loader)(DUMBFILE *)
279 #endif
280 )
281 {
282 ALLEGRO_AUDIO_STREAM *stream;
283 DUMBFILE *df;
284 DUH_SIGRENDERER *sig = NULL;
285 DUH *duh = NULL;
286 DUMB_IT_SIGRENDERER *it_sig = NULL;
287 int64_t start_pos = -1;
288
289 df = lib.dumbfile_open_ex(f, &dfs_f);
290 if (!df) {
291 ALLEGRO_ERROR("dumbfile_open_ex failed.\n");
292 return NULL;
293 }
294
295 start_pos = al_ftell(f);
296
297 #if (DUMB_MAJOR_VERSION) >= 2
298 /*
299 * DUMB 2.0 introduces dumb_read_any. It takes two extra int arguments.
300 *
301 * The first int, restrict_, changes how a MOD module is interpreted.
302 * int restrict_ is a two-bit bitfield, and 0 is a good default.
303 * For discussion, see: https://github.com/kode54/dumb/issues/53
304 *
305 * The second int, subsong, matters only for very few formats.
306 * A5 doesn't allow to choose a subsong from the 5.2 API anyway, thus 0.
307 */
308 duh = lib.dumb_read_any(df, 0, 0);
309 #else
310 duh = loader(df);
311 #endif
312 if (!duh) {
313 ALLEGRO_ERROR("Failed to create DUH.\n");
314 goto Error;
315 }
316
317 sig = lib.duh_start_sigrenderer(duh, 0, 2, 0);
318 if (!sig) {
319 ALLEGRO_ERROR("duh_start_sigrenderer failed.\n");
320 goto Error;
321 }
322
323 it_sig = lib.duh_get_it_sigrenderer(sig);
324 if (it_sig) {
325 /* Turn off freezing for XM files. Seems completely pointless. */
326 lib.dumb_it_set_xm_speed_zero_callback(it_sig, lib.dumb_it_callback_terminate, NULL);
327 }
328
329 stream = al_create_audio_stream(buffer_count, samples, 44100,
330 ALLEGRO_AUDIO_DEPTH_INT16, ALLEGRO_CHANNEL_CONF_2);
331
332 if (stream) {
333 MOD_FILE *mf = al_malloc(sizeof(MOD_FILE));
334 mf->duh = duh;
335 mf->sig = sig;
336 mf->fh = NULL;
337 mf->length = lib.duh_get_length(duh) / 65536.0;
338 if (mf->length < 0) {
339 mf->length = 0;
340 }
341 /*
342 * Set these to -1, so that we can default to the internal loop
343 * points.
344 */
345 mf->loop_start = -1;
346 mf->loop_end = -1;
347
348 stream->extra = mf;
349 stream->feeder = modaudio_stream_update;
350 stream->unload_feeder = modaudio_stream_close;
351 stream->rewind_feeder = modaudio_stream_rewind;
352 stream->seek_feeder = modaudio_stream_seek;
353 stream->get_feeder_position = modaudio_stream_get_position;
354 stream->get_feeder_length = modaudio_stream_get_length;
355 stream->set_feeder_loop = modaudio_stream_set_loop;
356 _al_acodec_start_feed_thread(stream);
357 }
358 else {
359 ALLEGRO_ERROR("Failed to create stream.\n");
360 goto Error;
361 }
362
363 return stream;
364
365 Error:
366
367 if (sig) {
368 lib.duh_end_sigrenderer(sig);
369 }
370
371 if (duh) {
372 lib.unload_duh(duh);
373 }
374
375 /* try to return back to where we started to load */
376 if (start_pos != -1)
377 al_fseek(f, start_pos, ALLEGRO_SEEK_SET);
378
379 return NULL;
380 }
381
382 static void shutdown_libdumb(void)
383 {
384 if (libdumb_loaded) {
385 lib.dumb_exit();
386 libdumb_loaded = false;
387 }
388
389 #ifdef ALLEGRO_CFG_ACODEC_DUMB_DLL
390 if (dumb_dll) {
391 _al_close_library(dumb_dll);
392 dumb_dll = NULL;
393 }
394 #endif
395 }
396
397 static bool init_libdumb(void)
398 {
399 if (libdumb_loaded) {
400 return true;
401 }
402
403 #ifdef ALLEGRO_CFG_ACODEC_DUMB_DLL
404 dumb_dll = _al_open_library(ALLEGRO_CFG_ACODEC_DUMB_DLL);
405 if (!dumb_dll) {
406 ALLEGRO_ERROR("Could not load " ALLEGRO_CFG_ACODEC_DUMB_DLL "\n");
407 return false;
408 }
409
410 #define INITSYM(x) \
411 do \
412 { \
413 lib.x = _al_import_symbol(dumb_dll, #x); \
414 if (lib.x == 0) { \
415 ALLEGRO_ERROR("undefined symbol in lib structure: " #x "\n"); \
416 return false; \
417 } \
418 } while(0)
419 #else
420 #define INITSYM(x) (lib.x = (x))
421 #endif
422
423 _al_add_exit_func(shutdown_libdumb, "shutdown_libdumb");
424
425 memset(&lib, 0, sizeof(lib));
426
427 INITSYM(duh_render); /* see comment on duh_render deprecation above */
428 INITSYM(duh_sigrenderer_get_position);
429 INITSYM(duh_end_sigrenderer);
430 INITSYM(unload_duh);
431 INITSYM(duh_start_sigrenderer);
432 INITSYM(dumbfile_open_ex);
433 INITSYM(duh_get_length);
434 INITSYM(dumb_exit);
435 INITSYM(register_dumbfile_system);
436 INITSYM(duh_get_it_sigrenderer);
437 INITSYM(dumb_it_set_loop_callback);
438 INITSYM(dumb_it_set_xm_speed_zero_callback);
439 INITSYM(dumb_it_callback_terminate);
440
441 dfs.open = dfs_open;
442 dfs.skip = dfs_skip;
443 dfs.getc = dfs_getc;
444 dfs.getnc = dfs_getnc;
445 dfs.close = dfs_close;
446
447 #if (DUMB_MAJOR_VERSION) >= 2
448 INITSYM(dumb_read_any);
449
450 dfs.seek = dfs_seek;
451 dfs.get_size = dfs_get_size;
452 #else
453 INITSYM(dumb_read_it);
454 INITSYM(dumb_read_xm);
455 INITSYM(dumb_read_s3m);
456 INITSYM(dumb_read_mod);
457 #endif
458
459 /* Set up DUMB's default I/O to go through Allegro... */
460 lib.register_dumbfile_system(&dfs);
461
462 /* But we'll actually use them through this version: */
463 dfs_f = dfs;
464 dfs_f.open = NULL;
465 dfs_f.close = NULL;
466
467 libdumb_loaded = true;
468 return true;
469 }
470
471 #if (DUMB_MAJOR_VERSION) >= 2
472
473 static ALLEGRO_AUDIO_STREAM *load_dumb_audio_stream_f(ALLEGRO_FILE *f,
474 size_t buffer_count, unsigned int samples)
475 {
476 if (!init_libdumb())
477 return NULL;
478 return modaudio_stream_init(f, buffer_count, samples);
479 }
480
481 /*
482 * DUMB 2.0 figures out the file format for us.
483 * Need only one loader from disk file and one loader from DUMBFILE.
484 */
485 static ALLEGRO_AUDIO_STREAM *load_dumb_audio_stream(const char *filename,
486 size_t buffer_count, unsigned int samples)
487 {
488 ALLEGRO_FILE *f;
489 ALLEGRO_AUDIO_STREAM *stream;
490 ASSERT(filename);
491
492 f = al_fopen(filename, "rb");
493 if (!f)
494 return NULL;
495
496 stream = load_dumb_audio_stream_f(f, buffer_count, samples);
497
498 if (!stream) {
499 al_fclose(f);
500 return NULL;
501 }
502
503 ((MOD_FILE *)stream->extra)->fh = f;
504
505 return stream;
506 }
507
508 #else
509 /*
510 * For DUMB 0.9.3:
511 *
512 * 4 separate loaders for the 4 file formats supported by DUMB 0.9.3,
513 * then 4 loaders that take a DUMBFILE. The loaders from file are
514 * all identical, except for the function called in the middle.
515 */
516
517 static ALLEGRO_AUDIO_STREAM *load_mod_audio_stream_f(ALLEGRO_FILE *f,
518 size_t buffer_count, unsigned int samples)
519 {
520 if (!init_libdumb())
521 return NULL;
522 return modaudio_stream_init(f, buffer_count, samples, lib.dumb_read_mod);
523 }
524
525 static ALLEGRO_AUDIO_STREAM *load_it_audio_stream_f(ALLEGRO_FILE *f,
526 size_t buffer_count, unsigned int samples)
527 {
528 if (!init_libdumb())
529 return NULL;
530 return modaudio_stream_init(f, buffer_count, samples, lib.dumb_read_it);
531 }
532
533 static ALLEGRO_AUDIO_STREAM *load_xm_audio_stream_f(ALLEGRO_FILE *f,
534 size_t buffer_count, unsigned int samples)
535 {
536 if (!init_libdumb())
537 return NULL;
538 return modaudio_stream_init(f, buffer_count, samples, lib.dumb_read_xm);
539 }
540
541 static ALLEGRO_AUDIO_STREAM *load_s3m_audio_stream_f(ALLEGRO_FILE *f,
542 size_t buffer_count, unsigned int samples)
543 {
544 if (!init_libdumb())
545 return NULL;
546 return modaudio_stream_init(f, buffer_count, samples, lib.dumb_read_s3m);
547 }
548
549 static ALLEGRO_AUDIO_STREAM *load_mod_audio_stream(const char *filename,
550 size_t buffer_count, unsigned int samples)
551 {
552 ALLEGRO_FILE *f;
553 ALLEGRO_AUDIO_STREAM *stream;
554 ASSERT(filename);
555
556 f = al_fopen(filename, "rb");
557 if (!f) {
558 ALLEGRO_ERROR("Unable to open %s for reading.\n", filename);
559 return NULL;
560 }
561
562 stream = load_mod_audio_stream_f(f, buffer_count, samples);
563
564 if (!stream) {
565 al_fclose(f);
566 return NULL;
567 }
568
569 ((MOD_FILE *)stream->extra)->fh = f;
570
571 return stream;
572 }
573
574 static ALLEGRO_AUDIO_STREAM *load_it_audio_stream(const char *filename,
575 size_t buffer_count, unsigned int samples)
576 {
577 ALLEGRO_FILE *f;
578 ALLEGRO_AUDIO_STREAM *stream;
579 ASSERT(filename);
580
581 f = al_fopen(filename, "rb");
582 if (!f) {
583 ALLEGRO_ERROR("Unable to open %s for reading.\n", filename);
584 return NULL;
585 }
586
587 stream = load_it_audio_stream_f(f, buffer_count, samples);
588
589 if (!stream) {
590 al_fclose(f);
591 return NULL;
592 }
593
594 ((MOD_FILE *)stream->extra)->fh = f;
595
596 return stream;
597 }
598
599 static ALLEGRO_AUDIO_STREAM *load_xm_audio_stream(const char *filename,
600 size_t buffer_count, unsigned int samples)
601 {
602 ALLEGRO_FILE *f;
603 ALLEGRO_AUDIO_STREAM *stream;
604 ASSERT(filename);
605
606 f = al_fopen(filename, "rb");
607 if (!f) {
608 ALLEGRO_ERROR("Unable to open %s for reading.\n", filename);
609 return NULL;
610 }
611
612 stream = load_xm_audio_stream_f(f, buffer_count, samples);
613
614 if (!stream) {
615 al_fclose(f);
616 return NULL;
617 }
618
619 ((MOD_FILE *)stream->extra)->fh = f;
620
621 return stream;
622 }
623
624 static ALLEGRO_AUDIO_STREAM *load_s3m_audio_stream(const char *filename,
625 size_t buffer_count, unsigned int samples)
626 {
627 ALLEGRO_FILE *f;
628 ALLEGRO_AUDIO_STREAM *stream;
629 ASSERT(filename);
630
631 f = al_fopen(filename, "rb");
632 if (!f) {
633 ALLEGRO_ERROR("Unable to open %s for reading.\n", filename);
634 return NULL;
635 }
636
637 stream = load_s3m_audio_stream_f(f, buffer_count, samples);
638
639 if (!stream) {
640 al_fclose(f);
641 return NULL;
642 }
643
644 ((MOD_FILE *)stream->extra)->fh = f;
645
646 return stream;
647 }
648
649 #endif // DUMB_MAJOR_VERSION
650
651
652 bool _al_register_dumb_loaders(void)
653 {
654 bool ret = true;
655 #if (DUMB_MAJOR_VERSION) >= 2
656 /*
657 * DUMB 2.0 offers a single loader for at least 13 formats, see their
658 * readme. Amiga NoiseTracker isn't listed there, but it's DUMB-supported.
659 * It merely has no common extensions, see:
660 * https://github.com/kode54/dumb/issues/53
661 */
662 ret &= al_register_audio_stream_loader(".669", load_dumb_audio_stream);
663 ret &= al_register_audio_stream_loader_f(".669", load_dumb_audio_stream_f);
664 ret &= al_register_sample_identifier(".669", _al_identify_669);
665 ret &= al_register_audio_stream_loader(".amf", load_dumb_audio_stream);
666 ret &= al_register_audio_stream_loader_f(".amf", load_dumb_audio_stream_f);
667 ret &= al_register_sample_identifier(".amf", _al_identify_amf);
668 ret &= al_register_audio_stream_loader(".asy", load_dumb_audio_stream);
669 ret &= al_register_audio_stream_loader_f(".asy", load_dumb_audio_stream_f);
670 ret &= al_register_sample_identifier(".asy", _al_identify_asy);
671 ret &= al_register_audio_stream_loader(".it", load_dumb_audio_stream);
672 ret &= al_register_audio_stream_loader_f(".it", load_dumb_audio_stream_f);
673 ret &= al_register_sample_identifier(".it", _al_identify_it);
674 ret &= al_register_audio_stream_loader(".mod", load_dumb_audio_stream);
675 ret &= al_register_audio_stream_loader_f(".mod", load_dumb_audio_stream_f);
676 ret &= al_register_sample_identifier(".mod", _al_identify_mod);
677 ret &= al_register_audio_stream_loader(".mtm", load_dumb_audio_stream);
678 ret &= al_register_audio_stream_loader_f(".mtm", load_dumb_audio_stream_f);
679 ret &= al_register_sample_identifier(".mtm", _al_identify_mtm);
680 ret &= al_register_audio_stream_loader(".okt", load_dumb_audio_stream);
681 ret &= al_register_audio_stream_loader_f(".okt", load_dumb_audio_stream_f);
682 ret &= al_register_sample_identifier(".okt", _al_identify_okt);
683 ret &= al_register_audio_stream_loader(".psm", load_dumb_audio_stream);
684 ret &= al_register_audio_stream_loader_f(".psm", load_dumb_audio_stream_f);
685 ret &= al_register_sample_identifier(".psm", _al_identify_psm);
686 ret &= al_register_audio_stream_loader(".ptm", load_dumb_audio_stream);
687 ret &= al_register_audio_stream_loader_f(".ptm", load_dumb_audio_stream_f);
688 ret &= al_register_sample_identifier(".ptm", _al_identify_ptm);
689 ret &= al_register_audio_stream_loader(".riff", load_dumb_audio_stream);
690 ret &= al_register_audio_stream_loader_f(".riff", load_dumb_audio_stream_f);
691 ret &= al_register_sample_identifier(".riff", _al_identify_riff);
692 ret &= al_register_audio_stream_loader(".s3m", load_dumb_audio_stream);
693 ret &= al_register_audio_stream_loader_f(".s3m", load_dumb_audio_stream_f);
694 ret &= al_register_sample_identifier(".s3m", _al_identify_s3m);
695 ret &= al_register_audio_stream_loader(".stm", load_dumb_audio_stream);
696 ret &= al_register_audio_stream_loader_f(".stm", load_dumb_audio_stream_f);
697 ret &= al_register_sample_identifier(".stm", _al_identify_stm);
698 ret &= al_register_audio_stream_loader(".xm", load_dumb_audio_stream);
699 ret &= al_register_audio_stream_loader_f(".xm", load_dumb_audio_stream_f);
700 ret &= al_register_sample_identifier(".xm", _al_identify_xm);
701 #else
702 /*
703 * DUMB 0.9.3 supported only these 4 formats and had no *_any loader.
704 * Avoid DUMB 1.0 because of versioning problems: dumb.h from git tag 1.0
705 * reports 0.9.3 in its version numbers.
706 */
707 ret &= al_register_audio_stream_loader(".xm", load_xm_audio_stream);
708 ret &= al_register_audio_stream_loader_f(".xm", load_xm_audio_stream_f);
709 ret &= al_register_sample_identifier(".xm", _al_identify_xm);
710 ret &= al_register_audio_stream_loader(".it", load_it_audio_stream);
711 ret &= al_register_audio_stream_loader_f(".it", load_it_audio_stream_f);
712 ret &= al_register_sample_identifier(".it", _al_identify_it);
713 ret &= al_register_audio_stream_loader(".mod", load_mod_audio_stream);
714 ret &= al_register_audio_stream_loader_f(".mod", load_mod_audio_stream_f);
715 ret &= al_register_sample_identifier(".mod", _al_identify_mod);
716 ret &= al_register_audio_stream_loader(".s3m", load_s3m_audio_stream);
717 ret &= al_register_audio_stream_loader_f(".s3m", load_s3m_audio_stream_f);
718 ret &= al_register_sample_identifier(".s3m", _al_identify_s3m);
719 #endif // DUMB_MAJOR_VERSION
720 return ret;
721 }
722
723 /* vim: set sts=3 sw=3 et: */