- Timestamp:
- Jan 30, 2006, 1:39:57 AM (19 years ago)
- Location:
- trunk/src/lib/sound
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/sound/ogg_player.cc
r6828 r6842 35 35 this->setClassID(CL_SOUND_OGG_PLAYER, "OggPlayer"); 36 36 37 this->trackLoaded = false; 37 38 this->source = 0; 39 this->buffers[0] = 0; 40 this->buffers[1] = 0; 38 41 39 42 if (fileName != NULL) 40 43 { 41 this->open(fileName);42 this->setName(fileName);44 if (this->open(fileName)) 45 this->setName(fileName); 43 46 } 44 47 } … … 48 51 * @param fileName the file to open 49 52 */ 50 void OggPlayer::open(const char* fileName) 51 { 53 bool OggPlayer::open(const char* fileName) 54 { 55 if (this->buffers[0] == 0) 56 alGenBuffers(2, this->buffers); 57 SoundEngine::checkError("Allocating Buffers", __LINE__); 58 59 if (this->source == 0) 60 SoundEngine::getInstance()->popALSource(this->source); 61 if (this->source == 0) 62 { 63 this->trackLoaded = false; 64 return false; 65 } 66 printf("OK\n"); 67 52 68 int result; 53 69 … … 69 85 else 70 86 format = AL_FORMAT_STEREO16; 71 72 73 alGenBuffers(2, buffers);74 check();75 SoundEngine::getInstance()->popALSource(this->source);76 check();77 87 78 88 alSource3f(source, AL_POSITION, 0.0, 0.0, 0.0); … … 82 92 alSourcei (source, AL_SOURCE_RELATIVE, AL_TRUE ); 83 93 alSourcef (source, AL_GAIN, SoundEngine::getInstance()->getMusicVolume()); 94 95 this->trackLoaded = true; 96 return true; 84 97 } 85 98 … … 92 105 empty(); 93 106 SoundEngine::getInstance()->pushALSource(source); 107 this->source = 0; 94 108 check(); 95 alDeleteBuffers(1, buffers); 109 alDeleteBuffers(2, buffers); 110 this->buffers[0] = 0; 111 this->buffers[1] = 0; 96 112 check(); 97 113 98 114 ov_clear(&oggStream); 115 this->trackLoaded = false; 99 116 } 100 117 … … 106 123 bool OggPlayer::playback() 107 124 { 125 if (!this->trackLoaded) 126 return false; 127 108 128 if(playing()) 109 129 return true; … … 127 147 bool OggPlayer::playing() 128 148 { 149 if (!this->trackLoaded) 150 return false; 129 151 ALenum state; 130 152 … … 140 162 bool OggPlayer::update() 141 163 { 164 if (!this->trackLoaded) 165 return false; 166 142 167 int processed; 143 168 bool active = true; … … 233 258 { 234 259 cout 235 236 237 238 239 240 241 242 243 260 << "version " << vorbisInfo->version << "\n" 261 << "channels " << vorbisInfo->channels << "\n" 262 << "rate (hz) " << vorbisInfo->rate << "\n" 263 << "bitrate upper " << vorbisInfo->bitrate_upper << "\n" 264 << "bitrate nominal " << vorbisInfo->bitrate_nominal << "\n" 265 << "bitrate lower " << vorbisInfo->bitrate_lower << "\n" 266 << "bitrate window " << vorbisInfo->bitrate_window << "\n" 267 << "\n" 268 << "vendor " << vorbisComment->vendor << "\n"; 244 269 245 270 for(int i = 0; i < vorbisComment->comments; i++) -
trunk/src/lib/sound/ogg_player.h
r6828 r6842 29 29 OggPlayer(const char* fileName = NULL); 30 30 31 voidopen(const char* fileName);31 bool open(const char* fileName); 32 32 void release(); 33 33 void debug(); … … 53 53 ALuint source; //!< The source we play back on 54 54 ALenum format; //!< The format we play back 55 bool trackLoaded; //!< If a Track has been loaded. 55 56 }; 56 57 -
trunk/src/lib/sound/sound_engine.cc
r6840 r6842 337 337 338 338 alGenSources(1, &source); 339 printf("%d %d\n", i, source);340 339 this->checkError("allocate Source", __LINE__); 340 if (!alIsSource(source)) 341 { 342 PRINTF(2)("not allocated Source\n"); 343 continue; 344 } 341 345 342 346 alSourcef (source, AL_PITCH, 1.0 );
Note: See TracChangeset
for help on using the changeset viewer.