diff options
Diffstat (limited to 'apps/codecs/nsf.c')
-rw-r--r-- | apps/codecs/nsf.c | 82 |
1 files changed, 40 insertions, 42 deletions
diff --git a/apps/codecs/nsf.c b/apps/codecs/nsf.c index 2f37da81d2..72f6974214 100644 --- a/apps/codecs/nsf.c +++ b/apps/codecs/nsf.c | |||
@@ -4307,46 +4307,44 @@ static void set_codec_track(int t, int d) { | |||
4307 | nSilenceTrackMS=5000; | 4307 | nSilenceTrackMS=5000; |
4308 | SetFadeTime(track,track+fade, fNSFPlaybackSpeed,def); | 4308 | SetFadeTime(track,track+fade, fNSFPlaybackSpeed,def); |
4309 | } | 4309 | } |
4310 | ci->id3->elapsed=d*1000; /* d is track no to display */ | 4310 | ci->set_elapsed(d*1000); /* d is track no to display */ |
4311 | } | 4311 | } |
4312 | 4312 | ||
4313 | /** Operational info **/ | ||
4314 | static int track = 0; | ||
4315 | static char last_path[MAX_PATH]; | ||
4316 | static int dontresettrack = 0; | ||
4317 | |||
4313 | /* this is the codec entry point */ | 4318 | /* this is the codec entry point */ |
4314 | enum codec_status codec_main(void) | 4319 | enum codec_status codec_main(enum codec_entry_call_reason reason) |
4320 | { | ||
4321 | if (reason == CODEC_LOAD) { | ||
4322 | /* we only render 16 bits, 44.1KHz, Stereo */ | ||
4323 | ci->configure(DSP_SET_SAMPLE_DEPTH, 16); | ||
4324 | ci->configure(DSP_SET_FREQUENCY, 44100); | ||
4325 | ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO); | ||
4326 | |||
4327 | RebuildOutputTables(); | ||
4328 | } | ||
4329 | |||
4330 | return CODEC_OK; | ||
4331 | } | ||
4332 | |||
4333 | /* this is called for each file to process */ | ||
4334 | enum codec_status codec_run(void) | ||
4315 | { | 4335 | { |
4316 | int written; | 4336 | int written; |
4317 | uint8_t *buf; | 4337 | uint8_t *buf; |
4318 | size_t n; | 4338 | size_t n; |
4319 | int endofstream; /* end of stream flag */ | 4339 | int endofstream; /* end of stream flag */ |
4320 | int track; | 4340 | int usingplaylist = 0; |
4321 | int dontresettrack; | ||
4322 | char last_path[MAX_PATH]; | ||
4323 | int usingplaylist; | ||
4324 | |||
4325 | /* we only render 16 bits */ | ||
4326 | ci->configure(DSP_SET_SAMPLE_DEPTH, 16); | ||
4327 | |||
4328 | ci->configure(DSP_SET_FREQUENCY, 44100); | ||
4329 | ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO); | ||
4330 | |||
4331 | RebuildOutputTables(); | ||
4332 | |||
4333 | dontresettrack=0; | ||
4334 | last_path[0]='\0'; | ||
4335 | track=0; | ||
4336 | 4341 | ||
4337 | next_track: | ||
4338 | usingplaylist=0; | ||
4339 | DEBUGF("NSF: next_track\n"); | 4342 | DEBUGF("NSF: next_track\n"); |
4340 | if (codec_init()) { | 4343 | if (codec_init()) { |
4341 | return CODEC_ERROR; | 4344 | return CODEC_ERROR; |
4342 | } | 4345 | } |
4343 | DEBUGF("NSF: after init\n"); | 4346 | DEBUGF("NSF: after init\n"); |
4344 | 4347 | ||
4345 | |||
4346 | /* wait for track info to load */ | ||
4347 | if (codec_wait_taginfo() != 0) | ||
4348 | goto request_next_track; | ||
4349 | |||
4350 | codec_set_replaygain(ci->id3); | 4348 | codec_set_replaygain(ci->id3); |
4351 | 4349 | ||
4352 | /* Read the entire file */ | 4350 | /* Read the entire file */ |
@@ -4408,22 +4406,27 @@ init_nsf: | |||
4408 | reset_profile_timers(); | 4406 | reset_profile_timers(); |
4409 | 4407 | ||
4410 | while (!endofstream) { | 4408 | while (!endofstream) { |
4409 | intptr_t param; | ||
4410 | enum codec_command_action action = ci->get_command(¶m); | ||
4411 | 4411 | ||
4412 | ci->yield(); | 4412 | if (action == CODEC_ACTION_HALT) |
4413 | if (ci->stop_codec || ci->new_track) { | ||
4414 | break; | 4413 | break; |
4415 | } | ||
4416 | 4414 | ||
4417 | if (ci->seek_time >0) { | 4415 | if (action == CODEC_ACTION_SEEK_TIME) { |
4418 | track=ci->seek_time/1000; | 4416 | if (param > 0) { |
4419 | if (usingplaylist) { | 4417 | track=param/1000; |
4420 | if (track>=nPlaylistSize) break; | 4418 | if (usingplaylist) { |
4421 | } else { | 4419 | if (track>=nPlaylistSize) break; |
4422 | if (track>=nTrackCount) break; | 4420 | } else { |
4421 | if (track>=nTrackCount) break; | ||
4422 | } | ||
4423 | dontresettrack=1; | ||
4424 | ci->seek_complete(); | ||
4425 | goto init_nsf; | ||
4426 | } | ||
4427 | else { | ||
4428 | ci->seek_complete(); | ||
4423 | } | 4429 | } |
4424 | ci->seek_complete(); | ||
4425 | dontresettrack=1; | ||
4426 | goto init_nsf; | ||
4427 | } | 4430 | } |
4428 | 4431 | ||
4429 | ENTER_TIMER(total); | 4432 | ENTER_TIMER(total); |
@@ -4449,22 +4452,17 @@ init_nsf: | |||
4449 | 4452 | ||
4450 | print_timers(last_path,track); | 4453 | print_timers(last_path,track); |
4451 | 4454 | ||
4452 | request_next_track: | ||
4453 | if (ci->request_next_track()) { | ||
4454 | if (ci->global_settings->repeat_mode==REPEAT_ONE) { | 4455 | if (ci->global_settings->repeat_mode==REPEAT_ONE) { |
4455 | /* in repeat one mode just advance to the next track */ | 4456 | /* in repeat one mode just advance to the next track */ |
4456 | track++; | 4457 | track++; |
4457 | if (track>=nTrackCount) track=0; | 4458 | if (track>=nTrackCount) track=0; |
4458 | dontresettrack=1; | 4459 | dontresettrack=1; |
4459 | /* at this point we can't tell if another file has been selected */ | 4460 | /* at this point we can't tell if another file has been selected */ |
4460 | goto next_track; | ||
4461 | } else { | 4461 | } else { |
4462 | /* otherwise do a proper load of the next file */ | 4462 | /* otherwise do a proper load of the next file */ |
4463 | dontresettrack=0; | 4463 | dontresettrack=0; |
4464 | last_path[0]='\0'; | 4464 | last_path[0]='\0'; |
4465 | } | 4465 | } |
4466 | goto next_track; /* when we fall through here we'll reload the file */ | ||
4467 | } | ||
4468 | 4466 | ||
4469 | return CODEC_OK; | 4467 | return CODEC_OK; |
4470 | } | 4468 | } |