comparison decoders/modplug.c @ 211:b35c04e4691e

Patched to select streams to handle more carefully.
author Ryan C. Gordon <icculus@icculus.org>
date Fri, 11 Jan 2002 11:10:22 +0000
parents 32376317eedb
children c9772a9f5271
comparison
equal deleted inserted replaced
210:4861069841b9 211:b35c04e4691e
50 static void MODPLUG_close(Sound_Sample *sample); 50 static void MODPLUG_close(Sound_Sample *sample);
51 static Uint32 MODPLUG_read(Sound_Sample *sample); 51 static Uint32 MODPLUG_read(Sound_Sample *sample);
52 52
53 static const char *extensions_modplug[] = 53 static const char *extensions_modplug[] =
54 { 54 {
55 /* Plays 22 different mod formats (there are two kinds of AMF), including: 55 /* The XMMS plugin is apparently able to load compressed modules as
56 */ 56 * well, but libmodplug does not handle this.
57 "MOD", "S3M", "XM", "IT", "669", "AMF", "AMS", "DMB", 57 */
58 "DMF", "DSM", "FAR", "MDL", "MED", "MHM", "OKT", "PTM", 58 "669", /* Composer 669 / UNIS 669 module */
59 "STM", "ULT", "UMX", "MT2", "PSM", 59 "AMF", /* ASYLUM Music Format / Advanced Music Format(DSM) */
60 60 "AMS", /* AMS module */
61 /* Plays zip, rar, gzip, and bzip2 compressed mods. The following 61 "DBM", /* DigiBooster Pro Module */
62 * extensions are recognized: 62 "DMF", /* DMF DELUSION DIGITAL MUSIC FILEFORMAT (X-Tracker) */
63 */ 63 "DSM", /* DSIK Internal Format module */
64 "MDZ", "S3Z", "XMZ", "ITZ", /* zip */ 64 "FAR", /* Farandole module */
65 "MDR", "S3R", "XMR", "ITR", /* rar */ 65 "IT", /* Impulse Tracker IT file */
66 "MDGZ", "S3GZ", "XMGZ", "ITGZ", /* gzip */ 66 "MDL", /* DigiTracker module */
67
68 /* You can also load plain old ZIP, RAR, and GZ files. If ModPlug finds
69 * a mod in them, it will play it.
70 */
71 #if 0 67 #if 0
72 "ZIP", "RAR", "GZ", 68 "J2B", /* Not implemented? What is it anyway? */
73 #endif 69 #endif
74 70 "MED", /* OctaMed MED file */
71 "MOD", /* ProTracker / NoiseTracker MOD/NST file */
72 "MT2", /* MadTracker 2.0 */
73 "MTM", /* MTM file */
74 "OKT", /* Oktalyzer module */
75 "PTM", /* PTM PolyTracker module */
76 "PSM", /* PSM module */
77 "S3M", /* ScreamTracker file */
78 "STM", /* ST 2.xx */
79 "ULT",
80 "UMX",
81 "XM", /* FastTracker II */
75 NULL 82 NULL
76 }; 83 };
77 84
78 const Sound_DecoderFunctions __Sound_DecoderFunctions_MODPLUG = 85 const Sound_DecoderFunctions __Sound_DecoderFunctions_MODPLUG =
79 { 86 {
122 } /* MODPLUG_init */ 129 } /* MODPLUG_init */
123 130
124 131
125 static void MODPLUG_quit(void) 132 static void MODPLUG_quit(void)
126 { 133 {
134 /* it's a no-op. */
127 } /* MODPLUG_quit */ 135 } /* MODPLUG_quit */
128 136
129 137
130 /* Most MOD files I've seen have tended to be a few hundred KB, even if some 138 /* Most MOD files I've seen have tended to be a few hundred KB, even if some
131 * of them were much smaller than that. 139 * of them were much smaller than that.
137 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; 145 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
138 ModPlugFile *module; 146 ModPlugFile *module;
139 Uint8 *data; 147 Uint8 *data;
140 size_t size; 148 size_t size;
141 Uint32 retval; 149 Uint32 retval;
142 150 int has_extension = 0;
151 int i;
152
153 /* Apparently ModPlug's loaders are too forgiving. They gladly accept
154 * streams that they shouldn't. For now, rely on file extension instead.
155 */
156 for (i = 0; extensions_modplug[i] != NULL; i++)
157 {
158 if (__Sound_strcasecmp(ext, extensions_modplug[i]) == 0)
159 {
160 has_extension = 1;
161 break;
162 } /* if */
163 } /* for */
164
165 if (!has_extension)
166 {
167 SNDDBG(("MODPLUG: Unrecognized file type: %s\n", ext));
168 return(0);
169 }
170
143 /* ModPlug needs the entire stream in one big chunk. I don't like it, 171 /* ModPlug needs the entire stream in one big chunk. I don't like it,
144 * but I don't think there's any way around it. 172 * but I don't think there's any way around it.
145 */ 173 */
146 data = (Uint8 *) malloc(CHUNK_SIZE); 174 data = (Uint8 *) malloc(CHUNK_SIZE);
147 BAIL_IF_MACRO(data == NULL, ERR_OUT_OF_MEMORY, 0); 175 BAIL_IF_MACRO(data == NULL, ERR_OUT_OF_MEMORY, 0);