X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=psp%2Fmp3.c;h=19f6ec36d7973832b18bc02786e17ad1f35d3395;hb=7443ecd9586ff46c9ffbe8c2fdc719c722ff9b25;hp=456b72b95e6c3ae7c2054f37409498f248a91cb0;hpb=117f236a4df7e19866bef195fa38ca022ff4b529;p=libpicofe.git diff --git a/psp/mp3.c b/psp/mp3.c index 456b72b..19f6ec3 100644 --- a/psp/mp3.c +++ b/psp/mp3.c @@ -165,7 +165,8 @@ int mp3_init(void) mod = load_start_module("flash0:/kd/audiocodec.prx"); else mod = load_start_module("flash0:/kd/avcodec.prx"); if (mod < 0) { - ret = mod = load_start_module("flash0:/kd/audiocodec_260.prx"); // last chance.. + ret = mod; + mod = load_start_module("flash0:/kd/audiocodec_260.prx"); // last chance.. if (mod < 0) goto fail; } @@ -204,8 +205,9 @@ int mp3_init(void) goto fail2; } + /* use slightly higher prio then main */ thread_exit = 0; - thid = sceKernelCreateThread("mp3decode_thread", decode_thread, 30, 0x2000, 0, 0); /* use slightly higher prio then main */ + thid = sceKernelCreateThread("mp3decode_thread", decode_thread, 30, 0x2000, 0, NULL); if (thid < 0) { lprintf("failed to create decode thread: %08x\n", thid); ret = thid; @@ -371,6 +373,9 @@ void mp3_start_play(FILE *f, int pos) mp3_fname = fname; } + // clear decoder state + sceAudiocodecInit(mp3_codec_struct, 0x1002); + // seek.. mp3_src_pos = (int) (((float)pos / 1023.0f) * (float)mp3_src_size); sceIoLseek32(mp3_handle, mp3_src_pos, PSP_SEEK_SET); @@ -458,7 +463,7 @@ int mp3_get_offset(void) // 0-1023 unsigned int offs1024 = 0; int cdda_on; - cdda_on = (PicoMCD & 1) && (PicoOpt&0x800) && !(Pico_mcd->s68k_regs[0x36] & 1) && + cdda_on = (PicoAHW & PAHW_MCD) && (PicoOpt&0x800) && !(Pico_mcd->s68k_regs[0x36] & 1) && (Pico_mcd->scd.Status_CDC & 1) && mp3_handle >= 0; if (cdda_on) { @@ -471,3 +476,17 @@ int mp3_get_offset(void) // 0-1023 } +void mp3_reopen_file(void) +{ + if (mp3_fname == NULL) return; + lprintf("mp3_reopen_file(%s)\n", mp3_fname); + + // try closing, just in case + if (mp3_handle >= 0) sceIoClose(mp3_handle); + + mp3_handle = sceIoOpen(mp3_fname, PSP_O_RDONLY, 0777); + if (mp3_handle >= 0) + sceIoLseek32(mp3_handle, mp3_src_pos, PSP_SEEK_SET); + lprintf("mp3_reopen_file %s\n", mp3_handle >= 0 ? "ok" : "failed"); +} +