diff options
Diffstat (limited to 'apps/codecs/mod.c')
-rw-r--r-- | apps/codecs/mod.c | 67 |
1 files changed, 24 insertions, 43 deletions
diff --git a/apps/codecs/mod.c b/apps/codecs/mod.c index 4ace721a1e..3dfaac663f 100644 --- a/apps/codecs/mod.c +++ b/apps/codecs/mod.c | |||
@@ -1218,47 +1218,37 @@ void synthrender(int32_t *renderbuffer, int samplecount) | |||
1218 | } | 1218 | } |
1219 | } | 1219 | } |
1220 | 1220 | ||
1221 | /* this is the codec entry point */ | ||
1222 | enum codec_status codec_main(enum codec_entry_call_reason reason) | ||
1223 | { | ||
1224 | if (reason == CODEC_LOAD) { | ||
1225 | /* Make use of 44.1khz */ | ||
1226 | ci->configure(DSP_SET_FREQUENCY, 44100); | ||
1227 | /* Sample depth is 28 bit host endian */ | ||
1228 | ci->configure(DSP_SET_SAMPLE_DEPTH, 28); | ||
1229 | /* Stereo output */ | ||
1230 | ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED); | ||
1231 | } | ||
1232 | |||
1233 | return CODEC_OK; | ||
1234 | } | ||
1221 | 1235 | ||
1222 | enum codec_status codec_main(void) | 1236 | /* this is called for each file to process */ |
1237 | enum codec_status codec_run(void) | ||
1223 | { | 1238 | { |
1224 | size_t n; | 1239 | size_t n; |
1225 | unsigned char *modfile; | 1240 | unsigned char *modfile; |
1226 | int old_patterntableposition; | 1241 | int old_patterntableposition; |
1227 | |||
1228 | int bytesdone; | 1242 | int bytesdone; |
1243 | intptr_t param; | ||
1229 | 1244 | ||
1230 | next_track: | ||
1231 | if (codec_init()) { | 1245 | if (codec_init()) { |
1232 | return CODEC_ERROR; | 1246 | return CODEC_ERROR; |
1233 | } | 1247 | } |
1234 | 1248 | ||
1235 | if (codec_wait_taginfo() != 0) | ||
1236 | goto request_next_track; | ||
1237 | |||
1238 | codec_set_replaygain(ci->id3); | 1249 | codec_set_replaygain(ci->id3); |
1239 | 1250 | ||
1240 | /* Load MOD file */ | 1251 | /* Load MOD file */ |
1241 | /* | ||
1242 | * This is the save way | ||
1243 | |||
1244 | size_t bytesfree; | ||
1245 | unsigned int filesize; | ||
1246 | |||
1247 | p = modfile; | ||
1248 | bytesfree=sizeof(modfile); | ||
1249 | while ((n = ci->read_filebuf(p, bytesfree)) > 0) { | ||
1250 | p += n; | ||
1251 | bytesfree -= n; | ||
1252 | if (bytesfree == 0) | ||
1253 | return CODEC_ERROR; | ||
1254 | } | ||
1255 | filesize = p-modfile; | ||
1256 | |||
1257 | if (filesize == 0) | ||
1258 | return CODEC_ERROR; | ||
1259 | */ | ||
1260 | |||
1261 | /* Directly use mod in buffer */ | ||
1262 | ci->seek_buffer(0); | 1252 | ci->seek_buffer(0); |
1263 | modfile = ci->request_buffer(&n, ci->filesize); | 1253 | modfile = ci->request_buffer(&n, ci->filesize); |
1264 | if (!modfile || n < (size_t)ci->filesize) { | 1254 | if (!modfile || n < (size_t)ci->filesize) { |
@@ -1268,27 +1258,22 @@ next_track: | |||
1268 | initmodplayer(); | 1258 | initmodplayer(); |
1269 | loadmod(modfile); | 1259 | loadmod(modfile); |
1270 | 1260 | ||
1271 | /* Make use of 44.1khz */ | ||
1272 | ci->configure(DSP_SET_FREQUENCY, 44100); | ||
1273 | /* Sample depth is 28 bit host endian */ | ||
1274 | ci->configure(DSP_SET_SAMPLE_DEPTH, 28); | ||
1275 | /* Stereo output */ | ||
1276 | ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED); | ||
1277 | |||
1278 | /* The main decoder loop */ | 1261 | /* The main decoder loop */ |
1279 | ci->set_elapsed(0); | 1262 | ci->set_elapsed(0); |
1280 | bytesdone = 0; | 1263 | bytesdone = 0; |
1281 | old_patterntableposition = 0; | 1264 | old_patterntableposition = 0; |
1282 | 1265 | ||
1283 | while (1) { | 1266 | while (1) { |
1284 | ci->yield(); | 1267 | enum codec_command_action action = ci->get_command(¶m); |
1285 | if (ci->stop_codec || ci->new_track) | 1268 | |
1269 | if (action == CODEC_ACTION_HALT) | ||
1286 | break; | 1270 | break; |
1287 | 1271 | ||
1288 | if (ci->seek_time) { | 1272 | if (action == CODEC_ACTION_SEEK_TIME) { |
1289 | /* New time is ready in ci->seek_time */ | 1273 | /* New time is ready in param */ |
1290 | modplayer.patterntableposition = ci->seek_time/1000; | 1274 | modplayer.patterntableposition = param/1000; |
1291 | modplayer.currentline = 0; | 1275 | modplayer.currentline = 0; |
1276 | ci->set_elapsed(modplayer.patterntableposition*1000+500); | ||
1292 | ci->seek_complete(); | 1277 | ci->seek_complete(); |
1293 | } | 1278 | } |
1294 | 1279 | ||
@@ -1305,9 +1290,5 @@ next_track: | |||
1305 | 1290 | ||
1306 | } | 1291 | } |
1307 | 1292 | ||
1308 | request_next_track: | ||
1309 | if (ci->request_next_track()) | ||
1310 | goto next_track; | ||
1311 | |||
1312 | return CODEC_OK; | 1293 | return CODEC_OK; |
1313 | } | 1294 | } |