From 0342e37f37e103f1c6d97bc75f992782818e8e7b Mon Sep 17 00:00:00 2001 From: Erik Hofman Date: Wed, 6 Jul 2016 13:26:23 +0200 Subject: [PATCH] Either install soundmgr_openal.hxx or soundmgr_aeonwave.hxx as soundmgr.hxx --- simgear/sound/CMakeLists.txt | 15 +++++---- simgear/sound/soundmgr_aeonwave.cxx | 48 +++++++++++++++-------------- 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/simgear/sound/CMakeLists.txt b/simgear/sound/CMakeLists.txt index 2f57ca4b..88825386 100644 --- a/simgear/sound/CMakeLists.txt +++ b/simgear/sound/CMakeLists.txt @@ -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 ) diff --git a/simgear/sound/soundmgr_aeonwave.cxx b/simgear/sound/soundmgr_aeonwave.cxx index 2bc863a2..c79fb32f 100644 --- a/simgear/sound/soundmgr_aeonwave.cxx +++ b/simgear/sound/soundmgr_aeonwave.cxx @@ -70,6 +70,16 @@ public: { } + ~SoundManagerPrivate() + { + std::vector::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 _devices; + std::vector _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 SGSoundMgr::get_available_devices() { - vector devices; #ifdef ENABLE_SOUND std::string on = " on "; std::string colon = ": "; @@ -656,13 +659,12 @@ vector 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; } -- 2.39.5