Skip to content
Snippets Groups Projects
Commit 334e8d2f authored by jpbl's avatar jpbl
Browse files

OpenAL compiling fixes

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