]> git.mxchange.org Git - simgear.git/commitdiff
Make it possible to specify a different device name
authorehofman <ehofman>
Sat, 28 Nov 2009 10:37:02 +0000 (10:37 +0000)
committerTim Moore <timoore@redhat.com>
Sun, 29 Nov 2009 12:04:38 +0000 (13:04 +0100)
simgear/sound/soundmgr_openal.cxx
simgear/sound/soundmgr_openal.hxx

index 918b05da5a65f9f7d25ffa6d8749b760d4605e3f..f7199458fca48a2a430e5ecc1203570fd2aede77 100644 (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);
index 30801665ccdc0f2f38cc7134aad037e88cacd869..f1f9bd17a178d5feb8d518a030f40a7c0312e73d 100644 (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);