Simple Player doesn't work

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

Moderators: cheriff, TyRaNiD

Post Reply
nikocronaldo
Posts: 31
Joined: Sun Feb 24, 2008 7:19 am

Simple Player doesn't work

Post by nikocronaldo »

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

It gives me this errors:

Code: Select all


               
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: Select all

#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: Select all


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?
pspZorba
Posts: 156
Joined: Sat Sep 22, 2007 11:45 am
Location: NY

Post by pspZorba »

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: Select all

main.c:106: warning: comparison between pointer and integer  
I think it's in Audio_Play()

you have:

Code: Select all

   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: Select all

                   MediaType = "mp3";  
is MediaType an int or a char * ?

always in this function :

you said that this function returns an int

Code: Select all

 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 !
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

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

what you must do is use sprintf or strcpy
Image
Upgrade your PSP
User avatar
Jim
Posts: 476
Joined: Sat Jul 02, 2005 10:06 pm
Location: Sydney
Contact:

Post by Jim »

if(MediaType=="mp3")

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

You need strcmp.

Jim
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

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

char x = 'mp3 ';

...

if (x == 'mp3 ')
User avatar
jean
Posts: 489
Joined: Sat Jan 05, 2008 2:44 am

Post by jean »

There are some platforms...
Wow...really? Never seen one!! I guess this depends on compiler...
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

but not " " ;)
Image
Upgrade your PSP
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

jean wrote:
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.
Post Reply