summaryrefslogtreecommitdiff
path: root/apps/codecs/asap.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/asap.c')
-rw-r--r--apps/codecs/asap.c32
1 files changed, 13 insertions, 19 deletions
diff --git a/apps/codecs/asap.c b/apps/codecs/asap.c
index 9447c738d2..f12dc6a0c5 100644
--- a/apps/codecs/asap.c
+++ b/apps/codecs/asap.c
@@ -29,24 +29,21 @@ CODEC_HEADER
29static byte samples[CHUNK_SIZE] IBSS_ATTR; /* The sample buffer */ 29static byte samples[CHUNK_SIZE] IBSS_ATTR; /* The sample buffer */
30static ASAP_State asap; /* asap codec state */ 30static ASAP_State asap; /* asap codec state */
31 31
32/* this is the codec entry point */ 32/* this is called for each file to process */
33enum codec_status codec_main(void) 33enum codec_status codec_run(void)
34{ 34{
35 int n_bytes; 35 int n_bytes;
36 int song; 36 int song;
37 int duration; 37 int duration;
38 char* module; 38 char* module;
39 int bytesPerSample =2; 39 int bytesPerSample =2;
40 intptr_t param;
40 41
41next_track:
42 if (codec_init()) { 42 if (codec_init()) {
43 DEBUGF("codec init failed\n"); 43 DEBUGF("codec init failed\n");
44 return CODEC_ERROR; 44 return CODEC_ERROR;
45 } 45 }
46 46
47 if (codec_wait_taginfo() != 0)
48 goto request_next_track;
49
50 codec_set_replaygain(ci->id3); 47 codec_set_replaygain(ci->id3);
51 48
52 int bytes_done =0; 49 int bytes_done =0;
@@ -97,19 +94,20 @@ next_track:
97 94
98 /* The main decoder loop */ 95 /* The main decoder loop */
99 while (1) { 96 while (1) {
100 ci->yield(); 97 enum codec_command_action action = ci->get_command(&param);
101 if (ci->stop_codec || ci->new_track) 98
99 if (action == CODEC_ACTION_HALT)
102 break; 100 break;
103 101
104 if (ci->seek_time) { 102 if (action == CODEC_ACTION_SEEK_TIME) {
105 /* New time is ready in ci->seek_time */ 103 /* New time is ready in param */
106 104
107 /* seek to pos */ 105 /* seek to pos */
108 ASAP_Seek(&asap,ci->seek_time); 106 ASAP_Seek(&asap,param);
109 /* update elapsed */
110 ci->set_elapsed(ci->seek_time);
111 /* update bytes_done */ 107 /* update bytes_done */
112 bytes_done = ci->seek_time*44.1*2; 108 bytes_done = param*44.1*2;
109 /* update elapsed */
110 ci->set_elapsed((bytes_done / 2) / 44.1);
113 /* seek ready */ 111 /* seek ready */
114 ci->seek_complete(); 112 ci->seek_complete();
115 } 113 }
@@ -129,10 +127,6 @@ next_track:
129 if(n_bytes != sizeof(samples)) 127 if(n_bytes != sizeof(samples))
130 break; 128 break;
131 } 129 }
132
133request_next_track:
134 if (ci->request_next_track())
135 goto next_track;
136 130
137 return CODEC_OK; 131 return CODEC_OK;
138} 132}