Some logging and more detailed error reporting
This was SVN commit r864.
This commit is contained in:
parent
ce742e37c2
commit
aff7bd83e6
@ -1,6 +1,8 @@
|
|||||||
#include "precompiled.h"
|
#include "precompiled.h"
|
||||||
|
|
||||||
#include "CMusicPlayer.h"
|
#include "CMusicPlayer.h"
|
||||||
|
#include <CLogger.h>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
# ifndef NDEBUG
|
# ifndef NDEBUG
|
||||||
@ -97,8 +99,8 @@ long VorbisTell(void *datasource)
|
|||||||
CMusicPlayer::CMusicPlayer(void)
|
CMusicPlayer::CMusicPlayer(void)
|
||||||
{
|
{
|
||||||
info = NULL;
|
info = NULL;
|
||||||
source = NULL;
|
source = 0;
|
||||||
format = NULL;
|
format = 0;
|
||||||
|
|
||||||
buffers[0] = buffers[1] = 0;
|
buffers[0] = buffers[1] = 0;
|
||||||
}
|
}
|
||||||
@ -111,7 +113,7 @@ CMusicPlayer::~CMusicPlayer(void)
|
|||||||
void CMusicPlayer::open(char *filename)
|
void CMusicPlayer::open(char *filename)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
format = NULL;
|
format = 0;
|
||||||
info = NULL;
|
info = NULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -146,7 +148,12 @@ void CMusicPlayer::open(char *filename)
|
|||||||
void* p;
|
void* p;
|
||||||
size_t sizeOfFile;
|
size_t sizeOfFile;
|
||||||
if(vfs_load(filename, p, sizeOfFile) <= 0)
|
if(vfs_load(filename, p, sizeOfFile) <= 0)
|
||||||
|
{
|
||||||
|
LOG(ERROR, "CMusicPlayer::open(): vfs_load for %s failed!\n", filename);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
LOG(NORMAL, "CMusicPlayer::open(): file %s loaded successfully\n", filename);
|
||||||
// TODO maybe: Free the mem handle returned by vfs_load (using mem_free_h) ??
|
// TODO maybe: Free the mem handle returned by vfs_load (using mem_free_h) ??
|
||||||
|
|
||||||
memFile.dataPtr = (char*)p;
|
memFile.dataPtr = (char*)p;
|
||||||
@ -267,7 +274,7 @@ bool CMusicPlayer::isPlaying()
|
|||||||
if(!is_open)
|
if(!is_open)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ALenum state = NULL;
|
ALenum state = 0;
|
||||||
alGetSourcei(source,AL_SOURCE_STATE,&state);
|
alGetSourcei(source,AL_SOURCE_STATE,&state);
|
||||||
check();
|
check();
|
||||||
//printf("returning from isPlaying.\n");
|
//printf("returning from isPlaying.\n");
|
||||||
@ -353,7 +360,7 @@ bool CMusicPlayer::stream(ALuint buffer)
|
|||||||
// error
|
// error
|
||||||
else if(ret < 0)
|
else if(ret < 0)
|
||||||
{
|
{
|
||||||
printf("Error reading from ogg file\n");
|
printf("Error reading from ogg file: %s\n", errorString(ret).c_str());
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
// EOF
|
// EOF
|
||||||
@ -388,6 +395,8 @@ std::string CMusicPlayer::errorString(int errorcode)
|
|||||||
return std::string("Invalid Vorbis header.");
|
return std::string("Invalid Vorbis header.");
|
||||||
case OV_EFAULT:
|
case OV_EFAULT:
|
||||||
return std::string("Internal logic fault (bug or heap/stack corruption.");
|
return std::string("Internal logic fault (bug or heap/stack corruption.");
|
||||||
|
case OV_EINVAL:
|
||||||
|
return std::string("Invalid argument passed to Vorbis function");
|
||||||
case AL_INVALID_NAME:
|
case AL_INVALID_NAME:
|
||||||
return "AL_INVALID_NAME";
|
return "AL_INVALID_NAME";
|
||||||
case AL_INVALID_ENUM:
|
case AL_INVALID_ENUM:
|
||||||
@ -399,6 +408,8 @@ std::string CMusicPlayer::errorString(int errorcode)
|
|||||||
case AL_OUT_OF_MEMORY:
|
case AL_OUT_OF_MEMORY:
|
||||||
return "AL_OUT_OF_MEMORY";
|
return "AL_OUT_OF_MEMORY";
|
||||||
default:
|
default:
|
||||||
return std::string("Unknown Ogg error.");
|
std::stringstream str;
|
||||||
|
str << "Unknown Ogg error (code "<< errorcode << ")";
|
||||||
|
return str.str();
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user