다음 튜토리얼문서를 참고해서 작성했다.
http://www.psp-programming.com/tutorials/c/lesson06.htm
libmad - MPEG audio decoder 설치
svn 소스받기
svn checkout svn://svn.ps2dev.org/psp/trunk/libmad
설치하기
cd libmad
make
make install
이 프로그램에 필요한 mp3 player 헤더파일
Source code
코드보기
[CODE type="c"]#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) {
[tab]sceKernelExitGame();
[tab]return 0;
}
/* Callback thread */
int CallbackThread(SceSize args, void *argp) {
[tab]int cbid;
[tab]cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
[tab]sceKernelRegisterExitCallback(cbid);
[tab]sceKernelSleepThreadCB();
[tab]return 0;
}
/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void) {
[tab]int thid = 0;
[tab]thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
[tab]if(thid >= 0) {
[tab][tab]sceKernelStartThread(thid, 0, 0);
[tab]}
[tab]return thid;
}
// END OF TWILIGHT ZONE! <do doo do do>
int main(){
[tab]
[tab]//scePowerSetClockFrequency(333, 333, 166);
[tab]
[tab]pspDebugScreenInit();
[tab]SetupCallbacks();
[tab]
[tab]pspAudioInit();
[tab]SceCtrlData pad;
[tab]
[tab]int i;
[tab]
[tab]MP3_Init(1);
[tab]MP3_Load("test.mp3");
[tab]MP3_Play();
[tab]
[tab]while(1){
[tab][tab]sceCtrlReadBufferPositive(&pad, 1);
[tab][tab]if(pad.Buttons & PSP_CTRL_CROSS){
[tab][tab][tab]break;
[tab][tab]}
[tab][tab]else if(pad.Buttons & PSP_CTRL_CIRCLE){
[tab][tab][tab]MP3_Pause();
[tab][tab][tab]for(i=0;i<10;i++){
[tab][tab][tab][tab]sceDisplayWaitVblankStart();
[tab][tab][tab]}
[tab][tab]}
[tab][tab]
[tab][tab]if(MP3_EndOfStream()==1){
[tab][tab][tab]MP3_Stop();
[tab][tab]}
[tab]}
[tab]
[tab]MP3_Stop();
[tab]MP3_FreeTune();
[tab]
[tab]sceKernelSleepThread();
[tab]return 0;
}[/HTML][/CODE]
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
Trackback Address :: 이 글에는 트랙백을 보낼 수 없습니다