int AalibUnload(int channel) { if ((channel<1)||(channel>48)) { return PSPAALIB_ERROR_INVALID_CHANNEL; } channels[channel].initialized=FALSE; if ((PSPAALIB_CHANNEL_WAV_1<=channel)&&(channel<=PSPAALIB_CHANNEL_WAV_32)) { return UnloadWav(channel-PSPAALIB_CHANNEL_WAV_1); } if ((PSPAALIB_CHANNEL_OGG_1<=channel)&&(channel<=PSPAALIB_CHANNEL_OGG_10)) { return UnloadOgg(channel-PSPAALIB_CHANNEL_OGG_1); } if ((PSPAALIB_CHANNEL_SCEMP3_1<=channel)&&(channel<=PSPAALIB_CHANNEL_SCEMP3_2)) { return UnloadSceMp3(channel-PSPAALIB_CHANNEL_SCEMP3_1); } if ((PSPAALIB_CHANNEL_AT3_1<=channel)&&(channel<=PSPAALIB_CHANNEL_AT3_2)) { return UnloadAt3(channel-PSPAALIB_CHANNEL_AT3_1); } return PSPAALIB_ERROR_INVALID_CHANNEL; }
int LoadSceMp3(cccUCS2* filename,int channel) { if ((channel<0)||(channel>1)) { return PSPAALIB_ERROR_SCEMP3_INVALID_CHANNEL; } if (streamsSceMp3[channel].initialized) { UnloadSceMp3(channel); } char* c=(char*)malloc(4); c[3]='\0'; streamsSceMp3[channel].mp3Buf=memalign(64,16*1024); streamsSceMp3[channel].pcmBuf=memalign(64,8*1152); streamsSceMp3[channel].file=sceIoOpenUCS2(filename,PSP_O_RDONLY,0777); if (!streamsSceMp3[channel].file) { free(streamsSceMp3[channel].mp3Buf); free(streamsSceMp3[channel].pcmBuf); return PSPAALIB_ERROR_SCEMP3_INVALID_FILE; } streamsSceMp3[channel].args.mp3StreamStart=0; streamsSceMp3[channel].args.mp3StreamEnd=sceIoLseek(streamsSceMp3[channel].file,0,PSP_SEEK_END); streamsSceMp3[channel].args.unk1=0; streamsSceMp3[channel].args.unk2=0; streamsSceMp3[channel].args.mp3Buf=streamsSceMp3[channel].mp3Buf; streamsSceMp3[channel].args.mp3BufSize=16*1024; streamsSceMp3[channel].args.pcmBuf=streamsSceMp3[channel].pcmBuf; streamsSceMp3[channel].args.pcmBufSize=8*1152; sceIoLseek(streamsSceMp3[channel].file,-128,PSP_SEEK_END); sceIoRead(streamsSceMp3[channel].file,c,3); if(!strcmp(c,"TAG")) { streamsSceMp3[channel].args.mp3StreamEnd -= 128; } sceIoLseek(streamsSceMp3[channel].file,0,PSP_SEEK_SET); sceIoRead(streamsSceMp3[channel].file,c,3); if(!strcmp(c,"ID3")) { int tagSize; sceIoLseek(streamsSceMp3[channel].file,6,PSP_SEEK_SET); sceIoRead(streamsSceMp3[channel].file,&tagSize,4); ENDIAN_SWAP_32BIT(tagSize); ID3_TAG_LENGTH_TO_INT(tagSize); streamsSceMp3[channel].args.mp3StreamStart = tagSize + 10; } streamsSceMp3[channel].handle=sceMp3ReserveMp3Handle(&(streamsSceMp3[channel].args)); if (streamsSceMp3[channel].handle<0) { sceIoClose(streamsSceMp3[channel].file); free(streamsSceMp3[channel].mp3Buf); free(streamsSceMp3[channel].pcmBuf); return PSPAALIB_ERROR_SCEMP3_RESERVE_HANDLE; } FillBuffer(channel); if (sceMp3Init(streamsSceMp3[channel].handle)<0) { sceMp3ReleaseMp3Handle(streamsSceMp3[channel].handle); sceIoClose(streamsSceMp3[channel].file); free(streamsSceMp3[channel].mp3Buf); free(streamsSceMp3[channel].pcmBuf); return PSPAALIB_ERROR_SCEMP3_INIT; } streamsSceMp3[channel].initialized=TRUE; streamsSceMp3[channel].paused=TRUE; streamsSceMp3[channel].stopReason=PSPAALIB_STOP_JUST_LOADED; streamsSceMp3[channel].hz=sceMp3GetSamplingRate(streamsSceMp3[channel].handle); return PSPAALIB_SUCCESS; }