Get soundmgr_aeonwave in a compilig state

This commit is contained in:
Erik Hofman 2016-07-04 14:26:19 +02:00
parent 968e0b4cd2
commit d12cd4945e
5 changed files with 163 additions and 135 deletions

View File

@ -131,6 +131,7 @@ option(SIMGEAR_HEADLESS "Set to ON to build SimGear without GUI/graphics support
option(ENABLE_RTI "Set to ON to build SimGear with RTI support" OFF) option(ENABLE_RTI "Set to ON to build SimGear with RTI support" OFF)
option(ENABLE_TESTS "Set to OFF to disable building SimGear's test applications" ON) 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(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" ON)
option(ENABLE_PKGUTIL "Set to ON to build the sg_pkgutil application (default)" 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_DNS "Set to ON to use udns library and DNS service resolver" ON)
@ -191,8 +192,12 @@ if (MSVC AND MSVC_3RDPARTY_ROOT)
) )
# set (BOOST_ROOT ${MSVC_3RDPARTY_ROOT}/boost_1_44_0) # set (BOOST_ROOT ${MSVC_3RDPARTY_ROOT}/boost_1_44_0)
message(STATUS "BOOST_ROOT is ${BOOST_ROOT}") message(STATUS "BOOST_ROOT is ${BOOST_ROOT}")
if (USE_AEONWAVE)
find_package(AAX COMPONENTS aax REQUIRED)
else()
set (OPENAL_INCLUDE_DIR ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/include) set (OPENAL_INCLUDE_DIR ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/include)
set (OPENAL_LIBRARY_DIR ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/lib) set (OPENAL_LIBRARY_DIR ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/lib)
endif()
endif (MSVC AND MSVC_3RDPARTY_ROOT) endif (MSVC AND MSVC_3RDPARTY_ROOT)
if(APPLE) if(APPLE)
@ -209,11 +214,9 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
endif() endif()
# Somehow this only works if included before searching for Boost...
include(BoostTestTargets)
find_package(Boost REQUIRED) find_package(Boost REQUIRED)
set (BOOST_CXX_FLAGS "-DBOOST_BIMAP_DISABLE_SERIALIZATION") set (BOOST_CXX_FLAGS "-DBOOST_BIMAP_DISABLE_SERIALIZATION")
include(BoostTestTargets)
if(SIMGEAR_HEADLESS) if(SIMGEAR_HEADLESS)
message(STATUS "SimGear mode: HEADLESS") message(STATUS "SimGear mode: HEADLESS")
@ -401,10 +404,20 @@ include_directories(BEFORE ${PROJECT_BINARY_DIR}/simgear)
include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS} include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR}
${OPENAL_INCLUDE_DIR}
${CURL_INCLUDE_DIRS} ${CURL_INCLUDE_DIRS}
) )
if (USE_AEONWAVE)
find_package(AAX COMPONENTS aax REQUIRED)
include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS}
${AAX_INCLUDE_DIR}
)
else()
include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS}
${OPENAL_INCLUDE_DIR}
)
endif()
add_definitions(-DHAVE_CONFIG_H) add_definitions(-DHAVE_CONFIG_H)
# configure a header file to pass some of the CMake settings # configure a header file to pass some of the CMake settings

View File

