Changeset 5968 in orxonox.OLD for branches/network/src/lib/sound/sound_source.cc
- Timestamp:
- Dec 7, 2005, 4:16:51 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/lib/sound/sound_source.cc
r5386 r5968 18 18 #include "sound_source.h" 19 19 #include "sound_engine.h" 20 20 21 #include "alincl.h" 21 22 #include "compiler.h" … … 33 34 34 35 // adding the Source to the SourcesList of the SoundEngine 35 SoundEngine::getInstance()->addSource(this);36 37 36 this->buffer = buffer; 38 37 this->sourceNode = sourceNode; 39 38 40 alGenSources(1, &this->sourceID); 41 if ((result = alGetError()) != AL_NO_ERROR) 42 SoundEngine::PrintALErrorString(result); 43 if (this->buffer != NULL) 44 alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID()); 45 alSourcef (this->sourceID, AL_PITCH, 1.0 ); 46 alSourcef (this->sourceID, AL_GAIN, SoundEngine::getInstance()->getEffectsVolume() ); 47 alSourcei (sourceID, AL_LOOPING, AL_FALSE ); 39 this->sourceID = 0; 40 this->bPlay = false; 48 41 } 49 42 … … 53 46 SoundSource::~SoundSource() 54 47 { 55 //SoundEngine::getInstance()->removeSource(this); 56 alDeleteSources(1, &this->sourceID); 48 SoundEngine::getInstance()->pushALSource(this->sourceID); 57 49 } 58 50 … … 62 54 void SoundSource::play() 63 55 { 56 if (this->sourceID == 0) 57 SoundEngine::getInstance()->popALSource(this->sourceID); 64 58 alSourcePlay(this->sourceID); 59 this->bPlay = true; 65 60 } 66 61 … … 71 66 void SoundSource::play(const SoundBuffer* buffer) 72 67 { 68 if (unlikely(this->sourceID == 0)) 69 SoundEngine::getInstance()->popALSource(this->sourceID); 70 71 printf("%d\n",sourceID); 73 72 alSourceStop(this->sourceID); 74 73 alSourcei (this->sourceID, AL_BUFFER, buffer->getID()); … … 77 76 if (unlikely(this->buffer != NULL)) 78 77 alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID()); 78 this->bPlay = true; 79 79 } 80 80 … … 84 84 void SoundSource::stop() 85 85 { 86 this->bPlay = false; 86 87 alSourceStop(this->sourceID); 88 SoundEngine::getInstance()->pushALSource(this->sourceID); 87 89 } 88 90
Note: See TracChangeset
for help on using the changeset viewer.