| 1 |
#include "allegro5/allegro_acodec.h" |
| 2 |
#include "allegro5/allegro_audio.h" |
| 3 |
#include "allegro5/internal/aintern_acodec_cfg.h" |
| 4 |
#include "acodec.h" |
| 5 |
|
| 6 |
|
| 7 |
/* globals */ |
| 8 |
static bool acodec_inited = false; |
| 9 |
|
| 10 |
|
| 11 |
/* Function: al_get_allegro_acodec_version |
| 12 |
*/ |
| 13 |
uint32_t al_get_allegro_acodec_version(void) |
| 14 |
{ |
| 15 |
return ALLEGRO_VERSION_INT; |
| 16 |
} |
| 17 |
|
| 18 |
|
| 19 |
/* Function: al_init_acodec_addon |
| 20 |
*/ |
| 21 |
bool al_init_acodec_addon(void) |
| 22 |
{ |
| 23 |
bool acodec_prefer_dumb = false; |
| 24 |
const char* acodec_prefer_dumb_value = |
| 25 |
al_get_config_value(al_get_system_config(), "compatibility", "acodec_prefer_dumb"); |
| 26 |
if (acodec_prefer_dumb_value && strcmp(acodec_prefer_dumb_value, "true") == 0) |
| 27 |
acodec_prefer_dumb = true; |
| 28 |
|
| 29 |
bool ret = true; |
| 30 |
|
| 31 |
ret &= al_register_sample_loader(".wav", _al_load_wav); |
| 32 |
ret &= al_register_sample_saver(".wav", _al_save_wav); |
| 33 |
ret &= al_register_sample_loader_f(".wav", _al_load_wav_f); |
| 34 |
ret &= al_register_sample_saver_f(".wav", _al_save_wav_f); |
| 35 |
ret &= al_register_audio_stream_loader(".wav", _al_load_wav_audio_stream); |
| 36 |
ret &= al_register_audio_stream_loader_f(".wav", _al_load_wav_audio_stream_f); |
| 37 |
ret &= al_register_sample_identifier(".wav", _al_identify_wav); |
| 38 |
|
| 39 |
/* buil-in VOC loader */ |
| 40 |
ret &= al_register_sample_loader(".voc", _al_load_voc); |
| 41 |
ret &= al_register_sample_loader_f(".voc", _al_load_voc_f); |
| 42 |
ret &= al_register_sample_identifier(".voc", _al_identify_voc); |
| 43 |
|
| 44 |
#ifdef ALLEGRO_CFG_ACODEC_FLAC |
| 45 |
ret &= al_register_sample_loader(".flac", _al_load_flac); |
| 46 |
ret &= al_register_audio_stream_loader(".flac", _al_load_flac_audio_stream); |
| 47 |
ret &= al_register_sample_loader_f(".flac", _al_load_flac_f); |
| 48 |
ret &= al_register_audio_stream_loader_f(".flac", _al_load_flac_audio_stream_f); |
| 49 |
ret &= al_register_sample_identifier(".flac", _al_identify_flac); |
| 50 |
#endif |
| 51 |
|
| 52 |
#ifdef ALLEGRO_CFG_ACODEC_VORBIS |
| 53 |
ret &= al_register_sample_loader(".ogg", _al_load_ogg_vorbis); |
| 54 |
ret &= al_register_audio_stream_loader(".ogg", _al_load_ogg_vorbis_audio_stream); |
| 55 |
ret &= al_register_sample_loader_f(".ogg", _al_load_ogg_vorbis_f); |
| 56 |
ret &= al_register_audio_stream_loader_f(".ogg", _al_load_ogg_vorbis_audio_stream_f); |
| 57 |
ret &= al_register_sample_identifier(".ogg", _al_identify_ogg_vorbis); |
| 58 |
#endif |
| 59 |
|
| 60 |
#ifdef ALLEGRO_CFG_ACODEC_OPUS |
| 61 |
ret &= al_register_sample_loader(".opus", _al_load_ogg_opus); |
| 62 |
ret &= al_register_audio_stream_loader(".opus", _al_load_ogg_opus_audio_stream); |
| 63 |
ret &= al_register_sample_loader_f(".opus", _al_load_ogg_opus_f); |
| 64 |
ret &= al_register_audio_stream_loader_f(".opus", _al_load_ogg_opus_audio_stream_f); |
| 65 |
ret &= al_register_sample_identifier(".opus", _al_identify_ogg_opus); |
| 66 |
#endif |
| 67 |
|
| 68 |
#ifdef ALLEGRO_CFG_ACODEC_DUMB |
| 69 |
if (!acodec_prefer_dumb) |
| 70 |
ret &= _al_register_dumb_loaders(); |
| 71 |
#endif |
| 72 |
|
| 73 |
#ifdef ALLEGRO_CFG_ACODEC_OPENMPT |
| 74 |
ret &= _al_register_openmpt_loaders(); |
| 75 |
#endif |
| 76 |
|
| 77 |
#ifdef ALLEGRO_CFG_ACODEC_DUMB |
| 78 |
if (acodec_prefer_dumb) |
| 79 |
ret &= _al_register_dumb_loaders(); |
| 80 |
#endif |
| 81 |
|
| 82 |
/* MP3 will mis-identify a lot of mod files, so put its identifier last */ |
| 83 |
#ifdef ALLEGRO_CFG_ACODEC_MP3 |
| 84 |
ret &= al_register_sample_loader(".mp3", _al_load_mp3); |
| 85 |
ret &= al_register_audio_stream_loader(".mp3", _al_load_mp3_audio_stream); |
| 86 |
ret &= al_register_sample_loader_f(".mp3", _al_load_mp3_f); |
| 87 |
ret &= al_register_audio_stream_loader_f(".mp3", _al_load_mp3_audio_stream_f); |
| 88 |
ret &= al_register_sample_identifier(".mp3", _al_identify_mp3); |
| 89 |
#endif |
| 90 |
|
| 91 |
acodec_inited = ret; |
| 92 |
|
| 93 |
return ret; |
| 94 |
} |
| 95 |
|
| 96 |
|
| 97 |
/* Function: al_is_acodec_addon_initialized |
| 98 |
*/ |
| 99 |
bool al_is_acodec_addon_initialized(void) |
| 100 |
{ |
| 101 |
return acodec_inited; |
| 102 |
} |
| 103 |
|
| 104 |
|
| 105 |
/* vim: set sts=3 sw=3 et: */ |