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 

Simple Player doesn't work

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



Joined: 24 Feb 2008
Posts: 31

PostPosted: Tue Jul 08, 2008 7:41 am    Post subject: Simple Player doesn't work Reply with quote

I made a simple player, it plays MP3 and OGG, but it doesn't work.

It gives me this errors:


Code:


               
psp-gcc -I. -IC:/pspsdk/psp/sdk/include -O2 -G0 -Wall -D_PSP_FW_VERSION=400   -c
 -o main.o main.c
main.c: In function 'Audio_Play':
main.c:106: warning: comparison between pointer and integer
main.c:106: warning: comparison with string literal results in unspecified behav
ior
main.c:109: warning: comparison between pointer and integer
main.c:109: warning: comparison with string literal results in unspecified behav
ior
main.c:117: warning: assignment makes integer from pointer without a cast
main.c:124: warning: assignment makes integer from pointer without a cast
main.c: In function 'Audio_Pause':
main.c:132: warning: comparison between pointer and integer
main.c:132: warning: comparison with string literal results in unspecified behav
ior
main.c:135: warning: comparison between pointer and integer
main.c:135: warning: comparison with string literal results in unspecified behav
ior
main.c: In function 'Audio_Stop':
main.c:143: warning: comparison between pointer and integer
main.c:143: warning: comparison with string literal results in unspecified behav
ior
main.c:146: warning: comparison between pointer and integer
main.c:146: warning: comparison with string literal results in unspecified behav
ior
main.c:152: warning: assignment makes integer from pointer without a cast
main.c:153: warning: control reaches end of non-void function
main.c: In function 'Audio_Pause':
main.c:139: warning: control reaches end of non-void function
main.c: In function 'Audio_Play':
main.c:129: warning: control reaches end of non-void function
psp-gcc -I. -IC:/pspsdk/psp/sdk/include -O2 -G0 -Wall -D_PSP_FW_VERSION=400   -c
 -o graphics.o graphics.c
psp-gcc -I. -IC:/pspsdk/psp/sdk/include -O2 -G0 -Wall -D_PSP_FW_VERSION=400   -c
 -o framebuffer.o framebuffer.c
psp-gcc -I. -IC:/pspsdk/psp/sdk/include -O2 -G0 -Wall -D_PSP_FW_VERSION=400   -c
 -o mp3player.o mp3player.c
psp-gcc -I. -IC:/pspsdk/psp/sdk/include -O2 -G0 -Wall -D_PSP_FW_VERSION=400   -c
 -o oggplayer.o oggplayer.c
oggplayer.c: In function 'OGGCallback':
oggplayer.c:73: warning: format '%d' expects type 'int', but argument 2 has type
 'long unsigned int'
oggplayer.c: In function 'OGG_Load':
oggplayer.c:126: warning: unused variable 'size'
oggplayer.c: In function 'OGG_Init':
oggplayer.c:164: warning: passing argument 2 of 'pspAudioSetChannelCallback' fro
m incompatible pointer type
oggplayer.c: In function 'OGG_Play':
oggplayer.c:175: warning: assignment makes integer from pointer without a cast
oggplayer.c: In function 'OGG_Stop':
oggplayer.c:184: warning: assignment makes integer from pointer without a cast
oggplayer.c: In function 'OGG_Pause':
oggplayer.c:192: warning: assignment makes integer from pointer without a cast
oggplayer.c:197: warning: assignment makes integer from pointer without a cast
psp-gcc -I. -IC:/pspsdk/psp/sdk/include -O2 -G0 -Wall -D_PSP_FW_VERSION=400  -L.
 -LC:/pspsdk/psp/sdk/lib -specs=C:/pspsdk/psp/sdk/lib/prxspecs -Wl,-q,-TC:/pspsd
k/psp/sdk/lib/linkfile.prx   main.o graphics.o framebuffer.o mp3player.o oggplay
er.o C:/pspsdk/psp/sdk/lib/prxexports.o -laac -lFLAC -lmad -lvorbisidec -lpspgu
-lpng -ljpeg -lz -lm -lmad -lpspaudiolib -lpspaudio -lpsphprm -lpspusb -lpspusbs
tor -lpspaudio -lpspaudiocodec -lpspkubridge -lpspsdk -lpspctrl -lpspumd -lpsprt
c -lpsppower -lpspgu -lpspaudiolib -lpspaudio -lm -lpspdebug -lpspdisplay -lpspg
e -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver
 -lpsputility -lpspuser -lpspkernel -o FileBrowser.elf
psp-fixup-imports FileBrowser.elf
psp-prxgen FileBrowser.elf FileBrowser.prx
mksfo 'File Browser' PARAM.SFO
pack-pbp EBOOT.PBP PARAM.SFO NULL  \
        NULL NULL NULL  \
        NULL  FileBrowser.prx NULL
[0]        408 bytes | PARAM.SFO
[1]          0 bytes | NULL
[2]          0 bytes | NULL
[3]          0 bytes | NULL
[4]          0 bytes | NULL
[5]          0 bytes | NULL
[6]     665838 bytes | FileBrowser.prx
[7]          0 bytes | NULL

                                     







main:

Code:
#define VERS    1
#define REVS    0
#define MODE_REPEAT 1

extern char *RequestFile(char *);

PSP_MODULE_INFO("File browser", 0, VERS, REVS);
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
PSP_HEAP_SIZE_MAX();



int exit_callback(int arg1, int arg2, void *common) {
   sceKernelExitGame();
   return 0;
}

