From: ehofman Date: Sat, 28 Nov 2009 10:37:02 +0000 (+0000) Subject: Make it possible to specify a different device name X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=d70a05a088aa22989f2b658a60250c145e18aee9;p=simgear.git Make it possible to specify a different device name --- diff --git a/simgear/sound/soundmgr_openal.cxx b/simgear/sound/soundmgr_openal.cxx index 918b05da..f7199458 100644 --- a/simgear/sound/soundmgr_openal.cxx +++ b/simgear/sound/soundmgr_openal.cxx @@ -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); diff --git a/simgear/sound/soundmgr_openal.hxx b/simgear/sound/soundmgr_openal.hxx index 30801665..f1f9bd17 100644 --- a/simgear/sound/soundmgr_openal.hxx +++ b/simgear/sound/soundmgr_openal.hxx @@ -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 _free_sources; vector _sources_in_use; - char *_devname; bool _bad_doppler; bool testForALError(string s);