cso support
[libpicofe.git] / psp / mp3.c
index ce12788..db3e39d 100644 (file)
--- a/psp/mp3.c
+++ b/psp/mp3.c
@@ -9,6 +9,7 @@
 #include <pspkernel.h>
 #include <pspsdk.h>
 #include <pspaudiocodec.h>
+#include <kubridge.h>
 
 #include "../../Pico/PicoInt.h"
 #include "../../Pico/sound/mix.h"
@@ -132,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;
 }
 
@@ -153,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;
        }
 
@@ -192,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;