다음 튜토리얼문서를 참고해서 작성했다.
svn 소스받기
이 프로그램에 필요한 mp3 player 헤더파일
Source code
Makefile
http://www.psp-programming.com/tutorials/c/lesson06.htmlibmad - MPEG audio decoder 설치
svn 소스받기
svn checkout svn://svn.ps2dev.org/psp/trunk/libmad
설치하기
cd libmad
make
make install
make
make install
이 프로그램에 필요한 mp3 player 헤더파일
Source code
코드보기
#include<pspkernel.h>
#include<pspctrl.h>
#include<pspdebug.h>
#include<pspaudio.h>
#include<pspaudiolib.h>
#include<psppower.h>
#include "mp3player.h"
PSP_MODULE_INFO("mp3 player",0,1,1);
#define printf pspDebugScreenPrintf
// TWILIGHT ZONE! <do doo do doo>
/* Exit callback */
int exit_callback(int arg1, int arg2, void *common) {
sceKernelExitGame();
return 0;
}
/* Callback thread */
int CallbackThread(SceSize args, void *argp) {
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void) {
int thid = 0;
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
if(thid >= 0) {
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
// END OF TWILIGHT ZONE! <do doo do do>
int main(){
//scePowerSetClockFrequency(333, 333, 166);
pspDebugScreenInit();
SetupCallbacks();
pspAudioInit();
SceCtrlData pad;
int i;
MP3_Init(1);
MP3_Load("test.mp3");
MP3_Play();
while(1){
sceCtrlReadBufferPositive(&pad, 1);
if(pad.Buttons & PSP_CTRL_CROSS){
break;
}
else if(pad.Buttons & PSP_CTRL_CIRCLE){
MP3_Pause();
for(i=0;i<10;i++){
sceDisplayWaitVblankStart();
}
}
if(MP3_EndOfStream()==1){
MP3_Stop();
}
}
MP3_Stop();
MP3_FreeTune();
sceKernelSleepThread();
return 0;
}
#include<pspctrl.h>
#include<pspdebug.h>
#include<pspaudio.h>
#include<pspaudiolib.h>
#include<psppower.h>
#include "mp3player.h"
PSP_MODULE_INFO("mp3 player",0,1,1);
#define printf pspDebugScreenPrintf
// TWILIGHT ZONE! <do doo do doo>
/* Exit callback */
int exit_callback(int arg1, int arg2, void *common) {
sceKernelExitGame();
return 0;
}
/* Callback thread */
int CallbackThread(SceSize args, void *argp) {
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void) {
int thid = 0;
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
if(thid >= 0) {
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
// END OF TWILIGHT ZONE! <do doo do do>
int main(){
//scePowerSetClockFrequency(333, 333, 166);
pspDebugScreenInit();
SetupCallbacks();
pspAudioInit();
SceCtrlData pad;
int i;
MP3_Init(1);
MP3_Load("test.mp3");
MP3_Play();
while(1){
sceCtrlReadBufferPositive(&pad, 1);
if(pad.Buttons & PSP_CTRL_CROSS){
break;
}
else if(pad.Buttons & PSP_CTRL_CIRCLE){
MP3_Pause();
for(i=0;i<10;i++){
sceDisplayWaitVblankStart();
}
}
if(MP3_EndOfStream()==1){
MP3_Stop();
}
}
MP3_Stop();
MP3_FreeTune();
sceKernelSleepThread();
return 0;
}
Makefile
TARGET = mp3
OBJS = mp3player.o main.o
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
LIBS = -lmad -lpspaudiolib -lpspaudio -lpsppower
LDFLAGS =
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = MP3 Player Example
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
OBJS = mp3player.o main.o
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
LIBS = -lmad -lpspaudiolib -lpspaudio -lpsppower
LDFLAGS =
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = MP3 Player Example
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
댓글