diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2011-04-27 03:08:23 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2011-04-27 03:08:23 +0000 |
commit | c537d5958e8b421ac4f9bef6c8b9e7425a6cf167 (patch) | |
tree | 7ed36518fb6524da7bbd913ba7619b85b5d15d23 /apps/codecs/asap.c | |
parent | dcf0f8de4a37ff1d2ea510aef75fa67977a8bdcc (diff) | |
download | rockbox-c537d5958e8b421ac4f9bef6c8b9e7425a6cf167.tar.gz rockbox-c537d5958e8b421ac4f9bef6c8b9e7425a6cf167.zip |
Commit FS#12069 - Playback rework - first stages. Gives as thorough as possible a treatment of codec management, track change and metadata logic as possible while maintaining fairly narrow focus and not rewriting everything all at once. Please see the rockbox-dev mail archive on 2011-04-25 (Playback engine rework) for a more thorough manifest of what was addressed. Plugins and codecs become incompatible.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29785 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/asap.c')
-rw-r--r-- | apps/codecs/asap.c | 32 |
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 | |||
29 | static byte samples[CHUNK_SIZE] IBSS_ATTR; /* The sample buffer */ | 29 | static byte samples[CHUNK_SIZE] IBSS_ATTR; /* The sample buffer */ |
30 | static ASAP_State asap; /* asap codec state */ | 30 | static ASAP_State asap; /* asap codec state */ |
31 | 31 | ||
32 | /* this is the codec entry point */ | 32 | /* this is called for each file to process */ |
33 | enum codec_status codec_main(void) | 33 | enum 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 | ||
41 | next_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(¶m); |
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 | |||
133 | request_next_track: | ||
134 | if (ci->request_next_track()) | ||
135 | goto next_track; | ||
136 | 130 | ||
137 | return CODEC_OK; | 131 | return CODEC_OK; |
138 | } | 132 | } |