Changeset 6733 for code/branches/sound5/src/orxonox/sound/SoundStreamer.cc
- Timestamp:
- Apr 15, 2010, 3:42:24 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.