X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=psp%2Fmp3.c;h=43b449d720312a502e8b37a5ebf94aee33bac46e;hb=8a091e48251d061ad06ffd12dfe205cbb42c78df;hp=5991063a54c466267b121d235f6d1726dcc956fc;hpb=fe9e3b2544bdc6ba0fef167a949db4f90511f5ea;p=libpicofe.git diff --git a/psp/mp3.c b/psp/mp3.c index 5991063..43b449d 100644 --- a/psp/mp3.c +++ b/psp/mp3.c @@ -1,9 +1,15 @@ +// (c) Copyright 2007 notaz, All rights reserved. +// Free for non-commercial use. + +// For commercial use, separate licencing terms must be obtained. + #include #include #include #include #include +#include #include "../../Pico/PicoInt.h" #include "../../Pico/sound/mix.h" @@ -127,9 +133,20 @@ static int read_next_frame(int which_buffer) static SceUID load_start_module(const char *prxname) { - SceUID mod = pspSdkLoadStartModule(prxname, PSP_MEMORY_PARTITION_KERNEL); - if (mod < 0) - lprintf("failed to load %s: %08x\n", prxname, mod); + SceUID mod, mod1; + int status, ret; + + mod = pspSdkLoadStartModule(prxname, PSP_MEMORY_PARTITION_KERNEL); + if (mod < 0) { + lprintf("failed to load %s (%08x), trying kuKernelLoadModule\n", prxname, mod); + mod1 = kuKernelLoadModule(prxname, 0, NULL); + if (mod1 < 0) lprintf("kuKernelLoadModule failed with %08x\n", mod1); + else { + ret = sceKernelStartModule(mod1, 0, NULL, &status, 0); + if (ret < 0) lprintf("sceKernelStartModule failed with %08x\n", ret); + else mod = mod1; + } + } return mod; } @@ -148,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; } @@ -187,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; @@ -441,7 +460,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) { @@ -454,3 +473,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"); +} +