-
-#ifdef __GP2X__
-
-#include "../gp2x/code940/940shared.h"
-
-extern _940_ctl_t *shared_ctl;
-extern unsigned char *mp3_mem;
-
-static int mp3_decode(void)
-{
- // tried copying this to cached mem, no improvement noticed
- int mp3_offs = shared_ctl->mp3_offs;
- unsigned char *readPtr = mp3_mem + mp3_offs;
- int bytesLeft = shared_ctl->mp3_len - mp3_offs;
- int offset; // frame offset from readPtr
- int err;
-
- if (bytesLeft <= 0) return 1; // EOF, nothing to do
-
- offset = MP3FindSyncWord(readPtr, bytesLeft);
- if (offset < 0) {
- shared_ctl->mp3_offs = shared_ctl->mp3_len;
- return 1; // EOF
- }
- readPtr += offset;
- bytesLeft -= offset;
-
- err = MP3Decode(mp3dec, &readPtr, &bytesLeft, mp3_out_buffer, 0);
- if (err) {
- if (err == ERR_MP3_INDATA_UNDERFLOW) {
- shared_ctl->mp3_offs = shared_ctl->mp3_len; // EOF
- return 1;
- } else if (err <= -6 && err >= -12) {
- // ERR_MP3_INVALID_FRAMEHEADER, ERR_MP3_INVALID_*
- // just try to skip the offending frame..
- readPtr++;
- }
- shared_ctl->mp3_errors++;
- shared_ctl->mp3_lasterr = err;
- }
- shared_ctl->mp3_offs = readPtr - mp3_mem;
- return 0;
-}
-
-void mp3_start_local(void)
-{
- mp3_buffer_offs = 0;
- mp3_decode();
-}
-
-#define mp3_update mp3_update_local
-
-#else
-
-static FILE *mp3_current_file = NULL;
-static int mp3_file_len = 0, mp3_file_pos = 0;
-static unsigned char mp3_input_buffer[2*1024];
-