Changeset 7299 in orxonox.OLD for trunk/src/lib/sound
- Timestamp:
- Apr 16, 2006, 5:48:40 PM (19 years ago)
- Location:
- trunk/src/lib/sound
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/sound/ogg_player.cc
r7297 r7299 102 102 return false; 103 103 } 104 this->state |= FileOpened; 104 105 105 106 // acquiring the vorbis-properties. 106 107 vorbisInfo = ov_info(&oggStream, -1); 107 108 vorbisComment = ov_comment(&oggStream, -1); 108 this->state |= FileOpened; 109 109 110 if(vorbisInfo->channels == 1) 110 111 format = AL_FORMAT_MONO16; … … 129 130 void OggPlayer::release() 130 131 { 131 this->printState();132 132 if (this->state & SourceAllocated) 133 133 { -
trunk/src/lib/sound/ogg_player.h
r7295 r7299 19 19 20 20 21 #define BUFFER_SIZE (8096 * 16)21 #define BUFFER_SIZE (8096 * 2) 22 22 23 23 -
trunk/src/lib/sound/sound_engine.cc
r7298 r7299 36 36 ////////////////// 37 37 /** 38 * standard constructor38 * @brief standard constructor 39 39 */ 40 40 SoundEngine::SoundEngine () … … 59 59 60 60 /** 61 * the singleton reference to this class61 * @brief the singleton reference to this class 62 62 */ 63 63 SoundEngine* SoundEngine::singletonRef = NULL; 64 64 65 65 /** 66 * standard deconstructor66 * @brief standard destructor 67 67 */ 68 68 SoundEngine::~SoundEngine () … … 105 105 106 106 /** 107 * loads the settings of the SoundEngine from an ini-file107 * @brief loads the settings of the SoundEngine from an ini-file 108 108 */ 109 109 void SoundEngine::loadSettings() … … 120 120 121 121 /** 122 * creates a new SoundSource.122 * @brief creates a new SoundSource. 123 123 * @param fileName The Name to load the SoundBuffer from 124 124 * @param sourceNode The sourceNode to bind this SoundSource to. … … 133 133 134 134 /** 135 * Sets the doppler values of openAL135 * @brief Sets the doppler values of openAL 136 136 * @param dopplerFactor the extent of the doppler-effect 137 137 * @param dopplerVelocity the Speed the sound travels … … 147 147 148 148 149 /** 150 * @brief retrieves an OpenAL Source from the availiable Sources. 151 * @param source the Source to fill with the Value. 152 */ 149 153 void SoundEngine::popALSource(ALuint& source) 150 154 { … … 158 162 this->ALSources.pop(); 159 163 SDL_mutexV(this->sourceMutex); 160 printf("Retrieve Source %d\n", source); 161 } 162 } 163 164 } 165 } 166 167 168 /** 169 * @brief Pushes an OpenAL Source back into the Stack of known sources 170 * @param source the Source to push onto the top of the SourceStack 171 */ 164 172 void SoundEngine::pushALSource(ALuint& source) 165 173 { … … 174 182 175 183 /** 176 * updates all The positions, Directions and Velocities of all Sounds177 */184 * @brief updates all The positions, Directions and Velocities of all Sounds 185 */ 178 186 void SoundEngine::update() 179 187 { … … 239 247 } 240 248 241 /**242 * Removes all the Buffers that are not anymore needed by any Sources243 */244 void SoundEngine::flushUnusedBuffers()245 {246 /// FIXME247 /* if(this->sourceList && this->bufferList)248 {249 tIterator<BaseObject>* bufferIterator = this->bufferList->getIterator();250 SoundBuffer* enumBuffer = (SoundBuffer*)bufferIterator->firstElement();251 while (enumBuffer)252 {253 tIterator<BaseObject>* sourceIterator = this->sourceList->getIterator();254 SoundSource* enumSource = (SoundSource*)sourceIterator->firstElement();255 while (enumSource)256 {257 if (enumBuffer == enumSource->getBuffer())258 break;259 enumSource = (SoundSource*)sourceIterator->nextElement();260 }261 delete sourceIterator;262 if (enumSource == NULL)263 ResourceManager::getInstance()->unload(enumBuffer);264 enumBuffer = (SoundBuffer*)bufferIterator->nextElement();265 }266 delete bufferIterator;267 }*/ /// FIXME268 }269 270 /**271 * flushes all the Buffers272 * deletes them from the BufferList, and also removes them via the ResourceManager.273 */274 void SoundEngine::flushAllBuffers()275 {276 if (this->bufferList)277 {278 while (this->bufferList->size() > 0)279 ResourceManager::getInstance()->unload(static_cast<SoundBuffer*>(this->bufferList->front()), RP_LEVEL);280 }281 }282 283 /**284 * deletes all the Sources.285 */286 void SoundEngine::flushAllSources()287 {288 if (this->sourceList)289 {290 while(this->sourceList->size() > 0)291 delete this->sourceList->front();292 }293 }294 249 295 250 /** … … 378 333 } 379 334 335 /** 336 * @brief checks for an OpenAL error 337 * @param error the ErrorMessage to display 338 * @param line on what line did the error occure. 339 */ 380 340 bool SoundEngine::checkError(const std::string& error, unsigned int line) 381 341 { … … 390 350 } 391 351 352 /** 353 * @brief check for an ALC error. 354 * @brief error the Error-String to display 355 * @param line on that line, the error occured (debugging mode). 356 */ 392 357 bool SoundEngine::checkALCError(const std::string& error, unsigned int line) 393 358 { -
trunk/src/lib/sound/sound_engine.h
r7298 r7299 52 52 void pushALSource(ALuint& source); 53 53 54 void flushUnusedBuffers();55 void flushAllBuffers();56 void flushAllSources();57 54 58 55 bool initAudio(); -
trunk/src/lib/sound/sound_source.cc
r7297 r7299 31 31 this->setClassID(CL_SOUND_SOURCE, "SoundSource"); 32 32 33 ALenum result;34 35 33 // adding the Source to the SourcesList of the SoundEngine 36 34 this->buffer = buffer; … … 39 37 this->sourceID = 0; 40 38 this->bPlay = false; 39 } 40 41 /** 42 * @brief construct a SoundSource out of the another soundSource 43 * @param source the Source to create this source from. 44 * 45 * Copies the buffer from source to this Source. 46 * Acquires a new SourceID if source is Playing. 47 */ 48 SoundSource::SoundSource(const SoundSource& source) 49 { 50 this->setClassID(CL_SOUND_SOURCE, "SoundSource"); 51 52 // adding the Source to the SourcesList of the SoundEngine 53 this->buffer = source.buffer; 54 this->sourceNode = source.sourceNode; 55 56 this->sourceID = 0; 57 if (source.bPlay == true) 58 { 59 this->bPlay = true; 60 SoundEngine::getInstance()->popALSource(this->sourceID); 61 } 62 else 63 this->bPlay = false; 64 } 65 66 /** 67 * @brief paste a copy of the source into this Source. 68 * @param source the SoundSource to paste into this one. 69 * @returns a Reference to this Source. 70 * 71 */ 72 SoundSource& SoundSource::operator=(const SoundSource& source) 73 { 74 this->buffer = source.buffer; 75 this->sourceNode = sourceNode; 76 77 if (source.bPlay) 78 this->play(); 79 else 80 this->stop(); 81 } 82 83 /** 84 * @brief compares two Sources with each other. 85 * @param source the Source to compare against this One. 86 * Two Sources are the same, if the PNodes match, and the Sound Played are the same. 87 * The alSource must not match, because no two Sources can have the same alSource. 88 */ 89 bool SoundSource::operator==(const SoundSource& source) 90 { 91 return (this->buffer == source.buffer && 92 this->bPlay == source.bPlay && 93 this->sourceNode == source.sourceNode); 41 94 } 42 95 … … 77 130 } 78 131 } 79 // assert (this->sourceID != 0);132 // assert (this->sourceID != 0); 80 133 81 134 alSourceStop(this->sourceID); -
trunk/src/lib/sound/sound_source.h
r7065 r7299 19 19 public: 20 20 SoundSource(const PNode* sourceNode = NULL, const SoundBuffer* buffer = NULL); 21 SoundSource(const SoundSource& source); 22 SoundSource& operator=(const SoundSource& source); 23 bool operator==(const SoundSource& source); 24 21 25 virtual ~SoundSource(); 22 26
Note: See TracChangeset
for help on using the changeset viewer.