Mercurial > SDL_sound_CoreAudio
changeset 149:1df5c106504e
Decoders can now list multiple file extensions.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Thu, 01 Nov 2001 19:13:17 +0000 |
parents | d51546293fd1 |
children | 033afe96afbc |
files | CHANGELOG SDL_sound.c SDL_sound.h decoders/aiff.c decoders/midi.c decoders/mod.c decoders/mp3.c decoders/ogg.c decoders/raw.c decoders/shn.c decoders/skeleton.c decoders/voc.c decoders/wav.c |
diffstat | 13 files changed, 49 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/CHANGELOG Thu Nov 01 19:12:36 2001 +0000 +++ b/CHANGELOG Thu Nov 01 19:13:17 2001 +0000 @@ -101,6 +101,10 @@ 10232001 - Rewrote playsound.c's audio_callback() to no longer need the overflow buffer hack, which streamlines it a little and trims the memory requirements for playsound by about 16 kilobytes. +11012001 - API COMPATIBILITY BREAKAGE: Decoders can now list multiple file + extensions each. Playsound has been updated to handle this. + Playsound now registers a SIGINT handler, so you can skip tracks + and/or abort the way that mpg123 does. --ryan. (icculus@clutteredmind.org)
--- a/SDL_sound.c Thu Nov 01 19:12:36 2001 +0000 +++ b/SDL_sound.c Thu Nov 01 19:13:17 2001 +0000 @@ -444,8 +444,8 @@ Sound_Sample *Sound_NewSample(SDL_RWops *rw, const char *ext, Sound_AudioInfo *desired, Uint32 bSize) { - size_t i; Sound_Sample *retval; + decoder_element *decoder; /* sanity checks. */ BAIL_IF_MACRO(!initialized, ERR_NOT_INITIALIZED, NULL); @@ -457,26 +457,30 @@ if (ext != NULL) { - for (i = 0; decoders[i].funcs != NULL; i++) + for (decoder = &decoders[0]; decoder->funcs != NULL; decoder++) { - if (decoders[i].available) + if (decoder->available) { - const char *decoderExt = decoders[i].funcs->info.extension; - if (__Sound_strcasecmp(decoderExt, ext) == 0) + const char **decoderExt = decoder->funcs->info.extensions; + while (*decoderExt) { - if (init_sample(decoders[i].funcs, retval, ext, desired)) - return(retval); - } /* if */ + if (__Sound_strcasecmp(*decoderExt, ext) == 0) + { + if (init_sample(decoder->funcs, retval, ext, desired)) + return(retval); + } /* if */ + decoderExt++; + } /* while */ } /* if */ } /* for */ } /* if */ /* no direct extension match? Try everything we've got... */ - for (i = 0; decoders[i].funcs != NULL; i++) + for (decoder = &decoders[0]; decoder->funcs != NULL; decoder++) { - if (decoders[i].available) + if (decoder->available) { - if (init_sample(decoders[i].funcs, retval, ext, desired)) + if (init_sample(decoder->funcs, retval, ext, desired)) return(retval); } /* if */ } /* for */
--- a/SDL_sound.h Thu Nov 01 19:12:36 2001 +0000 +++ b/SDL_sound.h Thu Nov 01 19:13:17 2001 +0000 @@ -112,10 +112,10 @@ */ typedef struct __SOUND_DECODERINFO__ { - const char *extension; /* standard file extension. "MP3", "WAV"... */ - const char *description; /* Human readable description of decoder. */ - const char *author; /* "Name Of Author <email@emailhost.dom>" */ - const char *url; /* URL specific to this decoder. */ + const char **extensions; /* File extensions, list ends with NULL. */ + const char *description; /* Human readable description of decoder. */ + const char *author; /* "Name Of Author <email@emailhost.dom>" */ + const char *url; /* URL specific to this decoder. */ } Sound_DecoderInfo;
--- a/decoders/aiff.c Thu Nov 01 19:12:36 2001 +0000 +++ b/decoders/aiff.c Thu Nov 01 19:13:17 2001 +0000 @@ -63,10 +63,11 @@ static void AIFF_close(Sound_Sample *sample); static Uint32 AIFF_read(Sound_Sample *sample); +static const char *extensions_aiff[] = { "AIFF", NULL }; const Sound_DecoderFunctions __Sound_DecoderFunctions_AIFF = { { - "AIFF", + extensions_aiff, "Audio Interchange File Format", "Torbjörn Andersson <d91tan@Update.UU.SE>", "http://www.icculus.org/SDL_sound/"
--- a/decoders/midi.c Thu Nov 01 19:12:36 2001 +0000 +++ b/decoders/midi.c Thu Nov 01 19:13:17 2001 +0000 @@ -69,10 +69,11 @@ static void MIDI_close(Sound_Sample *sample); static Uint32 MIDI_read(Sound_Sample *sample); +static const char *extensions_midi[] = { "MIDI", NULL }; const Sound_DecoderFunctions __Sound_DecoderFunctions_MIDI = { { - "MIDI", + extensions_midi, "MIDI music through the TiMidity MIDI to WAVE converter", "Torbjörn Andersson <d91tan@Update.UU.SE>", "http://www.goice.co.jp/member/mo/timidity/"
--- a/decoders/mod.c Thu Nov 01 19:12:36 2001 +0000 +++ b/decoders/mod.c Thu Nov 01 19:13:17 2001 +0000 @@ -53,10 +53,17 @@ static void MOD_close(Sound_Sample *sample); static Uint32 MOD_read(Sound_Sample *sample); +static const char *extensions_mikmod[] = +{ + "MOD", "IT", "XM", "S3M", "MTM", "669", "STM", "ULT", + "FAR", "MED", "AMF", "DSM", "IMF", "GDM", "STX", "OKT", + NULL +}; + const Sound_DecoderFunctions __Sound_DecoderFunctions_MOD = { { - "MOD", + extensions_mikmod, "Play modules through MikMod", "Torbjörn Andersson <d91tan@Update.UU.SE>", "http://www.mikmod.org/"
--- a/decoders/mp3.c Thu Nov 01 19:12:36 2001 +0000 +++ b/decoders/mp3.c Thu Nov 01 19:13:17 2001 +0000 @@ -55,10 +55,11 @@ static void MP3_close(Sound_Sample *sample); static Uint32 MP3_read(Sound_Sample *sample); +static const char *extensions_smpeg[] = { "MP3", "MPEG", "MPG", NULL }; const Sound_DecoderFunctions __Sound_DecoderFunctions_MP3 = { { - "MP3", + extensions_smpeg, "MPEG-1 Layer 3 audio through SMPEG", "Ryan C. Gordon <icculus@clutteredmind.org>", "http://www.icculus.org/SDL_sound/"
--- a/decoders/ogg.c Thu Nov 01 19:12:36 2001 +0000 +++ b/decoders/ogg.c Thu Nov 01 19:13:17 2001 +0000 @@ -59,10 +59,11 @@ static void OGG_close(Sound_Sample *sample); static Uint32 OGG_read(Sound_Sample *sample); +static const char *extensions_ogg[] = { "OGG", NULL }; const Sound_DecoderFunctions __Sound_DecoderFunctions_OGG = { { - "OGG", + extensions_ogg, "Ogg Vorbis audio through VorbisFile", "Ryan C. Gordon <icculus@clutteredmind.org>", "http://www.icculus.org/SDL_sound/"
--- a/decoders/raw.c Thu Nov 01 19:12:36 2001 +0000 +++ b/decoders/raw.c Thu Nov 01 19:13:17 2001 +0000 @@ -60,10 +60,11 @@ static void RAW_close(Sound_Sample *sample); static Uint32 RAW_read(Sound_Sample *sample); +static const char *extensions_raw[] = { "RAW", NULL }; const Sound_DecoderFunctions __Sound_DecoderFunctions_RAW = { { - "RAW", + extensions_raw, "Raw audio", "Ryan C. Gordon <icculus@clutteredmind.org>", "http://www.icculus.org/SDL_sound/"
--- a/decoders/shn.c Thu Nov 01 19:12:36 2001 +0000 +++ b/decoders/shn.c Thu Nov 01 19:13:17 2001 +0000 @@ -67,10 +67,11 @@ static void SHN_close(Sound_Sample *sample); static Uint32 SHN_read(Sound_Sample *sample); +static const char *extensions_shn[] = { "SHN", NULL }; const Sound_DecoderFunctions __Sound_DecoderFunctions_SHN = { { - "SHN", + extensions_shn, "Shorten-compressed audio data", "Ryan C. Gordon <icculus@clutteredmind.org>", "http://www.icculus.org/SDL_sound/"
--- a/decoders/skeleton.c Thu Nov 01 19:12:36 2001 +0000 +++ b/decoders/skeleton.c Thu Nov 01 19:13:17 2001 +0000 @@ -56,10 +56,11 @@ static void FMT_close(Sound_Sample *sample); static Uint32 FMT_read(Sound_Sample *sample); +static const char *extensions_fmt[] = { "FMT", NULL }; const Sound_DecoderFunctions __Sound_DecoderFunctions_FMT = { { - "FMT", + extensions_fmt, "FMT audio format description", "Ryan C. Gordon <icculus@clutteredmind.org>", "http://www.icculus.org/SDL_sound/"
--- a/decoders/voc.c Thu Nov 01 19:12:36 2001 +0000 +++ b/decoders/voc.c Thu Nov 01 19:13:17 2001 +0000 @@ -59,10 +59,11 @@ static void VOC_close(Sound_Sample *sample); static Uint32 VOC_read(Sound_Sample *sample); +static const char *extensions_voc[] = { "VOC", NULL }; const Sound_DecoderFunctions __Sound_DecoderFunctions_VOC = { { - "VOC", + extensions_voc, "Creative Labs Voice format", "Ryan C. Gordon <icculus@clutteredmind.org>", "http://www.icculus.org/SDL_sound/"
--- a/decoders/wav.c Thu Nov 01 19:12:36 2001 +0000 +++ b/decoders/wav.c Thu Nov 01 19:13:17 2001 +0000 @@ -50,10 +50,11 @@ static void WAV_close(Sound_Sample *sample); static Uint32 WAV_read(Sound_Sample *sample); +static const char *extensions_wav[] = { "WAV", NULL }; const Sound_DecoderFunctions __Sound_DecoderFunctions_WAV = { { - "WAV", + extensions_wav, "Microsoft WAVE audio format", "Ryan C. Gordon <icculus@clutteredmind.org>", "http://www.icculus.org/SDL_sound/"