- Timestamp:
- Apr 17, 2006, 2:25:27 AM (19 years ago)
- Location:
- trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/sound/sound_engine.cc
r7299 r7317 151 151 * @param source the Source to fill with the Value. 152 152 */ 153 voidSoundEngine::popALSource(ALuint& source)153 bool SoundEngine::popALSource(ALuint& source) 154 154 { 155 155 assert (source == 0); … … 162 162 this->ALSources.pop(); 163 163 SDL_mutexV(this->sourceMutex); 164 } 164 return true; 165 } 166 else 167 return false; 165 168 } 166 169 -
trunk/src/lib/sound/sound_engine.h
r7299 r7317 49 49 50 50 // administrative 51 voidpopALSource(ALuint& source);51 bool popALSource(ALuint& source); 52 52 void pushALSource(ALuint& source); 53 53 -
trunk/src/lib/sound/sound_source.cc
r7299 r7317 34 34 this->buffer = buffer; 35 35 this->sourceNode = sourceNode; 36 this->resident = false; 36 37 37 38 this->sourceID = 0; 38 39 this->bPlay = false; 39 40 } 41 40 42 41 43 /** … … 53 55 this->buffer = source.buffer; 54 56 this->sourceNode = source.sourceNode; 57 this->resident = source.resident; 55 58 56 59 this->sourceID = 0; … … 63 66 this->bPlay = false; 64 67 } 68 65 69 66 70 /** … … 74 78 this->buffer = source.buffer; 75 79 this->sourceNode = sourceNode; 80 this->resident = source.resident; 76 81 77 82 if (source.bPlay) … … 81 86 } 82 87 88 83 89 /** 84 90 * @brief compares two Sources with each other. … … 94 100 } 95 101 102 96 103 /** 97 104 * @brief deletes a SoundSource … … 100 107 { 101 108 this->stop(); 102 } 109 if (this->sourceID != 0) 110 SoundEngine::getInstance()->pushALSource(this->sourceID); 111 } 112 103 113 104 114 /** … … 107 117 void SoundSource::play() 108 118 { 109 if (this->sourceID == 0) 110 SoundEngine::getInstance()->popALSource(this->sourceID); 111 alSourcePlay(this->sourceID); 112 if (DEBUG >= 3) 113 SoundEngine::checkError("Play Source", __LINE__); 114 this->bPlay = true; 115 } 116 117 /** 118 * Plays back buffer on this Source 119 if (this->retrieveSource()) 120 { 121 alSourcePlay(this->sourceID); 122 if (DEBUG >= 3) 123 SoundEngine::checkError("Play Source", __LINE__); 124 this->bPlay = true; 125 } 126 } 127 128 129 /** 130 * @brief Plays back buffer on this Source 119 131 * @param buffer the buffer to play back on this Source 120 132 */ 121 133 void SoundSource::play(const SoundBuffer* buffer) 122 134 { 123 if (unlikely(this->sourceID == 0)) 124 { 125 SoundEngine::getInstance()->popALSource(this->sourceID); 126 if (sourceID == 0) 127 { 128 PRINTF(2)("No more Free source\n"); 129 return; 130 } 131 } 132 // assert (this->sourceID != 0); 135 if (!this->retrieveSource()) 136 { 137 PRINTF(2)("No more Free sources (You might consider raising the Source-Count).\n"); 138 return; 139 } 133 140 134 141 alSourceStop(this->sourceID); … … 143 150 SoundEngine::checkError("Play Source", __LINE__); 144 151 } 152 145 153 146 154 /** … … 156 164 SoundEngine::checkError("StopSource", __LINE__); 157 165 alSourcei(this->sourceID, AL_BUFFER, 0); 158 SoundEngine::getInstance()->pushALSource(this->sourceID); 166 if (!this->resident) 167 SoundEngine::getInstance()->pushALSource(this->sourceID); 159 168 this->sourceID = 0; 160 169 } 161 170 } 162 171 172 163 173 /** 164 174 * @brief Pauses Playback of a SoundSource … … 171 181 } 172 182 183 173 184 /** 174 185 * @brief Rewinds Playback of a SoundSource … … 181 192 SoundEngine::checkError("Rewind Source", __LINE__); 182 193 } 194 183 195 184 196 /** … … 196 208 } 197 209 210 211 /** 212 * @brief sets the Positional this Source should be attached to. 213 * @param sourceNode the Source this is attached to. 214 * If sourceNode == NULL then the Source will be centered, and Audio will be played on all channels. 215 */ 216 void SoundSource::setSourceNode(const PNode* sourceNode) 217 { 218 this->sourceNode = sourceNode; 219 } 220 221 /** 222 * @brief retrieve a Source. 223 */ 224 bool SoundSource::retrieveSource() 225 { 226 if (this->sourceID != 0) 227 return true; 228 else 229 { 230 SoundEngine::getInstance()->popALSource(this->sourceID); 231 if (this->sourceID != 0) 232 { 233 if (unlikely(this->sourceNode == NULL)) 234 resetSource(this->sourceID); 235 return true; 236 } 237 } 238 return false; 239 } 240 241 242 /** 243 * @brief reset an alSource to its default Values. 244 */ 245 void SoundSource::resetSource(ALuint sourceID) 246 { 247 alSource3f(sourceID, AL_POSITION, 0.0, 0.0, 0.0); 248 alSource3f(sourceID, AL_VELOCITY, 0.0, 0.0, 0.0); 249 alSource3f(sourceID, AL_DIRECTION, 0.0, 0.0, 0.0); 250 alSourcef (sourceID, AL_ROLLOFF_FACTOR, 0.0 ); 251 alSourcei (sourceID, AL_SOURCE_RELATIVE, AL_TRUE ); 252 alSourcef (sourceID, AL_GAIN, SoundEngine::getInstance()->getEffectsVolume()); 253 } -
trunk/src/lib/sound/sound_source.h
r7299 r7317 34 34 // development functions 35 35 /** @returns The ID of this Source */ 36 inline ALuint getID() const { return this->sourceID; } 36 inline ALuint getID() const { return this->sourceID; }; 37 37 /** @returns true, if the Source is Playing */ 38 38 inline bool isPlaying() const { return this->bPlay; }; 39 /** @param sourceNode the Source this is attached to. */ 40 inline void setSourceNode(const PNode* sourceNode) { this->sourceNode = sourceNode;}; 39 void setSourceNode(const PNode* sourceNode); 41 40 /** @returns the SoundBuffer of this Source */ 42 inline const SoundBuffer* getBuffer() const { return this->buffer; } 41 inline const SoundBuffer* getBuffer() const { return this->buffer; }; 43 42 /** @returns the SourceNode of this Source */ 44 inline const PNode* getNode() const { return this->sourceNode;} 43 inline const PNode* getNode() const { return this->sourceNode; }; 44 /** @param resident if the Source is Resident */ 45 inline void setResident(bool resident) { this->resident = resident; }; 46 /** @returns true if the alSource is Resident */ 47 inline bool isResident() const { return this->resident; }; 45 48 46 49 void setRolloffFactor(ALfloat rolloffFactor); 47 50 51 static void resetSource(ALuint sourceID); 52 53 private: 54 bool retrieveSource(); 55 48 56 private: 49 57 bool bPlay; //!< If the Source is Playing. 58 bool resident; //!< If the alSource should be resident (if true, the alSource will be returned on deletion). 50 59 ALuint sourceID; //!< The ID of the Source 51 60 const SoundBuffer* buffer; //!< The buffer to play in this source. -
trunk/src/story_entities/simple_game_menu.cc
r7316 r7317 401 401 402 402 /** 403 * switches to from one meny layer to an other403 * @brief switches to from one meny layer to an other 404 404 * @param layer1 from layer 405 405 * @param layer2 to layer
Note: See TracChangeset
for help on using the changeset viewer.