Commit 334e8d2f authored by jpbl's avatar jpbl

OpenAL compiling fixes

parent 9c3b8d29
if MAINTENER_CODE
maintener_directories = OpenAL
endif
SUBDIRS = gsm pacpp ${maintener_directories}
SUBDIRS = gsm pacpp OpenAL
noinst_LTLIBRARIES = libaudio.la
......
......@@ -39,6 +39,7 @@ namespace SFLAudio
* the load is successfull.
*/
virtual bool load() = 0;
virtual void unload() = 0;
/**
* This will create a context for the device.
......
if MAINTENER_CODE
noinst_PROGRAMS = example01 example02
noinst_LTLIBRARIES = libsflaudio.la
......@@ -26,5 +27,5 @@ LDADD = libsflaudio.la $(PORTAUDIO_LIBS) -lopenal ../pacpp/source/portaudiocpp/l
example01_SOURCES = example01.cpp
example02_SOURCES = example02.cpp
endif
......@@ -42,6 +42,10 @@ SFLAudio::NullDevice::load()
return true;
}
void
SFLAudio::NullDevice::unload()
{}
bool
SFLAudio::NullDevice::isNull()
{
......
......@@ -32,6 +32,7 @@ namespace SFLAudio
Context *createContext();
virtual bool load();
virtual void unload();
bool isNull();
};
}
......
......@@ -18,6 +18,7 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <iostream>
#include <AL/al.h>
#include <AL/alc.h>
......@@ -30,16 +31,34 @@ SFLAudio::OpenALDevice::OpenALDevice()
: mDevice(0)
{}
SFLAudio::OpenALDevice::~OpenALDevice()
{
unload();
}
void
SFLAudio::OpenALDevice::unload() {
if(mDevice) {
alcCloseDevice(mDevice);
mDevice = 0;
}
}
bool
SFLAudio::OpenALDevice::load() {
OpenALLayer::clearError();
mDevice = alcOpenDevice(0);
OpenALLayer::assertError();
ALenum error = alcGetError(mDevice);
if (error != AL_NO_ERROR) {
std::cerr << "OpenAL::alcOpenDevice: " << alGetString(error) << std::endl;
unload();
}
if(mDevice != 0) {
const ALCchar *device = alcGetString(mDevice, ALC_DEVICE_SPECIFIER);
setName(device);
}
return mDevice;
}
......
......@@ -31,6 +31,7 @@ namespace SFLAudio
public:
OpenALDevice();
virtual bool load();
virtual void unload();
virtual Context *createContext();
private:
......
......@@ -74,17 +74,4 @@ SFLAudio::OpenALLayer::openDevice(const std::string &)
return new NullDevice();
}
void
SFLAudio::OpenALLayer::assertError()
{
ALenum error;
if ((error = alGetError()) != AL_NO_ERROR) {
std::cerr << "OpenAL::alcOpenDevice: " << alGetString(error) << std::endl;
}
}
void
SFLAudio::OpenALLayer::clearError()
{
alGetError();
}
......@@ -33,9 +33,6 @@ namespace SFLAudio
virtual std::list< std::string > getDevicesNames();
virtual Device *openDevice();
virtual Device *openDevice(const std::string &name);
static void clearError();
static void assertError();
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment