Make it possible to specify a different device name

This commit is contained in:
ehofman
2009-11-28 10:37:02 +00:00
committed by Tim Moore
parent 0f21c39e49
commit d70a05a088
2 changed files with 8 additions and 7 deletions

View File

@@ -69,7 +69,6 @@ SGSoundMgr::SGSoundMgr() :
_geod_pos(SGGeod::fromCart(SGVec3d::zeros())),
_velocity(SGVec3d::zeros()),
_orientation(SGQuatd::zeros()),
_devname(NULL),
_bad_doppler(false)
{
#if defined(ALUT_API_MAJOR_VERSION) && ALUT_API_MAJOR_VERSION >= 1
@@ -97,13 +96,16 @@ SGSoundMgr::~SGSoundMgr() {
}
// initialize the sound manager
void SGSoundMgr::init() {
void SGSoundMgr::init(const char *devname) {
SG_LOG( SG_GENERAL, SG_INFO, "Initializing OpenAL sound manager" );
ALCdevice *device = alcOpenDevice(_devname);
if ( testForError(device, "No default audio device available.") ) {
return;
ALCdevice *device = alcOpenDevice(devname);
if ( testForError(device, "Audio device not available, trying default") ) {
ALCdevice *device = alcOpenDevice(NULL);
if (testForError(device, "Default Audio device not available.") ) {
return;
}
}
ALCcontext *context = alcCreateContext(device, NULL);

View File

@@ -95,7 +95,7 @@ public:
SGSoundMgr();
~SGSoundMgr();
void init();
void init(const char *devname = NULL);
void bind();
void unbind();
void update(double dt);
@@ -311,7 +311,6 @@ private:
vector<ALuint> _free_sources;
vector<ALuint> _sources_in_use;
char *_devname;
bool _bad_doppler;
bool testForALError(string s);