Changeset 2950 for code/branches/sound/src/sound/SoundBase.cc
- Timestamp:
- May 4, 2009, 3:40:08 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/sound/src/sound/SoundBase.cc
r2932 r2950 34 34 namespace orxonox 35 35 { 36 SoundBase::SoundBase() 37 { 38 this->source_ = 0; 39 this->buffer_ = 0; 40 this->entity_ = NULL; 41 } 36 42 SoundBase::SoundBase(WorldEntity* entity) 37 43 { … … 39 45 this->buffer_ = 0; 40 46 this->entity_ = entity; 41 42 if(SoundBase::soundmanager_s == NULL)43 SoundBase::soundmanager_s = SoundManager::instance();44 47 } 45 48 … … 51 54 52 55 void SoundBase::update() { 53 if( alIsSource(this->source_)) {56 if(this->entity_ != NULL && alIsSource(this->source_)) { 54 57 Vector3 pos = this->entity_->getPosition(); 55 58 alSource3f(this->source_, AL_POSITION, pos.x, pos.y, pos.z); … … 99 102 return getSourceState() == AL_PLAYING; 100 103 } 104 return false; 101 105 } 102 106 … … 105 109 return getSourceState() == AL_PAUSED; 106 110 } 111 return true; 107 112 } 108 113 … … 111 116 return getSourceState() == AL_INITIAL || getSourceState() == AL_STOPPED; 112 117 } 118 return true; 113 119 } 114 120 115 121 bool SoundBase::loadFile(std::string filename) { 122 COUT(3) << "OpenAL ALUT: loading file " << filename << std::endl; 116 123 this->buffer_ = alutCreateBufferFromFile(filename.c_str()); 117 124 if(this->buffer_ == AL_NONE) { 118 COUT(2) << "OpenAL ALUT: " << alutGetErrorString(alutGetError()) ;125 COUT(2) << "OpenAL ALUT: " << alutGetErrorString(alutGetError()) << std::endl; 119 126 return false; 120 127 } … … 123 130 alSourcei(this->source_, AL_BUFFER, this->buffer_); 124 131 if(alGetError() != AL_NO_ERROR) { 125 COUT(2) << "OpenAL: Error loading sample file" ;132 COUT(2) << "OpenAL: Error loading sample file" << std::endl; 126 133 return false; 127 134 }
Note: See TracChangeset
for help on using the changeset viewer.