- bugfix so that openal 1.13 works properly with megaglest
- added some code so we can show error messages when no menu item is active
This commit is contained in:
parent
6b63089612
commit
2bab37fdc0
|
@ -423,10 +423,16 @@ public:
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
//abort();
|
||||||
|
|
||||||
if(program && gameInitialized == true) {
|
if(program && gameInitialized == true) {
|
||||||
//printf("\nprogram->getState() [%p]\n",program->getState());
|
//printf("\nprogram->getState() [%p]\n",program->getState());
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
if(program->getState() != NULL) {
|
if(program->getState() != NULL) {
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
program->showMessage(errMsg.c_str());
|
program->showMessage(errMsg.c_str());
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
for(;program->isMessageShowing();) {
|
for(;program->isMessageShowing();) {
|
||||||
//program->getState()->render();
|
//program->getState()->render();
|
||||||
Window::handleEvent();
|
Window::handleEvent();
|
||||||
|
@ -434,13 +440,16 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
program->showMessage(errMsg.c_str());
|
program->showMessage(errMsg.c_str());
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
for(;program->isMessageShowing();) {
|
for(;program->isMessageShowing();) {
|
||||||
//program->renderProgramMsgBox();
|
//program->renderProgramMsgBox();
|
||||||
Window::handleEvent();
|
Window::handleEvent();
|
||||||
program->loop();
|
program->loop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
|
@ -47,6 +47,25 @@ const int SOUND_THREAD_UPDATE_MILLISECONDS = 25;
|
||||||
// class Program::CrashProgramState
|
// class Program::CrashProgramState
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
||||||
|
void ProgramState::render() {
|
||||||
|
Renderer &renderer= Renderer::getInstance();
|
||||||
|
renderer.clearBuffers();
|
||||||
|
renderer.reset2d();
|
||||||
|
renderer.renderMessageBox(program->getMsgBox());
|
||||||
|
renderer.renderMouse2d(mouseX, mouseY, mouse2dAnim);
|
||||||
|
renderer.swapBuffers();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProgramState::update() {
|
||||||
|
mouse2dAnim = (mouse2dAnim +1) % Renderer::maxMouse2dAnim;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProgramState::mouseMove(int x, int y, const MouseState *mouseState) {
|
||||||
|
mouseX = x;
|
||||||
|
mouseY = y;
|
||||||
|
program->getMsgBox()->mouseMove(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
Program::ShowMessageProgramState::ShowMessageProgramState(Program *program, const char *msg) :
|
Program::ShowMessageProgramState::ShowMessageProgramState(Program *program, const char *msg) :
|
||||||
ProgramState(program) {
|
ProgramState(program) {
|
||||||
userWantsExit = false;
|
userWantsExit = false;
|
||||||
|
@ -256,6 +275,7 @@ void Program::loopWorker() {
|
||||||
}
|
}
|
||||||
ProgramState *prevState = this->programState;
|
ProgramState *prevState = this->programState;
|
||||||
|
|
||||||
|
assert(programState != NULL);
|
||||||
programState->render();
|
programState->render();
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d programState->render took msecs: %lld ==============> MAIN LOOP RENDERING\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d programState->render took msecs: %lld ==============> MAIN LOOP RENDERING\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
|
@ -284,9 +304,10 @@ void Program::loopWorker() {
|
||||||
|
|
||||||
if(prevState == this->programState) {
|
if(prevState == this->programState) {
|
||||||
if(soundThreadManager == NULL || soundThreadManager->isThreadExecutionLagging()) {
|
if(soundThreadManager == NULL || soundThreadManager->isThreadExecutionLagging()) {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] ERROR / WARNING soundThreadManager->isThreadExecutionLagging is TRUE\n",__FILE__,__FUNCTION__,__LINE__);
|
if(soundThreadManager != NULL) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s %d] ERROR / WARNING soundThreadManager->isThreadExecutionLagging is TRUE\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] ERROR / WARNING soundThreadManager->isThreadExecutionLagging is TRUE\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s %d] ERROR / WARNING soundThreadManager->isThreadExecutionLagging is TRUE\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
}
|
||||||
SoundRenderer::getInstance().update();
|
SoundRenderer::getInstance().update();
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chronoUpdateLoop.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] SoundRenderer::getInstance().update() took msecs: %lld, updateCount = %d\n",__FILE__,__FUNCTION__,__LINE__,chronoUpdateLoop.getMillis(),updateCount);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chronoUpdateLoop.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] SoundRenderer::getInstance().update() took msecs: %lld, updateCount = %d\n",__FILE__,__FUNCTION__,__LINE__,chronoUpdateLoop.getMillis(),updateCount);
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chronoUpdateLoop.getMillis() > 0) chronoUpdateLoop.start();
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chronoUpdateLoop.getMillis() > 0) chronoUpdateLoop.start();
|
||||||
|
@ -398,6 +419,7 @@ void Program::setState(ProgramState *programState, bool cleanupOldState)
|
||||||
updateCameraTimer.init(GameConstants::cameraFps, maxTimes);
|
updateCameraTimer.init(GameConstants::cameraFps, maxTimes);
|
||||||
|
|
||||||
this->programState= programState;
|
this->programState= programState;
|
||||||
|
assert(programState != NULL);
|
||||||
programState->load();
|
programState->load();
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
|
@ -47,6 +47,10 @@ class ProgramState{
|
||||||
protected:
|
protected:
|
||||||
Program *program;
|
Program *program;
|
||||||
|
|
||||||
|
int mouseX;
|
||||||
|
int mouseY;
|
||||||
|
int mouse2dAnim;
|
||||||
|
|
||||||
int startX;
|
int startX;
|
||||||
int startY;
|
int startY;
|
||||||
bool forceMouseRender;
|
bool forceMouseRender;
|
||||||
|
@ -55,11 +59,16 @@ public:
|
||||||
ProgramState(Program *program) {
|
ProgramState(Program *program) {
|
||||||
this->program= program;
|
this->program= program;
|
||||||
this->forceMouseRender = false;
|
this->forceMouseRender = false;
|
||||||
|
this->mouseX = 0;
|
||||||
|
this->mouseY = 0;
|
||||||
|
this->mouse2dAnim = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
virtual ~ProgramState(){};
|
virtual ~ProgramState(){};
|
||||||
|
|
||||||
virtual void render()=0;
|
//virtual void render()=0;
|
||||||
virtual void update(){};
|
virtual void render();
|
||||||
|
virtual void update();
|
||||||
virtual void updateCamera(){};
|
virtual void updateCamera(){};
|
||||||
virtual void tick(){};
|
virtual void tick(){};
|
||||||
virtual void init(){};
|
virtual void init(){};
|
||||||
|
@ -75,7 +84,7 @@ public:
|
||||||
virtual void mouseDoubleClickRight(int x, int y){}
|
virtual void mouseDoubleClickRight(int x, int y){}
|
||||||
virtual void mouseDoubleClickCenter(int x, int y){}
|
virtual void mouseDoubleClickCenter(int x, int y){}
|
||||||
virtual void eventMouseWheel(int x, int y, int zDelta){}
|
virtual void eventMouseWheel(int x, int y, int zDelta){}
|
||||||
virtual void mouseMove(int x, int y, const MouseState *mouseState) {};
|
virtual void mouseMove(int x, int y, const MouseState *mouseState);
|
||||||
virtual void keyDown(char key){};
|
virtual void keyDown(char key){};
|
||||||
virtual void keyUp(char key){};
|
virtual void keyUp(char key){};
|
||||||
virtual void keyPress(char c){};
|
virtual void keyPress(char c){};
|
||||||
|
@ -137,6 +146,7 @@ public:
|
||||||
|
|
||||||
static Program *getInstance() {return singleton;}
|
static Program *getInstance() {return singleton;}
|
||||||
|
|
||||||
|
GraphicMessageBox * getMsgBox() { return &msgBox; }
|
||||||
void initNormal(WindowGl *window);
|
void initNormal(WindowGl *window);
|
||||||
void initServer(WindowGl *window,bool autostart=false,bool openNetworkSlots=false);
|
void initServer(WindowGl *window,bool autostart=false,bool openNetworkSlots=false);
|
||||||
void initClient(WindowGl *window, const Ip &serverIp);
|
void initClient(WindowGl *window, const Ip &serverIp);
|
||||||
|
|
|
@ -112,8 +112,8 @@ private:
|
||||||
|
|
||||||
StaticSoundSource* findStaticSoundSource();
|
StaticSoundSource* findStaticSoundSource();
|
||||||
StreamSoundSource* findStreamSoundSource();
|
StreamSoundSource* findStreamSoundSource();
|
||||||
void checkAlcError(const char* message);
|
void checkAlcError(string message);
|
||||||
static void checkAlError(const char* message);
|
static void checkAlError(string message);
|
||||||
|
|
||||||
ALCdevice* device;
|
ALCdevice* device;
|
||||||
ALCcontext* context;
|
ALCcontext* context;
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#include "platform_util.h"
|
#include "platform_util.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "conversion.h"
|
||||||
#include "leak_dumper.h"
|
#include "leak_dumper.h"
|
||||||
|
|
||||||
namespace Shared{ namespace Sound{ namespace OpenAL{
|
namespace Shared{ namespace Sound{ namespace OpenAL{
|
||||||
|
@ -38,40 +39,66 @@ SoundSource::~SoundSource()
|
||||||
|
|
||||||
bool SoundSource::playing()
|
bool SoundSource::playing()
|
||||||
{
|
{
|
||||||
ALint state = AL_PLAYING;
|
ALint state = AL_STOPPED;
|
||||||
alGetSourcei(source, AL_SOURCE_STATE, &state);
|
alGetSourcei(source, AL_SOURCE_STATE, &state);
|
||||||
return state != AL_STOPPED;
|
return(state == AL_PLAYING || state == AL_PAUSED);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundSource::unQueueBuffers() {
|
void SoundSource::unQueueBuffers() {
|
||||||
int processed;
|
SoundPlayerOpenAL::checkAlError("Problem unqueuing buffers START OF METHOD: ");
|
||||||
alGetSourcei(source, AL_BUFFERS_PROCESSED, &processed);
|
|
||||||
SoundPlayerOpenAL::checkAlError("Problem unqueuing buffers (alGetSourcei AL_BUFFERS_PROCESSED) in audio source: ");
|
|
||||||
|
|
||||||
int queued;
|
ALint queued=0;
|
||||||
alGetSourcei(source, AL_BUFFERS_QUEUED, &queued);
|
alGetSourcei(source, AL_BUFFERS_QUEUED, &queued);
|
||||||
SoundPlayerOpenAL::checkAlError("Problem unqueuing buffers (alGetSourcei AL_BUFFERS_QUEUED) in audio source: ");
|
SoundPlayerOpenAL::checkAlError(string(__FILE__) + string(" ") + string(__FUNCTION__) + string(" ") + intToStr(__LINE__));
|
||||||
|
|
||||||
|
ALint processed=0;
|
||||||
|
alGetSourcei(source, AL_BUFFERS_PROCESSED, &processed);
|
||||||
|
SoundPlayerOpenAL::checkAlError(string(__FILE__) + string(" ") + string(__FUNCTION__) + string(" ") + intToStr(__LINE__));
|
||||||
|
|
||||||
|
while(processed--) {
|
||||||
|
ALuint buffer=0;
|
||||||
|
alSourceUnqueueBuffers(source, 1, &buffer);
|
||||||
|
SoundPlayerOpenAL::checkAlError(string(__FILE__) + string(" ") + string(__FUNCTION__) + string(" ") + intToStr(__LINE__));
|
||||||
|
}
|
||||||
|
|
||||||
|
// ALint queued=0;
|
||||||
|
// alGetSourcei(source, AL_BUFFERS_QUEUED, &queued);
|
||||||
|
// while(queued--) {
|
||||||
|
// ALuint buffer=0;
|
||||||
|
// alSourceUnqueueBuffers(source, 1, &buffer);
|
||||||
|
// SoundPlayerOpenAL::checkAlError("Problem unqueuing buffers (alSourceUnqueueBuffers) in audio source: ");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// SoundPlayerOpenAL::checkAlError("Problem unqueuing buffers (alGetSourcei AL_BUFFERS_QUEUED) in audio source: ");
|
||||||
|
|
||||||
//if(processed < queued) {
|
|
||||||
while(queued--) {
|
|
||||||
ALuint buffer;
|
|
||||||
alSourceUnqueueBuffers(source, 1, &buffer);
|
|
||||||
SoundPlayerOpenAL::checkAlError("Problem unqueuing buffers (alSourceUnqueueBuffers) in audio source: ");
|
|
||||||
}
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundSource::stop()
|
void SoundSource::stop() {
|
||||||
{
|
|
||||||
alSourceStop(source);
|
alSourceStop(source);
|
||||||
|
SoundPlayerOpenAL::checkAlError(string(__FILE__) + string(" ") + string(__FUNCTION__) + string(" ") + intToStr(__LINE__));
|
||||||
SoundPlayerOpenAL::checkAlError("Problem stopping audio source (alSourceStop): ");
|
|
||||||
|
|
||||||
unQueueBuffers();
|
unQueueBuffers();
|
||||||
|
|
||||||
alSourcei(source, AL_BUFFER, AL_NONE);
|
alSourcei(source, AL_BUFFER, AL_NONE);
|
||||||
|
SoundPlayerOpenAL::checkAlError(string(__FILE__) + string(" ") + string(__FUNCTION__) + string(" ") + intToStr(__LINE__));
|
||||||
|
|
||||||
SoundPlayerOpenAL::checkAlError("Problem stopping audio source: ");
|
//unQueueBuffers();
|
||||||
|
|
||||||
|
alSourceRewind(source); // stops the source
|
||||||
|
SoundPlayerOpenAL::checkAlError(string(__FILE__) + string(" ") + string(__FUNCTION__) + string(" ") + intToStr(__LINE__));
|
||||||
|
|
||||||
|
while(playing() == true) {
|
||||||
|
//alSourceStop(source);
|
||||||
|
//SoundPlayerOpenAL::checkAlError(string(__FILE__) + string(" ") + string(__FUNCTION__) + string(" ") + intToStr(__LINE__));
|
||||||
|
ALint state = AL_STOPPED;
|
||||||
|
alGetSourcei(source, AL_SOURCE_STATE, &state);
|
||||||
|
SoundPlayerOpenAL::checkAlError(string(__FILE__) + string(" ") + string(__FUNCTION__) + string(" ") + intToStr(__LINE__));
|
||||||
|
|
||||||
|
sleep(1);
|
||||||
|
printf("$$$ WAITING FOR OPENAL TO STOP state = %d!\n",state);
|
||||||
|
}
|
||||||
|
//unQueueBuffers();
|
||||||
|
//SoundPlayerOpenAL::checkAlError(string(__FILE__) + string(" ") + string(__FUNCTION__) + string(" ") + intToStr(__LINE__));
|
||||||
}
|
}
|
||||||
|
|
||||||
ALenum SoundSource::getFormat(Sound* sound)
|
ALenum SoundSource::getFormat(Sound* sound)
|
||||||
|
@ -134,20 +161,22 @@ void StaticSoundSource::play(StaticSound* sound) {
|
||||||
static_cast<ALsizei> (sound->getInfo()->getSize()),
|
static_cast<ALsizei> (sound->getInfo()->getSize()),
|
||||||
static_cast<ALsizei> (sound->getInfo()->getSamplesPerSecond()));
|
static_cast<ALsizei> (sound->getInfo()->getSamplesPerSecond()));
|
||||||
|
|
||||||
SoundPlayerOpenAL::checkAlError("Couldn't fill audio buffer: ");
|
SoundPlayerOpenAL::checkAlError(string(__FILE__) + string(" ") + string(__FUNCTION__) + string(" ") + intToStr(__LINE__));
|
||||||
|
|
||||||
alSourcei(source, AL_BUFFER, buffer);
|
alSourcei(source, AL_BUFFER, buffer);
|
||||||
|
SoundPlayerOpenAL::checkAlError(string(__FILE__) + string(" ") + string(__FUNCTION__) + string(" ") + intToStr(__LINE__));
|
||||||
alSourcef(source, AL_GAIN, sound->getVolume());
|
alSourcef(source, AL_GAIN, sound->getVolume());
|
||||||
|
SoundPlayerOpenAL::checkAlError(string(__FILE__) + string(" ") + string(__FUNCTION__) + string(" ") + intToStr(__LINE__));
|
||||||
|
|
||||||
alSourcePlay(source);
|
alSourcePlay(source);
|
||||||
SoundPlayerOpenAL::checkAlError("Couldn't start audio source: ");
|
SoundPlayerOpenAL::checkAlError(string(__FILE__) + string(" ") + string(__FUNCTION__) + string(" ") + intToStr(__LINE__));
|
||||||
}
|
}
|
||||||
|
|
||||||
StreamSoundSource::StreamSoundSource()
|
StreamSoundSource::StreamSoundSource()
|
||||||
{
|
{
|
||||||
sound = 0;
|
sound = 0;
|
||||||
alGenBuffers(STREAMFRAGMENTS, buffers);
|
alGenBuffers(STREAMFRAGMENTS, buffers);
|
||||||
SoundPlayerOpenAL::checkAlError("Couldn't allocate audio buffers: ");
|
SoundPlayerOpenAL::checkAlError(string(__FILE__) + string(" ") + string(__FUNCTION__) + string(" ") + intToStr(__LINE__));
|
||||||
}
|
}
|
||||||
|
|
||||||
StreamSoundSource::~StreamSoundSource()
|
StreamSoundSource::~StreamSoundSource()
|
||||||
|
@ -186,14 +215,18 @@ void StreamSoundSource::play(StrSound* sound, int64 fadeon)
|
||||||
}
|
}
|
||||||
if(fadeon > 0) {
|
if(fadeon > 0) {
|
||||||
alSourcef(source, AL_GAIN, 0);
|
alSourcef(source, AL_GAIN, 0);
|
||||||
|
SoundPlayerOpenAL::checkAlError(string(__FILE__) + string(" ") + string(__FUNCTION__) + string(" ") + intToStr(__LINE__));
|
||||||
|
|
||||||
fadeState = FadingOn;
|
fadeState = FadingOn;
|
||||||
fade = fadeon;
|
fade = fadeon;
|
||||||
chrono.start();
|
chrono.start();
|
||||||
} else {
|
} else {
|
||||||
fadeState = NoFading;
|
fadeState = NoFading;
|
||||||
alSourcef(source, AL_GAIN, sound->getVolume());
|
alSourcef(source, AL_GAIN, sound->getVolume());
|
||||||
|
SoundPlayerOpenAL::checkAlError(string(__FILE__) + string(" ") + string(__FUNCTION__) + string(" ") + intToStr(__LINE__));
|
||||||
}
|
}
|
||||||
alSourcePlay(source);
|
alSourcePlay(source);
|
||||||
|
SoundPlayerOpenAL::checkAlError(string(__FILE__) + string(" ") + string(__FUNCTION__) + string(" ") + intToStr(__LINE__));
|
||||||
}
|
}
|
||||||
|
|
||||||
void StreamSoundSource::update()
|
void StreamSoundSource::update()
|
||||||
|
@ -204,16 +237,18 @@ void StreamSoundSource::update()
|
||||||
|
|
||||||
if(fadeState == NoFading){
|
if(fadeState == NoFading){
|
||||||
alSourcef(source, AL_GAIN, sound->getVolume());
|
alSourcef(source, AL_GAIN, sound->getVolume());
|
||||||
|
SoundPlayerOpenAL::checkAlError(string(__FILE__) + string(" ") + string(__FUNCTION__) + string(" ") + intToStr(__LINE__));
|
||||||
}
|
}
|
||||||
|
|
||||||
ALint processed = 0;
|
ALint processed = 0;
|
||||||
alGetSourcei(source, AL_BUFFERS_PROCESSED, &processed);
|
alGetSourcei(source, AL_BUFFERS_PROCESSED, &processed);
|
||||||
|
SoundPlayerOpenAL::checkAlError(string(__FILE__) + string(" ") + string(__FUNCTION__) + string(" ") + intToStr(__LINE__));
|
||||||
while(processed > 0) {
|
while(processed > 0) {
|
||||||
processed--;
|
processed--;
|
||||||
|
|
||||||
ALuint buffer;
|
ALuint buffer;
|
||||||
alSourceUnqueueBuffers(source, 1, &buffer);
|
alSourceUnqueueBuffers(source, 1, &buffer);
|
||||||
SoundPlayerOpenAL::checkAlError("Couldn't unqueue audio buffer: ");
|
SoundPlayerOpenAL::checkAlError(string(__FILE__) + string(" ") + string(__FUNCTION__) + string(" ") + intToStr(__LINE__));
|
||||||
|
|
||||||
if(!fillBufferAndQueue(buffer))
|
if(!fillBufferAndQueue(buffer))
|
||||||
break;
|
break;
|
||||||
|
@ -225,7 +260,7 @@ void StreamSoundSource::update()
|
||||||
|
|
||||||
std::cerr << "Restarting audio source because of buffer underrun.\n";
|
std::cerr << "Restarting audio source because of buffer underrun.\n";
|
||||||
alSourcePlay(source);
|
alSourcePlay(source);
|
||||||
SoundPlayerOpenAL::checkAlError("Couldn't restart audio source: ");
|
SoundPlayerOpenAL::checkAlError(string(__FILE__) + string(" ") + string(__FUNCTION__) + string(" ") + intToStr(__LINE__));
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle fading
|
// handle fading
|
||||||
|
@ -233,10 +268,13 @@ void StreamSoundSource::update()
|
||||||
case FadingOn:
|
case FadingOn:
|
||||||
if(chrono.getMillis() > fade) {
|
if(chrono.getMillis() > fade) {
|
||||||
alSourcef(source, AL_GAIN, sound->getVolume());
|
alSourcef(source, AL_GAIN, sound->getVolume());
|
||||||
|
SoundPlayerOpenAL::checkAlError(string(__FILE__) + string(" ") + string(__FUNCTION__) + string(" ") + intToStr(__LINE__));
|
||||||
|
|
||||||
fadeState = NoFading;
|
fadeState = NoFading;
|
||||||
} else {
|
} else {
|
||||||
alSourcef(source, AL_GAIN, sound->getVolume() *
|
alSourcef(source, AL_GAIN, sound->getVolume() *
|
||||||
static_cast<float> (chrono.getMillis())/fade);
|
static_cast<float> (chrono.getMillis())/fade);
|
||||||
|
SoundPlayerOpenAL::checkAlError(string(__FILE__) + string(" ") + string(__FUNCTION__) + string(" ") + intToStr(__LINE__));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case FadingOff:
|
case FadingOff:
|
||||||
|
@ -245,6 +283,7 @@ void StreamSoundSource::update()
|
||||||
} else {
|
} else {
|
||||||
alSourcef(source, AL_GAIN, sound->getVolume() *
|
alSourcef(source, AL_GAIN, sound->getVolume() *
|
||||||
(1.0f - static_cast<float>(chrono.getMillis())/fade));
|
(1.0f - static_cast<float>(chrono.getMillis())/fade));
|
||||||
|
SoundPlayerOpenAL::checkAlError(string(__FILE__) + string(" ") + string(__FUNCTION__) + string(" ") + intToStr(__LINE__));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -387,6 +426,7 @@ void SoundPlayerOpenAL::end() {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSound).enabled) SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSound).enabled) SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
alcMakeContextCurrent( NULL );
|
alcMakeContextCurrent( NULL );
|
||||||
|
SoundPlayerOpenAL::checkAlcError(string(__FILE__) + string(" ") + string(__FUNCTION__) + string(" ") + intToStr(__LINE__));
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSound).enabled) SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSound).enabled) SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
@ -558,20 +598,22 @@ StreamSoundSource* SoundPlayerOpenAL::findStreamSoundSource() {
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundPlayerOpenAL::checkAlcError(const char* message) {
|
void SoundPlayerOpenAL::checkAlcError(string message) {
|
||||||
int err = alcGetError(device);
|
int err = alcGetError(device);
|
||||||
if(err != ALC_NO_ERROR) {
|
if(err != ALC_NO_ERROR) {
|
||||||
std::stringstream msg;
|
std::stringstream msg;
|
||||||
msg << message << alcGetString(device, err);
|
msg << message.c_str() << alcGetString(device, err);
|
||||||
|
printf("openalc error [%s]\n",message.c_str());
|
||||||
throw std::runtime_error(msg.str());
|
throw std::runtime_error(msg.str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundPlayerOpenAL::checkAlError(const char* message) {
|
void SoundPlayerOpenAL::checkAlError(string message) {
|
||||||
int err = alGetError();
|
int err = alGetError();
|
||||||
if(err != AL_NO_ERROR) {
|
if(err != AL_NO_ERROR) {
|
||||||
std::stringstream msg;
|
std::stringstream msg;
|
||||||
msg << message << alGetString(err);
|
msg << message.c_str() << alGetString(err);
|
||||||
|
printf("openal error [%s]\n",message.c_str());
|
||||||
throw std::runtime_error(msg.str());
|
throw std::runtime_error(msg.str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue