* Make it so that we do not crash trying to play an MP3 that failed
  to load.
This commit is contained in:
jean.chalard
2009-06-11 14:47:21 +00:00
parent c1565450e5
commit 3639ac291f
3 changed files with 281 additions and 283 deletions
+4 -4
View File
@@ -25,8 +25,8 @@ protected:
int m_volume; int m_volume;
int m_samplesPlayed; int m_samplesPlayed;
int m_inBufferSize, m_outBufferSize; int m_inBufferSize, m_outBufferSize;
char m_inBuffer[16*1024]; // ? char m_inBuffer[16*1024] __attribute__((aligned(64))); // ?
short m_outBuffer[16*(1152/2)]; //? short m_outBuffer[16*(1152/2)] __attribute__((aligned(64))); //?
int m_numChannels; int m_numChannels;
int m_samplingRate; int m_samplingRate;
bool m_loop; bool m_loop;
@@ -40,11 +40,11 @@ public:
int m_fileSize; int m_fileSize;
char m_fileName[256]; char m_fileName[256];
static JMP3* mInstance; static JMP3* mInstance;
JMP3(const std::string& filename, int inBufferSize= 16*1024, int outBufferSize =16*(1152/2)); JMP3();
~JMP3(); ~JMP3();
static void init(); static void init();
bool fillBuffers(); bool fillBuffers();
bool load(const std::string& filename, int inBufferSize, int outBufferSize); bool load(const std::string& filename, int inBufferSize = 16*1024, int outBufferSize = 16 * (1152/2));
bool unload(); bool unload();
bool update(); bool update();
bool play(); bool play();
+1 -8
View File
@@ -18,9 +18,8 @@ void JMP3::init() {
loadModules(); loadModules();
} }
JMP3::JMP3(const std::string& filename, int inBufferSize, int outBufferSize) : JMP3::JMP3() :
m_volume(PSP_AUDIO_VOLUME_MAX), m_samplesPlayed(0), m_paused(true) { m_volume(PSP_AUDIO_VOLUME_MAX), m_samplesPlayed(0), m_paused(true) {
load(filename, inBufferSize,outBufferSize);
} }
JMP3::~JMP3() { JMP3::~JMP3() {
@@ -112,12 +111,6 @@ bool JMP3::load(const std::string& filename, int inBufferSize, int outBufferSize
sceIoLseek32(m_fileHandle, 0, SEEK_SET); sceIoLseek32(m_fileHandle, 0, SEEK_SET);
m_fileSize = fileSize; m_fileSize = fileSize;
unsigned char* testbuffer = new unsigned char[7456];
sceIoRead(m_fileHandle, testbuffer, 7456);
delete testbuffer;
initArgs.unk1 = 0; initArgs.unk1 = 0;
initArgs.unk2 = 0; initArgs.unk2 = 0;
initArgs.mp3StreamStart = 0; initArgs.mp3StreamStart = 0;
+6 -1
View File
@@ -112,7 +112,12 @@ JMusic *JSoundSystem::LoadMusic(const char *fileName)
JMusic *music = new JMusic(); JMusic *music = new JMusic();
if (music) if (music)
{ {
music->mTrack = new JMP3(s); music->mTrack = new JMP3();
if (!music->mTrack->load(s))
{
free(music->mTrack);
music->mTrack = NULL;
}
} }
JMP3::mInstance = music->mTrack; JMP3::mInstance = music->mTrack;
return music; return music;