#include <list>
#include <string>
-#include <AL/alc.h>
#include <SDL/SDL.h>
#include "fastevents.h"
{
public:
- Backend_() :
- mAlDevice(0),
- mAlContext(0)
+ Backend_()
{
#if defined(_WIN32) || defined(__WIN32__)
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0)
return; // fatal
}
- mAlDevice = alcOpenDevice(0);
- mAlContext = alcCreateContext(mAlDevice, 0);
- if (!mAlDevice || !mAlContext)
- {
- const char* error = alcGetString(mAlDevice,alcGetError(mAlDevice));
- gError.init(Error::OPENAL_INIT, error);
- return;
- }
- else
- {
- alcMakeContextCurrent(mAlContext);
- logInfo << "opened sound device `"
- << alcGetString(mAlDevice, ALC_DEFAULT_DEVICE_SPECIFIER)
- << "'" << std::endl;
- }
-
gError.init(Error::NONE);
}
~Backend_()
{
- alcMakeContextCurrent(0);
- alcDestroyContext(mAlContext);
- alcCloseDevice(mAlDevice);
-
FE_Quit();
SDL_Quit();
}
}
}
- static bool check(Error& error)
+ static const Error& getError()
{
- error = gError;
- return error.code() == Error::NONE;
+ return gError;
}
private:
- ALCdevice* mAlDevice;
- ALCcontext* mAlContext;
-
static Error gError;
static int gRetainCount;
static BackendP gInstance;
Backend_::release();
}
-bool Backend::check(Error& error)
+bool Backend::isInitialized()
+{
+ return getError().code() == Error::NONE;
+}
+
+const Error& Backend::getError()
{
- return Backend_::check(error);
+ return Backend_::getError();
}