Changeset 6476 for code/branches/sound4
- Timestamp:
- Mar 6, 2010, 3:08:19 PM (15 years ago)
- Location:
- code/branches/sound4/src/orxonox/sound
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/sound4/src/orxonox/sound/AmbientSound.cc
r6417 r6476 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 } 143 175 } -
code/branches/sound4/src/orxonox/sound/AmbientSound.h
r6435 r6476 30 30 #ifndef _AmbientSound_H__ 31 31 #define _AmbientSound_H__ 32 33 #include <boost/thread.hpp> 32 34 33 35 #include "sound/SoundPrereqs.h" … … 83 85 std::string ambientSource_; //!< Analogous to source_, but mood independent 84 86 bool bPlayOnLoad_; //!< Play the sound immediately when loaded 87 88 boost::thread soundstreamthread_; // hacky solution for streaming 89 void setStreamSource(const std::string& source); 85 90 }; 86 91 } -
code/branches/sound4/src/orxonox/sound/SoundStreamer.cc
r6435 r6476 30 30 #include <vorbis/vorbisfile.h> 31 31 #include "SoundManager.h" 32 #include "util/Sleep.h" 32 33 33 34 namespace orxonox … … 121 122 COUT(2) << "Sound Warning: Couldn't queue buffers: " << getALErrorString(error) << std::endl; 122 123 } 124 msleep(250); // perhaps another value here is better 123 125 } 124 126 }
Note: See TracChangeset
for help on using the changeset viewer.