diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b21730c..6f95a39b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -126,7 +126,7 @@ option(ENABLE_RTI "Set to ON to build SimGear with RTI support" OFF) option(ENABLE_GDAL "Set to ON to build SimGear with GDAL support" OFF) option(ENABLE_TESTS "Set to OFF to disable building SimGear's test applications" ON) option(ENABLE_SOUND "Set to OFF to disable building SimGear's sound support" ON) -option(USE_AEONWAVE "Set to ON to use AeonWave instead of OpenAL" OFF) +option(USE_AEONWAVE "Set to ON to use AeonWave instead of OpenAL" ON) option(ENABLE_PKGUTIL "Set to ON to build the sg_pkgutil application (default)" ON) option(ENABLE_DNS "Set to ON to use udns library and DNS service resolver" ON) option(ENABLE_SIMD "Enable SSE/SSE2 support for x86 compilers" ON) @@ -222,12 +222,18 @@ else() if (ENABLE_SOUND) if (USE_AEONWAVE) - find_package(AAX COMPONENTS aax REQUIRED) - else() + find_package(AAX) + endif() + + if(NOT AAX_FOUND) find_package(OpenAL REQUIRED) endif() - message(STATUS "Sound support: ENABLED") + if(AAX_FOUND) + message(STATUS "Sound support: AeonWave") + else() + message(STATUS "Sound support: OpenAL") + endif() endif(ENABLE_SOUND) find_package(OpenSceneGraph 3.2.0 REQUIRED osgText osgSim osgDB osgParticle osgGA osgViewer osgUtil) diff --git a/CMakeModules/FindAAX.cmake b/CMakeModules/FindAAX.cmake index edbef409..0e21386f 100644 --- a/CMakeModules/FindAAX.cmake +++ b/CMakeModules/FindAAX.cmake @@ -1,14 +1,19 @@ -# Locate AAX +# Try to find AAX (AeonWave) # This module defines -# AAX_LIBRARIES -# AAX_FOUND, if false, do not try to link to AAX -# AAX_INCLUDE_DIR, where to find the headers +# +# AAX_FOUND - if false, do not try to link to AAX +# AAX_INCLUDE_DIR - where to find the headers +# AAX_LIBRARIES - Link these to use AAX +# +# Copyright (C) 2016-2018 by Erik Hofman. +# Copyright (C) 2016-2018 by Adalin B.V. # # $AAXDIR is an environment variable that would # correspond to the ./configure --prefix=$AAXDIR # used in building AAX. # -# Created by Erik Hofman. +# This file is Public Domain (www.unlicense.org) +# This is free and unencumbered software released into the public domain. FIND_PATH(AAX_INCLUDE_DIR aax/aax.h HINTS diff --git a/README.OpenAL b/README.OpenAL deleted file mode 100644 index f21c656a..00000000 --- a/README.OpenAL +++ /dev/null @@ -1,20 +0,0 @@ -[This file is mirrored in both the FlightGear and SimGear packages.] - -You *must* have the development components of OpenAL installed on your system -to build FlightGear!" You can get a copy here: - - http://connect.creativelabs.com/openal/default.aspx - -Build notes: - -You can download a versioned release of the openal library from -http://www.openal.org/downloads.html. Download the openal source, -release 0.0.8 (dated February 11, 2006) and run: -tar xjvf openal-soft-1.5.304.tar.bz2 -cd openal-soft-1.5.304/ -ccmake . - -[ While running ccmake: press 'c' to configure, press 'c' once more, and - then press 'g' to generate and exit ] - - diff --git a/README.sound b/README.sound new file mode 100644 index 00000000..bee72ffe --- /dev/null +++ b/README.sound @@ -0,0 +1,39 @@ +[This file is mirrored in both the FlightGear and SimGear packages.] + +For Sound support FlightGear requires one of the two following packages: +- OpenAL +- AeonWave + +== OpenAL === + +You *must* have the development components of OpenAL installed on your system +to build FlightGear!" You can get a copy here: + + http://connect.creativelabs.com/openal/default.aspx + +Build notes: + +You can download a versioned release of the openal library from +http://www.openal.org/downloads.html. Download the openal source, +release 0.0.8 (dated February 11, 2006) and run: +tar xjvf openal-soft-1.5.304.tar.bz2 +cd openal-soft-1.5.304/ +ccmake . + +[ While running ccmake: press 'c' to configure, press 'c' once more, and + then press 'g' to generate and exit ] + + +== AeonWave === + +For FlightGear AeonWave has a number of advantages over OpenAL: +* Correct Doppler effect behavior +* Default distance attenuation frequency filtering +* Native support for 29 types of audio formats. +* Native support for wav, mp3, vorbis and raw file formats. + +The source code of AeonWave can be found on GitHub: +https://github.com/adalinbv + +Optimized binary packages are available at: +http://www.adalin.com/ diff --git a/simgear/simgear_config_cmake.h.in b/simgear/simgear_config_cmake.h.in index c3668638..de1b69c6 100644 --- a/simgear/simgear_config_cmake.h.in +++ b/simgear/simgear_config_cmake.h.in @@ -25,5 +25,6 @@ #cmakedefine SYSTEM_EXPAT #cmakedefine ENABLE_SOUND +#cmakedefine USE_AEONWAVE #cmakedefine ENABLE_SIMD #cmakedefine ENABLE_GDAL diff --git a/simgear/sound/soundmgr.hxx b/simgear/sound/soundmgr.hxx index 21d87d8d..89b8cda4 100644 --- a/simgear/sound/soundmgr.hxx +++ b/simgear/sound/soundmgr.hxx @@ -314,7 +314,7 @@ public: /** * Get a list of available playback devices. */ - std::vector get_available_devices(); + std::vector get_available_devices(); /** * Get the current OpenAL vendor or rendering backend. diff --git a/simgear/sound/soundmgr_aeonwave.cxx b/simgear/sound/soundmgr_aeonwave.cxx index 383c6039..b25fe008 100644 --- a/simgear/sound/soundmgr_aeonwave.cxx +++ b/simgear/sound/soundmgr_aeonwave.cxx @@ -75,10 +75,6 @@ public: ~SoundManagerPrivate() { - for (auto it = _devices.begin(); it != _devices.end(); ++it) { - free((void*)*it); - } - _devices.clear(); _sample_groups.clear(); } @@ -125,8 +121,6 @@ public: } sample_group_map _sample_groups; - - std::vector _devices; }; @@ -444,7 +438,7 @@ unsigned int SGSoundMgr::request_buffer(SGSoundSample *sample) std::string sample_name = sample->get_sample_name(); aax::Buffer& buf = d->_aax.buffer(sample_name); - if (!buf) { + if (sample->is_file() && !buf) { SG_LOG(SG_SOUND, SG_ALERT, "Unable to create buffer: " << sample_name); sample->set_buffer( SGSoundMgr::FAILED_BUFFER ); @@ -561,6 +555,7 @@ void SGSoundMgr::sample_play( SGSoundSample *sample ) if (bufid == SGSoundMgr::FAILED_BUFFER || bufid == SGSoundMgr::NO_BUFFER) { +printf("A: release: %i, bufid: %i (%i, %i)\n", sample->get_source(), bufid, SGSoundMgr::FAILED_BUFFER, SGSoundMgr::NO_BUFFER); release_source(sample->get_source()); return; } @@ -646,39 +641,46 @@ void SGSoundMgr::update_sample_config( SGSoundSample *sample, SGVec3d& position, aax::Emitter& emitter = d->get_emitter(sample->get_source()); aax::dsp dsp; - aax::Vector64 pos = position.data(); - aax::Vector ori = orientation.data(); - aax::Vector vel = velocity.data(); - - aax::Matrix64 mtx(pos, ori); - TRY( emitter.matrix(mtx) ); - TRY( emitter.velocity(vel) ); + if (emitter != d->nullEmitter) + { + aax::Vector64 pos = position.data(); + aax::Vector ori = orientation.data(); + aax::Vector vel = velocity.data(); - dsp = emitter.get(AAX_VOLUME_FILTER); - TRY( dsp.set(AAX_GAIN, sample->get_volume()) ); - TRY( emitter.set(dsp) ); + aax::Matrix64 mtx(pos, ori); + TRY( emitter.matrix(mtx) ); + TRY( emitter.velocity(vel) ); - dsp = emitter.get(AAX_PITCH_EFFECT); - TRY( dsp.set(AAX_PITCH, sample->get_pitch()) ); - TRY( emitter.set(dsp) ); - - if ( sample->has_static_data_changed() ) { - dsp = emitter.get(AAX_ANGULAR_FILTER); - TRY( dsp.set(AAX_INNER_ANGLE, sample->get_innerangle()) ); - TRY( dsp.set(AAX_OUTER_ANGLE, sample->get_outerangle()) ); - TRY( dsp.set(AAX_OUTER_GAIN, sample->get_outergain()) ); + dsp = emitter.get(AAX_VOLUME_FILTER); + TRY( dsp.set(AAX_GAIN, sample->get_volume()) ); TRY( emitter.set(dsp) ); - dsp = emitter.get(AAX_DISTANCE_FILTER); - TRY( dsp.set(AAX_REF_DISTANCE, sample->get_reference_dist()) ); - TRY( dsp.set(AAX_MAX_DISTANCE, sample->get_max_dist()) ); + dsp = emitter.get(AAX_PITCH_EFFECT); + TRY( dsp.set(AAX_PITCH, sample->get_pitch()) ); TRY( emitter.set(dsp) ); + + if ( sample->has_static_data_changed() ) { + dsp = emitter.get(AAX_ANGULAR_FILTER); + TRY( dsp.set(AAX_INNER_ANGLE, sample->get_innerangle()) ); + TRY( dsp.set(AAX_OUTER_ANGLE, sample->get_outerangle()) ); + TRY( dsp.set(AAX_OUTER_GAIN, sample->get_outergain()) ); + TRY( emitter.set(dsp) ); + + dsp = emitter.get(AAX_DISTANCE_FILTER); + TRY( dsp.set(AAX_REF_DISTANCE, sample->get_reference_dist()) ); + TRY( dsp.set(AAX_MAX_DISTANCE, sample->get_max_dist()) ); + TRY( emitter.set(dsp) ); + } + } + else { + SG_LOG( SG_SOUND, SG_ALERT, "Error: source: " << sample->get_source() << " not found"); } } -vector SGSoundMgr::get_available_devices() +vector SGSoundMgr::get_available_devices() { + vector devices; #ifdef ENABLE_SOUND std::string on = " on "; std::string colon = ": "; @@ -690,12 +692,12 @@ vector SGSoundMgr::get_available_devices() else if (*r) name += on + r; else if (*i) name += colon + i; - d->_devices.push_back( strdup(name.c_str()) ); + devices.push_back( name ); } } } #endif - return d->_devices; + return devices; } diff --git a/simgear/sound/soundmgr_openal.cxx b/simgear/sound/soundmgr_openal.cxx index 64a706df..cc3b420a 100644 --- a/simgear/sound/soundmgr_openal.cxx +++ b/simgear/sound/soundmgr_openal.cxx @@ -821,9 +821,9 @@ bool SGSoundMgr::load( const std::string &samplepath, return true; } -vector SGSoundMgr::get_available_devices() +vector SGSoundMgr::get_available_devices() { - vector devices; + vector devices; #ifdef ENABLE_SOUND const ALCchar *s;