Mercurial > SDL_sound_CoreAudio
comparison decoders/modplug.c @ 221:c9772a9f5271
Initial implementation or stubs for rewind method. Other cleanups.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Thu, 17 Jan 2002 20:53:53 +0000 |
parents | b35c04e4691e |
children | d3dc34315ac7 |
comparison
equal
deleted
inserted
replaced
220:ef72f3c490e7 | 221:c9772a9f5271 |
---|---|
47 static int MODPLUG_init(void); | 47 static int MODPLUG_init(void); |
48 static void MODPLUG_quit(void); | 48 static void MODPLUG_quit(void); |
49 static int MODPLUG_open(Sound_Sample *sample, const char *ext); | 49 static int MODPLUG_open(Sound_Sample *sample, const char *ext); |
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 static int MODPLUG_rewind(Sound_Sample *sample); | |
52 | 53 |
53 static const char *extensions_modplug[] = | 54 static const char *extensions_modplug[] = |
54 { | 55 { |
55 /* The XMMS plugin is apparently able to load compressed modules as | 56 /* The XMMS plugin is apparently able to load compressed modules as |
56 * well, but libmodplug does not handle this. | 57 * well, but libmodplug does not handle this. |
89 "Play modules through ModPlug", | 90 "Play modules through ModPlug", |
90 "Torbjörn Andersson <d91tan@Update.UU.SE>", | 91 "Torbjörn Andersson <d91tan@Update.UU.SE>", |
91 "http://modplug-xmms.sourceforge.net/" | 92 "http://modplug-xmms.sourceforge.net/" |
92 }, | 93 }, |
93 | 94 |
94 MODPLUG_init, /* init() method */ | 95 MODPLUG_init, /* init() method */ |
95 MODPLUG_quit, /* quit() method */ | 96 MODPLUG_quit, /* quit() method */ |
96 MODPLUG_open, /* open() method */ | 97 MODPLUG_open, /* open() method */ |
97 MODPLUG_close, /* close() method */ | 98 MODPLUG_close, /* close() method */ |
98 MODPLUG_read /* read() method */ | 99 MODPLUG_read, /* read() method */ |
100 MODPLUG_rewind /* rewind() method */ | |
99 }; | 101 }; |
100 | 102 |
101 | 103 |
102 static int MODPLUG_init(void) | 104 static int MODPLUG_init(void) |
103 { | 105 { |
133 { | 135 { |
134 /* it's a no-op. */ | 136 /* it's a no-op. */ |
135 } /* MODPLUG_quit */ | 137 } /* MODPLUG_quit */ |
136 | 138 |
137 | 139 |
138 /* Most MOD files I've seen have tended to be a few hundred KB, even if some | 140 /* |
141 * Most MOD files I've seen have tended to be a few hundred KB, even if some | |
139 * of them were much smaller than that. | 142 * of them were much smaller than that. |
140 */ | 143 */ |
141 #define CHUNK_SIZE 65536 | 144 #define CHUNK_SIZE 65536 |
142 | 145 |
143 static int MODPLUG_open(Sound_Sample *sample, const char *ext) | 146 static int MODPLUG_open(Sound_Sample *sample, const char *ext) |
148 size_t size; | 151 size_t size; |
149 Uint32 retval; | 152 Uint32 retval; |
150 int has_extension = 0; | 153 int has_extension = 0; |
151 int i; | 154 int i; |
152 | 155 |
153 /* Apparently ModPlug's loaders are too forgiving. They gladly accept | 156 /* |
154 * streams that they shouldn't. For now, rely on file extension instead. | 157 * Apparently ModPlug's loaders are too forgiving. They gladly accept |
158 * streams that they shouldn't. For now, rely on file extension instead. | |
155 */ | 159 */ |
156 for (i = 0; extensions_modplug[i] != NULL; i++) | 160 for (i = 0; extensions_modplug[i] != NULL; i++) |
157 { | 161 { |
158 if (__Sound_strcasecmp(ext, extensions_modplug[i]) == 0) | 162 if (__Sound_strcasecmp(ext, extensions_modplug[i]) == 0) |
159 { | 163 { |
160 has_extension = 1; | 164 has_extension = 1; |
161 break; | 165 break; |
162 } /* if */ | 166 } /* if */ |
163 } /* for */ | 167 } /* for */ |
164 | 168 |
165 if (!has_extension) | 169 if (!has_extension) |
166 { | 170 { |
167 SNDDBG(("MODPLUG: Unrecognized file type: %s\n", ext)); | 171 SNDDBG(("MODPLUG: Unrecognized file type: %s\n", ext)); |
168 return(0); | 172 Sound_SetError("MODPLUG: Not a module file."); |
169 } | 173 return(0); |
174 } /* if */ | |
170 | 175 |
171 /* ModPlug needs the entire stream in one big chunk. I don't like it, | 176 /* ModPlug needs the entire stream in one big chunk. I don't like it, |
172 * but I don't think there's any way around it. | 177 * but I don't think there's any way around it. |
173 */ | 178 */ |
174 data = (Uint8 *) malloc(CHUNK_SIZE); | 179 data = (Uint8 *) malloc(CHUNK_SIZE); |
227 if (retval == 0) | 232 if (retval == 0) |
228 sample->flags |= SOUND_SAMPLEFLAG_EOF; | 233 sample->flags |= SOUND_SAMPLEFLAG_EOF; |
229 return(retval); | 234 return(retval); |
230 } /* MODPLUG_read */ | 235 } /* MODPLUG_read */ |
231 | 236 |
237 | |
238 static int MODPLUG_rewind(Sound_Sample *sample) | |
239 { | |
240 /* !!! FIXME. */ | |
241 SNDDBG(("MODPLUG_rewind(): Write me!\n")); | |
242 assert(0); | |
243 return(0); | |
244 } /* MODPLUG_rewind */ | |
245 | |
232 #endif /* SOUND_SUPPORTS_MODPLUG */ | 246 #endif /* SOUND_SUPPORTS_MODPLUG */ |
233 | 247 |
234 | 248 |
235 /* end of modplug.c ... */ | 249 /* end of modplug.c ... */ |