forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Media Engine Questions?

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Kreationz



Joined: 18 May 2008
Posts: 53

PostPosted: Tue Dec 22, 2009 6:32 pm    Post subject: Media Engine Questions? Reply with quote

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:
#include <oslib/oslib.h>
//#include <psppower.h>

PSP_MODULE_INFO("OSLib Sample", 0, 1, 1);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);


enum colors
{
RED = RGBA(255,0,0,255),
GREEN = RGBA(0,255,0,255),
BLUE = RGBA(0,0,255,255),
WHITE = RGBA(255,255,255,255),
LITEGRAY = RGBA(125,125,125,255),
GRAY =  RGBA(150,150,150,255),
DARKGRAY = RGBA(125,125,125,255), 
BLACK = RGBA(0,0,0,255),
};


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

int main()
{


    oslInit(0);
    oslInitGfx(OSL_PF_8888, 1);
    oslInitConsole();
    oslInitAudioME(2);
    oslIntraFontInit(INTRAFONT_CACHE_ALL | INTRAFONT_STRING_UTF8);
    //scePowerSetClockFrequency( 333, 333, 166 );

    dopeness = oslLoadIntraFontFile("font.pgf", INTRAFONT_CACHE_ALL);
    mario = oslLoadSoundFileMP3( "mario.mp3", OSL_FMT_STREAM );
    buttondoc = oslLoadImageFile( "buttondoc.jpg", OSL_IN_RAM, OSL_PF_8888 );

    if ( !dopeness )
      {
          oslDebug(" Check if font.pgf is in your folder.");
      }

        if ( !mario )
      {
          oslDebug(" Check if mario.mp3 is in your folder.");
      }
   
        if ( !buttondoc )
      {
          oslDebug(" Check if buttondoc.jpg is in your folder.");
      }

   
       
    oslPlaySound(mario, 0);
    oslSetSoundLoop(mario, 1);
   
    while ( !osl_quit)
      {

     
    oslReadKeys();
    oslStartDrawing();
     
    oslClearScreen(WHITE);
    oslDrawImage(buttondoc);

    oslIntraFontSetStyle(dopeness, 1.2f,RED,0,INTRAFONT_ALIGN_CENTER);
    oslSetFont( dopeness );
    oslDrawStringf(240, 132, "NintendoBoy13 -\n Press [O] to pause/play");
     
    if (osl_keys->pressed.circle) oslPauseSound(mario, -1);
    oslEndDrawing();
    oslSyncFrame();
    oslAudioVSync();
   
      }
    oslIntraFontShutdown();
    oslEndGfx();
    oslQuit();
    return 0;
}


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.
Back to top
View user's profile Send private message
sakya



Joined: 28 Apr 2006
Posts: 190

PostPosted: Tue Dec 22, 2009 9:10 pm    Post subject: Reply with quote

Hi! :)

OSLib initializes the ME this way:
Code:
void initME(){
    if (sceKernelDevkitVersion() == 0x01050001)
    {
        LoadStartAudioModule("flash0:/kd/me_for_vsh.prx", PSP_MEMORY_PARTITION_KERNEL);
        LoadStartAudioModule("flash0:/kd/audiocodec.prx", PSP_MEMORY_PARTITION_KERNEL);
    }
    else
    {
        sceUtilityLoadAvModule(PSP_AV_MODULE_AVCODEC);
    }
}


Ciaooo
Sakya
Back to top
View user's profile Send private message Visit poster's website
psPea



Joined: 01 Sep 2007
Posts: 64

PostPosted: Wed Dec 23, 2009 5:36 am    Post subject: Reply with quote

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.
_________________
Click ME!
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
Kreationz



Joined: 18 May 2008
Posts: 53

PostPosted: Wed Dec 23, 2009 10:36 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group