]> git.mxchange.org Git - simgear.git/commitdiff
Either install soundmgr_openal.hxx or soundmgr_aeonwave.hxx as soundmgr.hxx
authorErik Hofman <erik@ehofman.com>
Wed, 6 Jul 2016 11:26:23 +0000 (13:26 +0200)
committerRoland Haeder <roland@mxchange.org>
Sat, 13 Aug 2016 08:21:16 +0000 (10:21 +0200)
simgear/sound/CMakeLists.txt
simgear/sound/soundmgr_aeonwave.cxx

index 2f57ca4beefb8ba99bc3f52f5e6e54f028b881e2..88825386a17f82e317ff90566021820fe3dee492 100644 (file)
@@ -3,31 +3,30 @@ include (SimGearComponent)
 set(HEADERS 
     sample.hxx
     sample_group.hxx
-    soundmgr_aeonwave.hxx
     xmlsound.hxx
     readwav.hxx
+    ${CMAKE_CURRENT_BINARY_DIR}/soundmgr.hxx
     )
     
 set(SOURCES 
     sample.cxx
     sample_group.cxx
-    soundmgr_aeonwave.cxx
     xmlsound.cxx
     readwav.cxx
     soundmgr_openal_private.hxx
     )
 
 if (USE_AEONWAVE)
-    set(HEADERS ${HEADERS}
-        soundmgr_aeonwave.hxx
-        )
+    CONFIGURE_FILE(
+        "soundmgr_aeonwave.hxx"
+        "soundmgr.hxx")
     set(SOURCES ${SOURCES}
         soundmgr_aeonwave.cxx
         )
 else()
-    set(HEADERS ${HEADERS}
-        soundmgr_openal.hxx
-        )
+    CONFIGURE_FILE(
+        "soundmgr_openal.hxx"
+        "soundmgr.hxx")
     set(SOURCES ${SOURCES}
         soundmgr_openal.cxx
         )
index 2bc863a2e92b425efd991c34f1ff69a5aaeb2eb9..c79fb32fad06b349d33d8e8b6ddc4d2230ad54d0 100644 (file)
@@ -70,6 +70,16 @@ public:
     {
     }
 
+    ~SoundManagerPrivate()
+    {
+        std::vector<const char*>::iterator it;
+        for (it = _devices.begin(); it != _devices.end(); ++it) {
+            free((void*)*it);
+        }
+        _devices.clear();
+        _sample_groups.clear();
+    }
+
     void init() {
         _mtx64 = AAX::Matrix64();
     }
@@ -109,7 +119,7 @@ public:
 
     sample_group_map _sample_groups;
 
-    std::vector<std::string> _devices;
+    std::vector<const char*> _devices;
 };
 
 
@@ -135,7 +145,6 @@ SGSoundMgr::~SGSoundMgr() {
 
     if (is_working())
         stop();
-    d->_sample_groups.clear();
 }
 
 // initialize the sound manager
@@ -153,29 +162,24 @@ void SGSoundMgr::init()
     d->_source_id = 0;
     d->_sources.clear();
 
-    AAX::AeonWave aax;
     AAX::DSP dsp;
-
-    const char* devname = _device_name.c_str();
-    if (_device_name == "")
-        devname = NULL; // use default device
-    else
-    {
+    if (!_device_name.empty()) {
         // try non-default device
-        aax = AAX::AeonWave(devname);
+        d->_aax = AAX::AeonWave(_device_name.c_str());
     }
-
-    if ((!devname)||(testForError(aax, "Audio device not available, trying default.")) ) {
-        aax = AAX::AeonWave(AAX_MODE_WRITE_STEREO);
-        if (testForError(aax, "Default audio device not available.") ) {
+    else
+    {
+        testForError(d->_aax, "Audio device not available, trying default.");
+        d->_aax = AAX::AeonWave(AAX_MODE_WRITE_STEREO);
+        if (testForError(d->_aax, "Default audio device not available.") ) {
            return;
         }
     }
 
-    d->_aax = aax;
     d->init();
 
     d->_aax.set(AAX_INITIALIZED);
+    testForError("initialization");
 
     dsp = AAX::DSP(d->_aax, AAX_VOLUME_FILTER);
     dsp.set(AAX_GAIN, 0.0f);
@@ -190,10 +194,10 @@ void SGSoundMgr::init()
     dsp.set(AAX_SOUND_VELOCITY, 340.3f);
     d->_aax.set(dsp);
 
-    testForError("listener initialization");
+    testForError("scenery setup");
 
-    _vendor = d->_aax.info(AAX_VENDOR_STRING);
-    _renderer = d->_aax.info(AAX_RENDERER_STRING);
+    _vendor = (const char *)d->_aax.info(AAX_VENDOR_STRING);
+    _renderer = (const char *)d->_aax.info(AAX_RENDERER_STRING);
 #endif
 }
 
@@ -644,7 +648,6 @@ void SGSoundMgr::update_sample_config( SGSoundSample *sample, SGVec3d& position,
 
 vector<const char*> SGSoundMgr::get_available_devices()
 {
-    vector<const char*> devices;
 #ifdef ENABLE_SOUND
     std::string on = " on ";
     std::string colon = ": ";
@@ -656,13 +659,12 @@ vector<const char*> SGSoundMgr::get_available_devices()
                 else if (r) name += on + r;
                 else if (i) name += colon + i;
 
-                d->_devices.push_back(name);
-                devices.push_back(name.c_str());
+                d->_devices.push_back( strdup(name.c_str()) );
             }
         }
     }
 #endif
-    return devices;
+    return d->_devices;
 }
 
 
@@ -681,7 +683,7 @@ bool SGSoundMgr::testForError(std::string s, std::string name)
 #ifdef ENABLE_SOUND
     enum aaxErrorType error = d->_aax.error_no();
     if (error != AAX_ERROR_NONE) {
-       SG_LOG( SG_SOUND, SG_ALERT, "AL Error (" << name << "): "
+       SG_LOG( SG_SOUND, SG_ALERT, "AeonWave Error (" << name << "): "
                                       << d->_aax.error(error) << " at " << s);
        return true;
     }