int CallbackThread(SceSize args, void *argp) {
   int cbid;
   cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
   sceKernelRegisterExitCallback(cbid);
   sceKernelSleepThreadCB();
   return 0;
}

int SetupCallbacks(void) {
   int thid = 0;
   thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
   if(thid >= 0) {
      sceKernelStartThread(thid, 0, 0);
   }
   return thid;
}



int Audio_Play(char *filename){

    char* suffix = strrchr(filename, '.');
   
    if(MediaType=="mp3"){
         MP3_End();
         }
    else if(MediaType=="ogg"){
         OGG_End();
         }
   
      
     if (stricmp(suffix, ".mp3") == 0) {
                         MP3_Init(1);
                         MP3_Load(filename);
                         MediaType = "mp3";
                         MP3_Play();
                         }
                         
     else if (stricmp(suffix, ".ogg") == 0) {
                         OGG_Init(1);
                         OGG_Load(filename);
                         MediaType = "ogg";
                         OGG_Play();
                         }
     //Doesnt work :(

}
int Audio_Pause(){
   
    if(MediaType=="mp3"){
         MP3_Pause();
         }
    else if(MediaType=="ogg"){
         OGG_Pause();
         }

}

int Audio_Stop(){
   
    if(MediaType=="mp3"){
         MP3_End();
         }
    else if(MediaType=="ogg"){
         OGG_End();
         }

         
    MediaType=0;
    MediaStatus = "stop";
}



int main()
{
   pspDebugScreenInit();
   SetupCallbacks();
   initGraphics();
   pspAudioInit();
   char fileToPlay[257] = "";
Audio_Play(fileToPlay);
   char * testDirectory = dirBrowse("ms0:");

   
   for(;;)
   {
      fillScreenRect(WHITE, 0, 0, 480, 272);
      centerText(480/2, 272/2, testDirectory, 50, 0);   // Show the path that 'testDirectory' was supposed to recieve from dirBrowse();
      flipScreen();
      sceDisplayWaitVblankStart();
   }
   pspAudioEnd();
   
   sceKernelSleepThread();
   return 0;
}


Makefile:

Code:


TARGET = FileBrowser
OBJS = main.o graphics.o framebuffer.o mp3player.o oggplayer.o

CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

LIBS = -laac  -lmad -lvorbisidec -lpspgu -lpng -ljpeg -lz -lm -lpspaudiolib -lpspaudio -lpsphprm -lpspusb -lpspusbstor -lpspaudio -lpspaudiocodec -lpspkubridge \
     -lpspsdk -lpspctrl -lpsppower

PSP_FW_VERSION = 400
BUILD_PRX = 1
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = File Browser

PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak



The file is compiled but give black screen on my PSP, any idea?
Code:
Back to top
View user's profile Send private message
pspZorba



Joined: 22 Sep 2007
Posts: 156
Location: NY

PostPosted: Tue Jul 08, 2008 10:40 am    Post subject: Reply with quote

you have several warnings that tells you have some problems, at the end of your compilation you should NOT have any errors NOR warnings.

eg. :
Code:

main.c:106: warning: comparison between pointer and integer 


I think it's in Audio_Play()

you have:
Code:
   if(MediaType=="mp3") 


you are comparing MediaType (which I didn't find any definition ? did you give all the code ?) and "mp3".

whatever the type of MediaType you can't compare strings using == you have to use strcmp (or stricmp or strncmp etc etc )

so (MediaType=="mp3") will always be false.



later you wrote :
Code:
                   MediaType = "mp3"; 


is MediaType an int or a char * ?

always in this function :

you said that this function returns an int

Code:
 int Audio_Play(char *filename)


but it returns nothing ...



so you will have to:

1) correct all the warnings. => if there is one you don't understand we can help you.

2) give all the code, otherwise we won't be able to help you.
_________________
--pspZorba--
NO to K1.5 !
Back to top
View user's profile Send private message
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Tue Jul 08, 2008 9:57 pm    Post subject: Reply with quote

I believe MediaType is a char but only pointers can be "assigned" like:
MediaType = "lalala";

what you must do is use sprintf or strcpy
_________________

Upgrade your PSP
Back to top
View user's profile Send private message
Jim



Joined: 02 Jul 2005
Posts: 487
Location: Sydney

PostPosted: Wed Jul 09, 2008 9:25 pm    Post subject: Reply with quote

if(MediaType=="mp3")

you can't do this, it's not C#.

You need strcmp.

Jim
_________________
http://www.dbfinteractive.com
Back to top
View user's profile Send private message Visit poster's website
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Thu Jul 10, 2008 4:32 am    Post subject: Reply with quote

There are some platforms that use four byte characters, so you can do this:

char x = 'mp3 ';

...

if (x == 'mp3 ')
Back to top
View user's profile Send private message AIM Address
jean



Joined: 05 Jan 2008
Posts: 489

PostPosted: Thu Jul 10, 2008 7:25 pm    Post subject: Reply with quote

Quote:
There are some platforms...

Wow...really? Never seen one!! I guess this depends on compiler...
Back to top
View user's profile Send private message
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Thu Jul 10, 2008 8:47 pm    Post subject: Reply with quote

but not " " ;)
_________________

Upgrade your PSP
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Fri Jul 11, 2008 2:38 am    Post subject: Reply with quote

jean wrote:
Quote:
There are some platforms...

Wow...really? Never seen one!! I guess this depends on compiler...


CodeWarrior for the PPC Mac was that way. I used four-byte chars on it all the time. This was before OSX.
Back to top
View user's profile Send private message AIM Address
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