@ -3,7 +3,7 @@ include (SimGearComponent)
set(HEADERS set(HEADERS
sample.hxx sample.hxx
sample_group.hxx sample_group.hxx
soundmgr_openal.hxx soundmgr_aeonwave.hxx
xmlsound.hxx xmlsound.hxx
readwav.hxx readwav.hxx
) )
@ -11,33 +11,54 @@ set(HEADERS
set(SOURCES set(SOURCES
sample.cxx sample.cxx
sample_group.cxx sample_group.cxx
soundmgr_openal.cxx soundmgr_aeonwave.cxx
xmlsound.cxx xmlsound.cxx
readwav.cxx readwav.cxx
soundmgr_openal_private.hxx soundmgr_openal_private.hxx
) )
if (USE_AEONWAVE)
set(HEADERS ${HEADERS}
soundmgr_aeonwave.hxx
)
set(SOURCES ${SOURCES}
soundmgr_aeonwave.cxx
)
else()
set(HEADERS ${HEADERS}
soundmgr_openal.hxx
)
set(SOURCES ${SOURCES}
soundmgr_openal.cxx
)
endif()
simgear_scene_component(sound sound "${SOURCES}" "${HEADERS}") simgear_scene_component(sound sound "${SOURCES}" "${HEADERS}")
if(ENABLE_TESTS AND ENABLE_SOUND) if(ENABLE_TESTS AND ENABLE_SOUND)
if (SIMGEAR_SHARED)
set( SOUND_TEST_LIBS set( SOUND_TEST_LIBS
${TEST_LIBS})
else()
set(SOUND_TEST_LIBS
${TEST_LIBS} ${TEST_LIBS}
${OPENAL_LIBRARY}) )
endif()
function(create_test TEST_NAME) if (USE_AEONWAVE)
else ()
if (SIMGEAR_SHARED)
else()
set(SOUND_TEST_LIBS ${SOUND_TEST_LIBS}
${OPENAL_LIBRARY}
)
endif()
function(create_test TEST_NAME)
add_executable(${TEST_NAME} ${TEST_NAME}.cxx) add_executable(${TEST_NAME} ${TEST_NAME}.cxx)
target_link_libraries(${TEST_NAME} ${SOUND_TEST_LIBS}) target_link_libraries(${TEST_NAME} ${SOUND_TEST_LIBS})
set_target_properties(${TEST_NAME} PROPERTIES set_target_properties(${TEST_NAME} PROPERTIES
COMPILE_DEFINITIONS "SRC_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}\"" ) COMPILE_DEFINITIONS "SRC_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}\"" )
endfunction() endfunction()
create_test(openal_test1) create_test(openal_test1)
create_test(openal_test2) create_test(openal_test2)
create_test(openal_test3) create_test(openal_test3)
endif()
endif() endif()

View File

@ -111,6 +111,7 @@ public:
inline size_t get_size() const { inline size_t get_size() const {
return (_samples * _tracks * _bits)/8; return (_samples * _tracks * _bits)/8;
} }
inline size_t get_no_samples() { return _samples; }
/** /**
@ -446,6 +447,10 @@ public:
_tracks = fmt & 0x3; _bits = fmt & 0x1C; _compressed = fmt & 0x100; _tracks = fmt & 0x3; _bits = fmt & 0x1C; _compressed = fmt & 0x100;
} }
inline void set_bits_sample( unsigned int b ) { _bits = b; }
inline void set_no_tracks( unsigned int t ) { _tracks = t; }
inline void set_compressed( bool c ) { _compressed = c; }
/** /**
* Set the block alignament for compressed audio. * Set the block alignament for compressed audio.
* @param block the block alignment in bytes * @param block the block alignment in bytes

View File

@ -54,18 +54,23 @@ typedef std::map < unsigned int,AAX::Buffer& > buffer_map;
typedef buffer_map::iterator buffer_map_iterator; typedef buffer_map::iterator buffer_map_iterator;
typedef buffer_map::const_iterator const_buffer_map_iterator; typedef buffer_map::const_iterator const_buffer_map_iterator;
typedef std::map < std::string, SGSharedPtr<SGSampleGroup> > sample_group_map;
typedef sample_group_map::iterator sample_group_map_iterator;
typedef sample_group_map::const_iterator const_sample_group_map_iterator;
#define BLOCKSIZE_TO_SMP(a) ((a) > 1) ? (((a)-4)*2) : 1
class SGSoundMgr::SoundManagerPrivate class SGSoundMgr::SoundManagerPrivate
{ {
public: public:
SoundManagerPrivate() : SoundManagerPrivate() :
_buffer_id(0),
_source_id(0),
_base_pos(SGVec3d::zeros()), _base_pos(SGVec3d::zeros()),
_buffer_id(0),
_source_id(0)
{ {
} }
void init() void init() {
{
_mtx64 = AAX::Matrix64(); _mtx64 = AAX::Matrix64();
} }
@ -73,7 +78,7 @@ public:
{ {
SGVec3d sgv_at = _orientation.backTransform(-SGVec3d::e3()); SGVec3d sgv_at = _orientation.backTransform(-SGVec3d::e3());
SGVec3d sgv_up = _orientation.backTransform(SGVec3d::e2()); SGVec3d sgv_up = _orientation.backTransform(SGVec3d::e2());
_mtx64.set(_base_pos, sgv_at, sgv_up); _mtx64.set(_base_pos.data(), sgv_at.data(), sgv_up.data());
} }
AAX::AeonWave _aax; AAX::AeonWave _aax;
@ -84,14 +89,22 @@ public:
unsigned int _buffer_id; unsigned int _buffer_id;
buffer_map _buffers; buffer_map _buffers;
AAX::Buffer nullBuffer;
AAX::Buffer& get_buffer(unsigned int id) {
buffer_map_iterator buffer_it = _buffers.find(id);
if ( buffer_it != _buffers.end() ) return buffer_it->second;
SG_LOG(SG_SOUND, SG_ALERT, "unknown buffer id requested.");
return nullBuffer;
}
unsigned int _source_id; unsigned int _source_id;
source_map _sources; source_map _sources;
AAX::Emitter nullEmitter;
AAX::Emitter& get_source(unsigned int id) { AAX::Emitter& get_source(unsigned int id) {
source_map_iterator source_it = _d->_sources.find(id); source_map_iterator source_it = _sources.find(id);
if ( source_it != d->_sources.end() ) return source_it->second; if ( source_it != _sources.end() ) return source_it->second;
SG_LOG(SG_SOUND, SG_ALERT, "unknown source id requested."); SG_LOG(SG_SOUND, SG_ALERT, "unknown source id requested.");
return NULL; return nullEmitter;
} }
sample_group_map _sample_groups; sample_group_map _sample_groups;
@ -106,13 +119,11 @@ public:
// constructor // constructor
SGSoundMgr::SGSoundMgr() : SGSoundMgr::SGSoundMgr() :
_renderer("unknown"),
_vendor("unknown"),
_active(false), _active(false),
_changed(true), _changed(true),
_volume(0.0), _volume(0.0)
_offset_pos(SGVec3d::zeros()),
_velocity(SGVec3d::zeros()),
_renderer("unknown"),
_vendor("unknown")
{ {
d.reset(new SoundManagerPrivate); d.reset(new SoundManagerPrivate);
d->_base_pos = SGVec3d::fromGeod(_geod_pos); d->_base_pos = SGVec3d::fromGeod(_geod_pos);
@ -139,7 +150,7 @@ void SGSoundMgr::init()
SG_LOG( SG_SOUND, SG_INFO, "Initializing AeonWave sound manager" ); SG_LOG( SG_SOUND, SG_INFO, "Initializing AeonWave sound manager" );
_source_id = 0; d->_source_id = 0;
d->_sources.clear(); d->_sources.clear();
AAX::AeonWave aax; AAX::AeonWave aax;
@ -154,7 +165,7 @@ void SGSoundMgr::init()
aax = AAX::AeonWave(devname); aax = AAX::AeonWave(devname);
} }
if ((!devname)||(testForError(device, "Audio device not available, trying default.")) ) { if ((!devname)||(testForError(aax, "Audio device not available, trying default.")) ) {
aax = AAX::AeonWave(AAX_MODE_WRITE_STEREO); aax = AAX::AeonWave(AAX_MODE_WRITE_STEREO);
if (testForError(aax, "Default audio device not available.") ) { if (testForError(aax, "Default audio device not available.") ) {
return; return;
@ -230,10 +241,10 @@ void SGSoundMgr::stop()
sgrp->stop(); sgrp->stop();
} }
_bufefr_id = 0; d->_buffer_id = 0;
d->_buffers.clear(); d->_buffers.clear();
_source_id = 0; d->_source_id = 0;
d->_sources.clear(); d->_sources.clear();
if (is_working()) { if (is_working()) {
@ -307,15 +318,14 @@ void SGSoundMgr::update( double dt )
SGQuatd hlOr = SGQuatd::fromLonLat( _geod_pos ); SGQuatd hlOr = SGQuatd::fromLonLat( _geod_pos );
SGVec3d velocity = SGVec3d::zeros(); SGVec3d velocity = SGVec3d::zeros();
if ( _velocity[0] || _velocity[1] || _velocity[2] ) { if ( _velocity[0] || _velocity[1] || _velocity[2] ) {
velocity = hlOr.backTransform(_velocity*SG_FEET_TO_METER); velocity = SGVec3d( _velocity*SG_FEET_TO_METER );
velocity = hlOr.backTransform(velocity);
} }
AAX::Vector vel(velocity.data());
d->_aax.sensor_velocity(vel);
if ( _bad_doppler ) { AAX::Matrix mtx = d->_mtx64.toMatrix();
velocity *= 100.0f; d->_aax.sensor_matrix(mtx);
}
d->_aax.sensor_velocity(AAX::Vector(toVec3f(velocity).data()));
d->_aax.sensor_matrix(d->_mtx64);
testForError("update"); testForError("update");
_changed = false; _changed = false;
@ -392,14 +402,14 @@ void SGSoundMgr::set_volume( float v )
unsigned int SGSoundMgr::request_source() unsigned int SGSoundMgr::request_source()
{ {
unsigned int id = d->_source_id++; unsigned int id = d->_source_id++;
d->_sources.insert( std::pair<id,AAX::Emitter()> ); d->_sources.insert( std::make_pair(id,AAX::Emitter()) );
return id; return id;
} }
// Free up a source id // Free up a source id
void SGSoundMgr::release_source( unsigned int source ) void SGSoundMgr::release_source( unsigned int source )
{ {
source_map_iterator source_it = _d->_sources.find(source); source_map_iterator source_it = d->_sources.find(source);
if ( source_it != d->_sources.end() ) if ( source_it != d->_sources.end() )
{ {
AAX::Emitter& emitter = source_it->second; AAX::Emitter& emitter = source_it->second;
@ -418,71 +428,61 @@ unsigned int SGSoundMgr::request_buffer(SGSoundSample *sample)
if ( !sample->is_valid_buffer() ) { if ( !sample->is_valid_buffer() ) {
// sample was not yet loaded or removed again // sample was not yet loaded or removed again
std::string sample_name = sample->get_sample_name(); std::string sample_name = sample->get_sample_name();
void *sample_data = NULL;
// sample name was not found in the buffer cache. AAX::Buffer& buf = d->_aax.buffer(sample_name);
if ( sample->is_file() ) {
AAX::Buffer& buf = d->_aax->buffer(sample_name);
if (!buf) { if (!buf) {
SG_LOG(SG_SOUND, SG_ALERT, SG_LOG(SG_SOUND, SG_ALERT,
"failed to load sound file: " << sample_name); "Unable to create buffer: " << sample_name);
sample->set_buffer( SGSoundMgr::FAILED_BUFFER ); sample->set_buffer( SGSoundMgr::FAILED_BUFFER );
return FAILED_BUFFER; return FAILED_BUFFER;
} }
buffer = d->_buffer_id++; buffer = d->_buffer_id++;
d->_buffers.insert( std::pair<buffer,buf> ); d->_buffers.insert( std::make_pair<unsigned int,AAX::Buffer&>(buffer,buf) );
sample->set_block_align( buf.get(AAX_BLOCK_ALIGNMENT) ); if ( !sample->is_file() ) {
sample->set_frequency( buf.get(AAX_FREQUENCY) );
sample->set_no_samples( buf.get(AAX_NO_SAMPLES) );
sample->set_no_tracks( buf.get(AAX_TRACKS) );
enum aaxFormat fmt = buf.get(AAX_FORMAT);
sample->set_bits_sample( aaxGetBitsPerSample(fmt) );
bool c = (fmt == AAX_MULAW || fmt == AAX_IMA4_ADPCM);
sample->set_compressed(c);
} else {
enum aaxFormat format = AAX_FORMAT_NONE; enum aaxFormat format = AAX_FORMAT_NONE;
switch( sample->get_format() ) switch( sample->get_format() )
{ {
case SG_SAMPLE_MONO16: case SG_SAMPLE_MONO16:
format = AAX_FORMAT_PCM16; format = AAX_PCM16S;
break; break;
case SG_SAMPLE_MONO8: case SG_SAMPLE_MONO8:
format = AAX_FORMAT_PCM8; format = AAX_PCM8S;
break; break;
case SG_SAMPLE_MULAW: case SG_SAMPLE_MULAW:
format = AAX_FORMAT_MULAW; format = AAX_MULAW;
break; break;
case SG_SAMPLE_ADPCM: case SG_SAMPLE_ADPCM:
format = AAX_FORMAT_IMA4_ADPCM; format = AAX_IMA4_ADPCM;
break; break;
default: default:
SG_LOG(SG_SOUND, SG_ALERT, "unsupported audio format"); SG_LOG(SG_SOUND, SG_ALERT, "unsupported audio format");
return buffer; return buffer;
} }
AAX::Buffer& buf = d->_aax->buffer(sample_name);
if ( buf ) {
unsigned int no_samples = sample->get_no_samples(); unsigned int no_samples = sample->get_no_samples();
buf.set(d->_aax, no_samples, 1, format); buf.set(d->_aax, no_samples, 1, format);
buf.set( AAX_FREQUENCY, sample->get_frequency() ); buf.set( AAX_FREQUENCY, sample->get_frequency() );
buf.fill( sample->get_data() ); buf.fill( sample->get_data() );
if (format == AAX_FORMAT_IMA4_ADPCM) { if (format == AAX_IMA4_ADPCM) {
size_t samples_block = BLOCKSIZE_TO_SMP( sample->get_block_align() ); size_t samples_block = BLOCKSIZE_TO_SMP( sample->get_block_align() );
buf.set( AAX_BLOCK_ALIGNMENT, samples_block ); buf.set( AAX_BLOCK_ALIGNMENT, samples_block );
} }
}
buffer = d->_buffer_id++;
d->_buffers.insert( std::pair<buffer,buf> );
sample->set_buffer(buffer); sample->set_buffer(buffer);
} sample->set_block_align( buf.get(AAX_BLOCK_ALIGNMENT) );
} sample->set_frequency( buf.get(AAX_FREQUENCY) );
sample->set_no_samples( buf.get(AAX_NO_SAMPLES) );
sample->set_no_tracks( buf.get(AAX_TRACKS) );
enum aaxFormat fmt = aaxFormat( buf.get(AAX_FORMAT) );
sample->set_bits_sample( aaxGetBitsPerSample(fmt) );
bool c = (fmt == AAX_MULAW || fmt == AAX_IMA4_ADPCM);
sample->set_compressed(c);
} }
else { else {
buffer = sample->get_buffer(); buffer = sample->get_buffer();
@ -496,13 +496,13 @@ void SGSoundMgr::release_buffer(SGSoundSample *sample)
if ( !sample->is_queue() ) if ( !sample->is_queue() )
{ {
unsigned int buffer = sample->get_buffer(); unsigned int buffer = sample->get_buffer();
buffer_map_iterator buffer_it = _d->_buffers.find(buffer); buffer_map_iterator buffer_it = d->_buffers.find(buffer);
if ( buffer_it != d->_buffers.end() ) if ( buffer_it != d->_buffers.end() )
{ {
sample->no_valid_buffer(); sample->no_valid_buffer();
#ifdef ENABLE_SOUND #ifdef ENABLE_SOUND
AAX::Buffer& buffer = buffer_it->second; AAX::Buffer& buffer = buffer_it->second;
d->_aax->destroy(buffer); d->_aax.destroy(buffer);
#endif #endif
d->_buffers.erase(buffer_it); d->_buffers.erase(buffer_it);
testForError("release buffer"); testForError("release buffer");
@ -514,7 +514,7 @@ void SGSoundMgr::sample_suspend( SGSoundSample *sample )
{ {
if ( sample->is_valid_source() && sample->is_playing() ) { if ( sample->is_valid_source() && sample->is_playing() ) {
AAX::Emitter& emitter = d->get_source(sample->get_source()); AAX::Emitter& emitter = d->get_source(sample->get_source());
emitter.set(AAX_PASUED); emitter.set(AAX_SUSPENDED);
} }
} }
@ -539,7 +539,8 @@ void SGSoundMgr::sample_play( SGSoundSample *sample )
AAX::Emitter& emitter = d->get_source(sample->get_source()); AAX::Emitter& emitter = d->get_source(sample->get_source());
if ( !sample->is_queue() ) { if ( !sample->is_queue() ) {
emitter.add(request_buffer(sample)); unsigned int buffer = request_buffer(sample);
emitter.add( d->get_buffer(buffer) );
} }
AAX::DSP dsp = emitter.get(AAX_DISTANCE_FILTER); AAX::DSP dsp = emitter.get(AAX_DISTANCE_FILTER);
@ -577,7 +578,7 @@ void SGSoundMgr::sample_destroy( SGSoundSample *sample )
{ {
if ( sample->is_valid_source() ) { if ( sample->is_valid_source() ) {
#ifdef ENABLE_SOUND #ifdef ENABLE_SOUND
ALint source = sample->get_source(); unsigned int source = sample->get_source();
if ( sample->is_playing() ) { if ( sample->is_playing() ) {
AAX::Emitter& emitter = d->get_source(source); AAX::Emitter& emitter = d->get_source(source);
emitter.set(AAX_STOPPED); emitter.set(AAX_STOPPED);
@ -610,9 +611,13 @@ void SGSoundMgr::update_sample_config( SGSoundSample *sample, SGVec3d& position,
AAX::Emitter& emitter = d->get_source(sample->get_source()); AAX::Emitter& emitter = d->get_source(sample->get_source());
AAX::DSP dsp; AAX::DSP dsp;
d->_mtx64.set(position.data(), orientation.data()); AAX::Vector64 pos = position.data();
emitter.velocity(velocity.data()); AAX::Vector64 ori = orientation.data();
emitter.matrix(d->_mtx64); AAX::Vector vel = velocity.data();
d->_mtx64.set(pos, ori);
AAX::Matrix mtx = d->_mtx64;
emitter.matrix(mtx);
emitter.velocity(vel);
dsp = emitter.get(AAX_VOLUME_FILTER); dsp = emitter.get(AAX_VOLUME_FILTER);
dsp.set(AAX_GAIN, sample->get_volume()); dsp.set(AAX_GAIN, sample->get_volume());
@ -631,7 +636,7 @@ void SGSoundMgr::update_sample_config( SGSoundSample *sample, SGVec3d& position,
dsp = emitter.get(AAX_DISTANCE_FILTER); dsp = emitter.get(AAX_DISTANCE_FILTER);
dsp.set(AAX_REF_DISTANCE, sample->get_reference_dist()); dsp.set(AAX_REF_DISTANCE, sample->get_reference_dist());
sp.set(AAX_MAX_DISTANC, sample->get_max_dist(); dsp.set(AAX_MAX_DISTANCE, sample->get_max_dist());
emitter.set(dsp); emitter.set(dsp);
} }
} }
@ -643,14 +648,13 @@ vector<const char*> SGSoundMgr::get_available_devices()
#ifdef ENABLE_SOUND #ifdef ENABLE_SOUND
std::string on = " on "; std::string on = " on ";
std::string colon = ": "; std::string colon = ": ";
while (std::string d = d->_aax.drivers()) { while (const char* be = d->_aax.drivers()) {
while (std::string r = d->_aax.devices()) { while (const char* r = d->_aax.devices()) {
while (std::string i = d->_aax.interfaces()) { while (const char* i = d->_aax.interfaces()) {
std::string name; std::string name = be;
if (!i.empty() && !r.empty()) name = d + on + r + colon + i; if (i && r) name += on + r + colon + i;
else if (!r.empty()) name = d + on + r; else if (r) name += on + r;
else if (!i.empty) name = d + colon + i; else if (i) name += colon + i;
else name = d;
d->_devices.push_back(name); d->_devices.push_back(name);
devices.push_back(name.c_str()); devices.push_back(name.c_str());
@ -685,20 +689,6 @@ bool SGSoundMgr::testForError(std::string s, std::string name)
return false; return false;
} }
bool SGSoundMgr::testForALCError(std::string s)
{
#ifdef ENABLE_SOUND
enum aaxErrorType error = d->_aax.error_no();
if (error != AAX_ERROR_NONE) {
SG_LOG( SG_SOUND, SG_ALERT, "Error (sound manager): "
<< d->_aax.error(error) << " at "
<< s);
return true;
}
#endif
return false;
}
bool SGSoundMgr::is_working() const bool SGSoundMgr::is_working() const
{ {
return (d->_aax != NULL); return (d->_aax != NULL);
@ -717,9 +707,7 @@ void SGSoundMgr::set_orientation( const SGQuatd& ori )
const SGVec3d& SGSoundMgr::get_position() const const SGVec3d& SGSoundMgr::get_position() const
{ {
aaxVec3d pos, at, up; return d->_base_pos;
d->_mtx64.get(pos, at, up);
return pos;
} }
void SGSoundMgr::set_position( const SGVec3d& pos, const SGGeod& pos_geod ) void SGSoundMgr::set_position( const SGVec3d& pos, const SGGeod& pos_geod )
@ -729,7 +717,7 @@ void SGSoundMgr::set_position( const SGVec3d& pos, const SGGeod& pos_geod )
SGVec3f SGSoundMgr::get_direction() const SGVec3f SGSoundMgr::get_direction() const
{ {
aaxVec3d pos, at, up; aaxVec3f pos, at, up;
d->_mtx64.get(pos, at, up); d->_mtx64.get(pos, at, up);
return at; return SGVec3f( at );
} }

View File

@ -127,7 +127,7 @@ public:
void set_position( const SGVec3d& pos, const SGGeod& pos_geod ); void set_position( const SGVec3d& pos, const SGGeod& pos_geod );
void set_position_offset( const SGVec3d& pos ) { void set_position_offset( const SGVec3d& pos ) {
_offset_pos = pos; _changed = true; _offset_pos = pos.data(); _changed = true;
} }
/** /**
@ -145,7 +145,7 @@ public:
* @param vel Velocity vector * @param vel Velocity vector
*/ */
void set_velocity( const SGVec3d& vel ) { void set_velocity( const SGVec3d& vel ) {
_velocity = vel; _changed = true; _velocity = vel.data(); _changed = true;
} }
/** /**
@ -154,7 +154,7 @@ public:
* *
* @return Velocity vector of the OpenAL listener * @return Velocity vector of the OpenAL listener
*/ */
inline SGVec3f get_velocity() { return toVec3f(_velocity); } inline SGVec3f get_velocity() { SGVec3f f(_velocity); return f; }
/** /**
* Set the orientation of the sound manager * Set the orientation of the sound manager
@ -299,7 +299,7 @@ public:
* a problem in the implementation or in out code. Until then * a problem in the implementation or in out code. Until then
* this function is used to detect the problematic implementations. * this function is used to detect the problematic implementations.
*/ */
inline bool bad_doppler_effect() { return _bad_doppler; } inline bool bad_doppler_effect() { return false; }
/** /**
* Get a list of available playback devices. * Get a list of available playback devices.
@ -316,6 +316,7 @@ public:
static const char* subsystemName() { return "sound"; }; static const char* subsystemName() { return "sound"; };
private: private:
class SoundManagerPrivate;
/// private implementation object /// private implementation object
std::auto_ptr<SoundManagerPrivate> d; std::auto_ptr<SoundManagerPrivate> d;
@ -328,11 +329,11 @@ private:
float _volume; float _volume;
// Position of the listener. // Position of the listener.
SGVec3d _offset_pos; AAX::Vector64 _offset_pos;
SGGeod _geod_pos; SGGeod _geod_pos;
// Velocity of the listener. // Velocity of the listener.
AAX::Vector _velocity; AAX::Vector64 _velocity;
bool testForError(void *p, std::string s); bool testForError(void *p, std::string s);