Changeset 6506 for code/branches/sound5/src/orxonox/sound/AmbientSound.cc
- Timestamp:
- Mar 11, 2010, 3:16:12 PM (14 years ago)
- Location:
- code/branches/sound5
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/sound5
- Property svn:mergeinfo changed
/code/branches/sound4 (added) merged: 6435,6476,6504
- Property svn:mergeinfo changed
-
code/branches/sound5/src/orxonox/sound/AmbientSound.cc
r6417 r6506 35 35 #include "core/XMLPort.h" 36 36 #include "SoundManager.h" 37 #include "SoundStreamer.h" 37 38 38 39 namespace orxonox … … 120 121 shared_ptr<ResourceInfo> fileInfo = Resource::getInfo(path); 121 122 if (fileInfo != NULL) 122 this->setS ource(path);123 this->setStreamSource(path); 123 124 else 124 125 COUT(3) << "Sound: " << this->ambientSource_ << ": Not a valid name! Ambient sound will not change." << std::endl; … … 141 142 this->stop(); 142 143 } 144 145 // hacky solution for file streaming 146 void AmbientSound::setStreamSource(const std::string& source) 147 { 148 this->audioSource_ = SoundManager::getInstance().getSoundSource(this); 149 if (this->source_ == source) 150 { 151 return; 152 } 153 154 this->source_ = source; 155 // Don't load "" 156 if (source_.empty()) 157 return; 158 159 if (this->soundstreamthread_.get_id() != boost::thread::id()) 160 { 161 this->soundstreamthread_.interrupt(); // unhandled interruptions lead to thread terminating ;-) 162 } 163 // Get resource info 164 shared_ptr<ResourceInfo> fileInfo = Resource::getInfo(source); 165 if (fileInfo == NULL) 166 { 167 COUT(2) << "Sound: Warning: Sound file '" << source << "' not found" << std::endl; 168 return; 169 } 170 // Open data stream 171 DataStreamPtr dataStream = Resource::open(fileInfo); 172 173 this->soundstreamthread_ = boost::thread(SoundStreamer(), this->audioSource_, dataStream); 174 this->initialiseSource(); 175 } 176 177 void AmbientSound::doStop() 178 { 179 SUPER(AmbientSound, doStop); 180 this->soundstreamthread_.interrupt(); 181 } 143 182 }
Note: See TracChangeset
for help on using the changeset viewer.