ALCdevice *dev;
ALCcontext *context;
+ alutInit(&argc, argv);
sglog().setLogLevels( SG_ALL, SG_ALERT );
// initialize OpenAL
alSourcePlay( source );
sleep(10);
+ alutExit();
return 0;
}
if ( !sample->is_playing() ) {
// a request to stop playing the sound has been filed.
- sample->no_valid_source();
sample->stop();
+ sample->no_valid_source();
_smgr->release_source( sample->get_source() );
} else {
update_sample_config( sample );
alGetSourcei( source, AL_SOURCE_STATE, &result );
if ( result == AL_STOPPED ) {
// sample is stoped because it wasn't looping
- sample->no_valid_source();
sample->stop();
+ sample->no_valid_source();
_smgr->release_source( source );
+ _smgr->release_buffer( sample );
}
}
testForALError("update");
return false;
}
- _removed_samples.push_back( sample_it->second );
+ if ( sample_it->second->is_valid_buffer() )
+ _removed_samples.push_back( sample_it->second );
_samples.erase( sample_it );
return true;
void SGSoundSample::update_absolute_position() {
SGQuatd orient = SGQuatd::fromLonLat(_base_pos) * _orientation;
_orivec = -toVec3f(orient.rotate(_direction));
-printf("ori: %f %f %f\n", _orivec[0], _orivec[1], _orivec[2]);
+//printf("ori: %f %f %f\n", _orivec[0], _orivec[1], _orivec[2]);
orient = SGQuatd::fromRealImag(0, _relative_pos) * _orientation;
_absolute_pos = -SGVec3d::fromGeod(_base_pos); // -orient.rotate(SGVec3d::e1());
-printf("pos: %f %f %f\n", _absolute_pos[0], _absolute_pos[1], _absolute_pos[2]);
+//printf("pos: %f %f %f\n", _absolute_pos[0], _absolute_pos[1], _absolute_pos[2]);
}
string SGSoundSample::random_string() {
// initialize the sound manager
void SGSoundMgr::init() {
+printf("Initializing OpenAL sound manager\n");
SG_LOG( SG_GENERAL, SG_INFO, "Initializing OpenAL sound manager" );
ALCdevice *device = alcOpenDevice(_devname);
return;
}
+ if (_context != NULL)
+ SG_LOG(SG_GENERAL, SG_ALERT, "context is already assigned");
_context = context;
_working = true;
// stop the sound manager
void SGSoundMgr::stop() {
if (_working) {
+printf("Stopping Sound Manager\n");
_working = false;
_active = false;
void SGSoundMgr::suspend() {
if (_working) {
+printf("SoundManager suspend\n");
sample_group_map_iterator sample_grp_current = _sample_groups.begin();
sample_group_map_iterator sample_grp_end = _sample_groups.end();
for ( ; sample_grp_current != sample_grp_end; ++sample_grp_current ) {
void SGSoundMgr::resume() {
if (_working) {
+printf("SoundManager resume\n");
sample_group_map_iterator sample_grp_current = _sample_groups.begin();
sample_group_map_iterator sample_grp_end = _sample_groups.end();
for ( ; sample_grp_current != sample_grp_end; ++sample_grp_current ) {
void SGSoundMgr::bind ()
{
+printf("SoundManager bind\n");
_free_sources.clear();
_free_sources.reserve( MAX_SOURCES );
_sources_in_use.clear();
void SGSoundMgr::unbind ()
{
+printf("SoundManager unbind\n");
_sample_groups.clear();
// delete free sources