summaryrefslogtreecommitdiff
path: root/apps/codecs/a52.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2011-04-27 03:08:23 +0000
committerMichael Sevakis <jethead71@rockbox.org>2011-04-27 03:08:23 +0000
commitc537d5958e8b421ac4f9bef6c8b9e7425a6cf167 (patch)
tree7ed36518fb6524da7bbd913ba7619b85b5d15d23 /apps/codecs/a52.c
parentdcf0f8de4a37ff1d2ea510aef75fa67977a8bdcc (diff)
downloadrockbox-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/a52.c')
-rw-r--r--apps/codecs/a52.c53
1 files changed, 27 insertions, 26 deletions
diff --git a/apps/codecs/a52.c b/apps/codecs/a52.c
index 00fdeea309..4cd293e37f 100644
--- a/apps/codecs/a52.c
+++ b/apps/codecs/a52.c
@@ -116,27 +116,31 @@ static void a52_decode_data(uint8_t *start, uint8_t *end)
116} 116}
117 117
118/* this is the codec entry point */ 118/* this is the codec entry point */
119enum codec_status codec_main(void) 119enum codec_status codec_main(enum codec_entry_call_reason reason)
120{
121 if (reason == CODEC_LOAD) {
122 /* Generic codec initialisation */
123 ci->configure(DSP_SET_STEREO_MODE, STEREO_NONINTERLEAVED);
124 ci->configure(DSP_SET_SAMPLE_DEPTH, 28);
125 }
126 else if (reason == CODEC_UNLOAD) {
127 if (state)
128 a52_free(state);
129 }
130
131 return CODEC_OK;
132}
133
134/* this is called for each file to process */
135enum codec_status codec_run(void)
120{ 136{
121 size_t n; 137 size_t n;
122 unsigned char *filebuf; 138 unsigned char *filebuf;
123 int sample_loc; 139 int sample_loc;
124 int retval; 140 intptr_t param;
125 141
126 /* Generic codec initialisation */ 142 if (codec_init())
127 ci->configure(DSP_SET_STEREO_MODE, STEREO_NONINTERLEAVED); 143 return CODEC_ERROR;
128 ci->configure(DSP_SET_SAMPLE_DEPTH, 28);
129
130next_track:
131 retval = CODEC_OK;
132
133 if (codec_init()) {
134 retval = CODEC_ERROR;
135 goto exit;
136 }
137
138 if (codec_wait_taginfo() != 0)
139 goto request_next_track;
140 144
141 ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency); 145 ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency);
142 codec_set_replaygain(ci->id3); 146 codec_set_replaygain(ci->id3);
@@ -153,15 +157,18 @@ next_track:
153 } 157 }
154 } 158 }
155 else { 159 else {
160 ci->seek_buffer(ci->id3->first_frame_offset);
156 samplesdone = 0; 161 samplesdone = 0;
157 } 162 }
158 163
159 while (1) { 164 while (1) {
160 if (ci->stop_codec || ci->new_track) 165 enum codec_command_action action = ci->get_command(&param);
166
167 if (action == CODEC_ACTION_HALT)
161 break; 168 break;
162 169
163 if (ci->seek_time) { 170 if (action == CODEC_ACTION_SEEK_TIME) {
164 sample_loc = (ci->seek_time - 1)/1000 * ci->id3->frequency; 171 sample_loc = param/1000 * ci->id3->frequency;
165 172
166 if (ci->seek_buffer((sample_loc/A52_SAMPLESPERFRAME)*ci->id3->bytesperframe)) { 173 if (ci->seek_buffer((sample_loc/A52_SAMPLESPERFRAME)*ci->id3->bytesperframe)) {
167 samplesdone = sample_loc; 174 samplesdone = sample_loc;
@@ -179,11 +186,5 @@ next_track:
179 ci->advance_buffer(n); 186 ci->advance_buffer(n);
180 } 187 }
181 188
182request_next_track: 189 return CODEC_OK;
183 if (ci->request_next_track())
184 goto next_track;
185
186exit:
187 a52_free(state);
188 return retval;
189} 190}