// 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);
// 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
if (_changed) {
alListenerf( AL_GAIN, _volume );
+#if 0
alListenerfv( AL_ORIENTATION, _at_up_vec );
alListenerfv( AL_POSITION, toVec3f(_position).data() );
alListenerfv( AL_VELOCITY, toVec3f(_velocity).data() );
+#endif
// alDopplerVelocity(340.3); // TODO: altitude dependent
testForALError("update");
_changed = false;
_free_sources.pop_back();
_sources_in_use.push_back(source);
}
+ else
+ SG_LOG( SG_GENERAL, SG_INFO, "No more free sources available\n");
return source;
}
void *data;
load(sample_name, &data, &format, &size, &freq);
- std::auto_ptr<unsigned char> ptr;
- ptr.reset((unsigned char *)data);
-
- sample->set_data( ptr );
+ sample->set_data( &data );
sample->set_frequency( freq );
sample->set_format( format );
sample->set_size( size );
}
}
}
- else
+ else {
buffer = sample->get_buffer();
+}
return buffer;
}