# HG changeset patch # User Ryan C. Gordon # Date 1004641997 0 # Node ID 1df5c106504ee7c994a765ada01f0fa18cc92a19 # Parent d51546293fd1962cee33d94f90f17595dfbac280 Decoders can now list multiple file extensions. diff -r d51546293fd1 -r 1df5c106504e CHANGELOG --- 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) diff -r d51546293fd1 -r 1df5c106504e SDL_sound.c --- 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 */ diff -r d51546293fd1 -r 1df5c106504e SDL_sound.h --- 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 " */ - 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 " */ + const char *url; /* URL specific to this decoder. */ } Sound_DecoderInfo; diff -r d51546293fd1 -r 1df5c106504e decoders/aiff.c --- 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 ", "http://www.icculus.org/SDL_sound/" diff -r d51546293fd1 -r 1df5c106504e decoders/midi.c --- 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 ", "http://www.goice.co.jp/member/mo/timidity/" diff -r d51546293fd1 -r 1df5c106504e decoders/mod.c --- 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 ", "http://www.mikmod.org/" diff -r d51546293fd1 -r 1df5c106504e decoders/mp3.c --- 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 ", "http://www.icculus.org/SDL_sound/" diff -r d51546293fd1 -r 1df5c106504e decoders/ogg.c --- 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 ", "http://www.icculus.org/SDL_sound/" diff -r d51546293fd1 -r 1df5c106504e decoders/raw.c --- 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 ", "http://www.icculus.org/SDL_sound/" diff -r d51546293fd1 -r 1df5c106504e decoders/shn.c --- 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 ", "http://www.icculus.org/SDL_sound/" diff -r d51546293fd1 -r 1df5c106504e decoders/skeleton.c --- 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 ", "http://www.icculus.org/SDL_sound/" diff -r d51546293fd1 -r 1df5c106504e decoders/voc.c --- 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 ", "http://www.icculus.org/SDL_sound/" diff -r d51546293fd1 -r 1df5c106504e decoders/wav.c --- 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 ", "http://www.icculus.org/SDL_sound/"