fixed mp3 buffer overlapping of GP2X sound buffer

git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@129 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
notaz 2007-05-12 15:06:44 +00:00
parent fb88e61431
commit 60b4b403b3

View file

@ -29,7 +29,7 @@ static _940_data_t *shared_data = 0;
_940_ctl_t *shared_ctl = 0; _940_ctl_t *shared_ctl = 0;
unsigned char *mp3_mem = 0; unsigned char *mp3_mem = 0;
#define MP3_SIZE_MAX (0x1000000 - 4*640*480) #define MP3_SIZE_MAX (0x400000 + 0x800000) // 12M
int crashed_940 = 0; int crashed_940 = 0;
@ -360,7 +360,7 @@ void sharedmem_init(void)
shared_data = (_940_data_t *) (shared_mem+0x100000); shared_data = (_940_data_t *) (shared_mem+0x100000);
/* this area must not get buffered on either side */ /* this area must not get buffered on either side */
shared_ctl = (_940_ctl_t *) (shared_mem+0x200000); shared_ctl = (_940_ctl_t *) (shared_mem+0x200000);
mp3_mem = (unsigned char *) mmap(0, MP3_SIZE_MAX, PROT_READ|PROT_WRITE, MAP_SHARED, memdev, 0x3000000); mp3_mem = (unsigned char *) mmap(0, MP3_SIZE_MAX, PROT_READ|PROT_WRITE, MAP_SHARED, memdev, 0x2400000);
if (mp3_mem == MAP_FAILED) if (mp3_mem == MAP_FAILED)
{ {
printf("mmap(mp3_mem) failed with %i\n", errno); printf("mmap(mp3_mem) failed with %i\n", errno);
@ -599,7 +599,6 @@ void mp3_start_play(FILE *f, int pos) // pos is 0-1023
if (loaded_mp3 != f) if (loaded_mp3 != f)
{ {
// printf("loading mp3... "); fflush(stdout);
if (PicoMessage != NULL) if (PicoMessage != NULL)
{ {
fseek(f, 0, SEEK_END); fseek(f, 0, SEEK_END);
@ -608,8 +607,7 @@ void mp3_start_play(FILE *f, int pos) // pos is 0-1023
} }
fseek(f, 0, SEEK_SET); fseek(f, 0, SEEK_SET);
fread(mp3_mem, 1, MP3_SIZE_MAX, f); fread(mp3_mem, 1, MP3_SIZE_MAX, f);
// if (feof(f)) printf("done.\n"); if (!feof(f)) printf("Warning: mp3 was too large, not all data loaded.\n");
// else printf("done. mp3 too large, not all data loaded.\n");
shared_ctl->mp3_len = ftell(f); shared_ctl->mp3_len = ftell(f);
loaded_mp3 = f; loaded_mp3 = f;