Changeset 6733 for code/branches/sound5
- Timestamp:
- Apr 15, 2010, 3:42:24 PM (15 years ago)
- Location:
- code/branches/sound5/src/orxonox/sound
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/sound5/src/orxonox/sound/AmbientSound.cc
r6730 r6733 183 183 if(this->soundstreamthread_ == boost::thread()) 184 184 COUT(2) << "Sound: Failed to create thread." << std::endl; 185 186 if (alIsSource(this->audioSource_)) // already playing or paused 187 { 188 // Sound was already playing or paused because there was a source acquired 189 assert(this->isPlaying() || this->isPaused()); 190 alSourcePlay(this->audioSource_); 191 if (int error = alGetError()) 192 COUT(2) << "Sound: Error playing sound: " << getALErrorString(error) << std::endl; 193 if (this->isPaused()) 194 alSourcePause(this->audioSource_); 195 } 196 else // No source acquired so far, but might be set to playing or paused 197 { 198 if (this->isPlaying() || this->isPaused()) 199 doPlay(); 200 if (this->isPaused()) 201 { 202 doPause(); 203 } 204 } 205 206 this->updateVolume(); 207 this->setPitch(this->getPitch()); 208 this->setLooping(this->getLooping()); 185 209 186 alSource3f(this->audioSource_, AL_POSITION, 0, 0, 0); 210 187 alSource3f(this->audioSource_, AL_VELOCITY, 0, 0, 0); -
code/branches/sound5/src/orxonox/sound/SoundStreamer.cc
r6729 r6733 44 44 { 45 45 COUT(4) << "Sound: Creating thread for " << dataStream->getName() << std::endl; 46 47 alSourcei(audioSource, AL_BUFFER, 0); 48 46 49 // Open file with custom streaming 47 50 ov_callbacks vorbisCallbacks; … … 101 104 } 102 105 106 alSourcei(audioSource, AL_LOOPING, AL_TRUE); 107 108 alSourcePlay(audioSource); 109 if(ALint error = alGetError()) 110 COUT(2) << "Sound: Could not start ambient sound" << std::endl; 111 103 112 while(true) // Stream forever, control through thread control 104 113 { 105 int processed; 114 115 int info; 116 alGetSourcei(audioSource, AL_SOURCE_STATE, &info); 117 if(info == AL_PLAYING) 118 COUT(4) << "Sound: " << dataStream->getName() << " is playing." << std::endl; 119 else 120 COUT(4) << "Sound: " << dataStream->getName() << " is not playing." << std::endl; 106 121 107 122 if(alcGetCurrentContext() == NULL) … … 111 126 } 112 127 128 int processed; 113 129 alGetSourcei(audioSource, AL_BUFFERS_PROCESSED, &processed); 114 130 if (ALint error = alGetError()) 115 131 COUT(2) << "Sound: Warning: Couldn't get number of processed buffers: " << getALErrorString(error) << std::endl; 132 COUT(4) << "Sound: processed buffers: " << processed << std::endl; 116 133 117 134 if(processed > 0) 118 135 { 119 COUT(4) << "Sound: " << processed << std::endl;120 136 ALuint* buffers = new ALuint[processed]; 121 137 alSourceUnqueueBuffers(audioSource, processed, buffers); 122 138 if (ALint error = alGetError()) 123 139 COUT(2) << "Sound: Warning: Couldn't unqueue buffers: " << getALErrorString(error) << std::endl; 124 125 int info;126 alGetSourcei(audioSource, AL_SOURCE_STATE, &info);127 if(info == AL_PLAYING)128 COUT(4) << "Sound: " << dataStream->getName() << " is playing." << std::endl;129 else130 COUT(4) << "Sound: " << dataStream->getName() << " is not playing." << std::endl;131 140 132 141 for(int i = 0; i < processed; i++) … … 171 180 return; 172 181 } 173 msleep( 100); // perhaps another value here is better182 msleep(50); // perhaps another value here is better 174 183 } 175 184 }
Note: See TracChangeset
for help on using the changeset viewer.