Media Engine Questions?

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Kreationz
Posts: 52
Joined: Sun May 18, 2008 11:01 am

Media Engine Questions?

Post by Kreationz »

OSLib uses the ME when you call oslInitAudioME, but it doesn't use the MediaEngine.prx Chilly Willy wrote. So, I decided to look at the source for OSLib and was able to call this function from a user mode Eboot without MediaEngine.prx or any other prx's just what OSLib adds in to the Eboot.

Code: Select all

#include <oslib/oslib.h>
//#include <psppower.h>

PSP_MODULE_INFO&#40;"OSLib Sample", 0, 1, 1&#41;;
PSP_MAIN_THREAD_ATTR&#40;THREAD_ATTR_USER | THREAD_ATTR_VFPU&#41;;


enum colors
&#123;
RED = RGBA&#40;255,0,0,255&#41;,
GREEN = RGBA&#40;0,255,0,255&#41;,
BLUE = RGBA&#40;0,0,255,255&#41;,
WHITE = RGBA&#40;255,255,255,255&#41;,
LITEGRAY = RGBA&#40;125,125,125,255&#41;,
GRAY =  RGBA&#40;150,150,150,255&#41;,
DARKGRAY = RGBA&#40;125,125,125,255&#41;,  
BLACK = RGBA&#40;0,0,0,255&#41;,
&#125;;


OSL_FONT *dopeness;
OSL_SOUND *mario;
OSL_IMAGE *buttondoc;

int main&#40;&#41;
&#123;


    oslInit&#40;0&#41;;
    oslInitGfx&#40;OSL_PF_8888, 1&#41;;
    oslInitConsole&#40;&#41;;
    oslInitAudioME&#40;2&#41;;
    oslIntraFontInit&#40;INTRAFONT_CACHE_ALL | INTRAFONT_STRING_UTF8&#41;;
    //scePowerSetClockFrequency&#40; 333, 333, 166 &#41;;

    dopeness = oslLoadIntraFontFile&#40;"font.pgf", INTRAFONT_CACHE_ALL&#41;;
    mario = oslLoadSoundFileMP3&#40; "mario.mp3", OSL_FMT_STREAM &#41;;
    buttondoc = oslLoadImageFile&#40; "buttondoc.jpg", OSL_IN_RAM, OSL_PF_8888 &#41;;

    if &#40; !dopeness &#41;
      &#123;
          oslDebug&#40;" Check if font.pgf is in your folder."&#41;;
      &#125;

        if &#40; !mario &#41;
      &#123;
          oslDebug&#40;" Check if mario.mp3 is in your folder."&#41;;
      &#125;
    
        if &#40; !buttondoc &#41;
      &#123;
          oslDebug&#40;" Check if buttondoc.jpg is in your folder."&#41;;
      &#125;

    
        
    oslPlaySound&#40;mario, 0&#41;;
    oslSetSoundLoop&#40;mario, 1&#41;;
    
    while &#40; !osl_quit&#41;
      &#123;

      
    oslReadKeys&#40;&#41;;
    oslStartDrawing&#40;&#41;; 
      
    oslClearScreen&#40;WHITE&#41;;
    oslDrawImage&#40;buttondoc&#41;;

    oslIntraFontSetStyle&#40;dopeness, 1.2f,RED,0,INTRAFONT_ALIGN_CENTER&#41;;
    oslSetFont&#40; dopeness &#41;;
    oslDrawStringf&#40;240, 132, "NintendoBoy13 -\n Press &#91;O&#93; to pause/play"&#41;;
      
    if &#40;osl_keys->pressed.circle&#41; oslPauseSound&#40;mario, -1&#41;;
    oslEndDrawing&#40;&#41;;
    oslSyncFrame&#40;&#41;;
    oslAudioVSync&#40;&#41;;
    
      &#125;
    oslIntraFontShutdown&#40;&#41;;
    oslEndGfx&#40;&#41;;
    oslQuit&#40;&#41;;
    return 0;
&#125;
The only files in the directory when I run this are the Eboot, MP3, jpg, and pgf and it runs fine. The even a bit more interesting part I think is I know it is using the ME, but I can still go into standby which I thought wasn't possible with the ME. When coming back from standby the sound is lost, so I believe the ME is either getting out of sync or getting turned off. This code is simple enough that I plan to do more testing possibly intercepting the standby telling things to pause on and then on re-power / un-standby telling the coe to re-init the Media Engine.

Now my only question is, has anyone else tried this and to what end?

I'm trying to solve the standby/CPU speed lock issues we currently have with the ME. This may at least provide us some clue.

Also is the Media Engine being called from OSLib via pspSdkLoadStartModule("flash0:/kd/me_for_vsh.prx", PSP_MEMORY_PARTITION_KERNEL);
Or a different prx? And if it is that one, why don't I see it in my flash0:/kd/ on my PSP?


Note: This wasn't my code I was looking at it for NintendoBoy13 a coder new to PSP development and just noticed this behavior and thought it warranted investigation.
sakya
Posts: 190
Joined: Fri Apr 28, 2006 5:48 pm
Contact:

Post by sakya »

Hi! :)

OSLib initializes the ME this way:

Code: Select all

void initME&#40;&#41;&#123;
    if &#40;sceKernelDevkitVersion&#40;&#41; == 0x01050001&#41;
    &#123;
        LoadStartAudioModule&#40;"flash0&#58;/kd/me_for_vsh.prx", PSP_MEMORY_PARTITION_KERNEL&#41;;
        LoadStartAudioModule&#40;"flash0&#58;/kd/audiocodec.prx", PSP_MEMORY_PARTITION_KERNEL&#41;;
    &#125;
    else
    &#123;
        sceUtilityLoadAvModule&#40;PSP_AV_MODULE_AVCODEC&#41;;
    &#125;
&#125;
Ciaooo
Sakya
psPea
Posts: 60
Joined: Sat Sep 01, 2007 12:51 pm

Post by psPea »

When you go into standby all file discriptors are lost, therefore the audio data cannot be read from the file to be decoded, this has nothing to do with the me. The only time you have to worry about going into standby is when you are running your own code on the me.

To resolve this you need to setup a power callback, save the file position when you're going into standby and reopen the file and seek to the offset when you come out of standby.
I tried this and it worked initially, but later on (for some unknown reason) there was no power callback message when coming out of standy.
Kreationz
Posts: 52
Joined: Sun May 18, 2008 11:01 am

Post by Kreationz »

So then I could set up my app which is running my own code to pause the code I'm running on intercepting a Standby Callback. Then on the next one resume it.
Post Reply