report errors opening sound files and hopefully revcover from them gracefully
This was SVN commit r12591.
This commit is contained in:
parent
453f4a8aa6
commit
a6e1e6cec7
@ -25,6 +25,7 @@
|
||||
#include "ps/CLogger.h"
|
||||
#include "ps/Filesystem.h"
|
||||
#include "soundmanager/SoundManager.h"
|
||||
#include "ps/CLogger.h"
|
||||
|
||||
COggData::COggData()
|
||||
{
|
||||
@ -45,34 +46,37 @@ void COggData::SetFormatAndFreq(int form, ALsizei freq)
|
||||
bool COggData::InitOggFile(const VfsPath& itemPath)
|
||||
{
|
||||
int buffersToStart = g_SoundManager->GetBufferCount();
|
||||
Status status = OpenOggNonstream(g_VFS, itemPath, ogg);
|
||||
ENSURE(status == INFO::OK);
|
||||
|
||||
m_FileFinished = false;
|
||||
|
||||
SetFormatAndFreq(ogg->Format(), ogg->SamplingRate() );
|
||||
|
||||
alGetError(); /* clear error */
|
||||
alGenBuffers(buffersToStart, m_Buffer);
|
||||
|
||||
if(alGetError() != AL_NO_ERROR)
|
||||
if ( OpenOggNonstream( g_VFS, itemPath, ogg) == INFO::OK )
|
||||
{
|
||||
LOGERROR(L"Error creating initial buffer for %ls", itemPath.string().c_str());
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_BuffersUsed = FetchDataIntoBuffer(buffersToStart, m_Buffer);
|
||||
if (m_FileFinished)
|
||||
m_FileFinished = false;
|
||||
|
||||
SetFormatAndFreq(ogg->Format(), ogg->SamplingRate() );
|
||||
|
||||
AL_CHECK
|
||||
|
||||
alGenBuffers(buffersToStart, m_Buffer);
|
||||
|
||||
if(alGetError() != AL_NO_ERROR)
|
||||
{
|
||||
m_OneShot = true;
|
||||
if (m_BuffersUsed < buffersToStart)
|
||||
{
|
||||
alDeleteBuffers(buffersToStart - m_BuffersUsed, &m_Buffer[m_BuffersUsed]);
|
||||
}
|
||||
LOGERROR( L"- Error creating initial buffer !!\n");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_BuffersUsed = FetchDataIntoBuffer(buffersToStart, m_Buffer);
|
||||
if (m_FileFinished)
|
||||
{
|
||||
m_OneShot = true;
|
||||
if (m_BuffersUsed < buffersToStart)
|
||||
{
|
||||
alDeleteBuffers(buffersToStart - m_BuffersUsed, &m_Buffer[m_BuffersUsed]);
|
||||
}
|
||||
}
|
||||
AL_CHECK
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
ALsizei COggData::GetBufferCount()
|
||||
|
@ -22,6 +22,7 @@
|
||||
#if CONFIG2_AUDIO
|
||||
|
||||
#include "OggData.h"
|
||||
#include "ps/CLogger.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
@ -96,8 +97,15 @@ CSoundData* CSoundData::SoundDataFromOgg(const VfsPath& itemPath)
|
||||
CSoundData* answer = NULL;
|
||||
COggData* oggAnswer = new COggData();
|
||||
|
||||
if (oggAnswer->InitOggFile(itemPath))
|
||||
if ( oggAnswer->InitOggFile(itemPath) )
|
||||
{
|
||||
answer = oggAnswer;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGERROR(L"could not initialize ogg data at %ls", itemPath.string().c_str());
|
||||
delete oggAnswer;
|
||||
}
|
||||
|
||||
return answer;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user