Changeset 7737 in orxonox.OLD for trunk/src/lib/sound
- Timestamp:
- May 19, 2006, 11:38:34 PM (19 years ago)
- Location:
- trunk/src/lib/sound
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/sound/ogg_player.cc
r7729 r7737 48 48 this->buffers[1] = 0; 49 49 this->musicThreadID = NULL; 50 this->musicMutex = SDL_CreateMutex();51 50 52 51 if (!fileName.empty()) … … 64 63 { 65 64 this->release(); 66 SDL_DestroyMutex(this->musicMutex);67 65 } 68 66 … … 76 74 bool OggPlayer::open(const std::string& fileName) 77 75 { 78 MutexLock(this->musicMutex);76 OrxThread::MutexLock musicLock(&this->musicMutex); 79 77 // release old Ogg-File (if loaded) 80 78 if (this->state & OggPlayer::FileOpened) … … 208 206 if (this->state & OggPlayer::FileOpened) 209 207 { 210 SDL_mutexP(this->musicMutex);208 OrxThread::MutexLock musicLock(&this->musicMutex); 211 209 ov_time_seek(&this->oggStream, timeCode); 212 SDL_mutexV(this->musicMutex);213 210 } 214 211 } … … 259 256 while (ogg->state & OggPlayer::Playing) 260 257 { 261 SDL_mutexP(ogg->musicMutex); 262 ogg->update(); 263 SDL_mutexV(ogg->musicMutex); 258 { 259 OrxThread::MutexLock musicLock(&ogg->musicMutex); 260 ogg->update(); 261 } 264 262 SDL_Delay(1); 265 263 } … … 281 279 this->state |= OggPlayer::Playing; 282 280 283 SDL_mutexP(this->musicMutex);281 OrxThread::MutexLock musicLock(&this->musicMutex); 284 282 if(!this->stream(this->buffers[0]) || !this->stream(this->buffers[1])) 285 283 { 286 SDL_mutexV(this->musicMutex);287 284 this->state &= ~OggPlayer::Playing; 288 285 return false; … … 296 293 if (DEBUG_LEVEL >= 3) 297 294 SoundEngine::checkError("OggPlayer::playback()::alSourcePlay", __LINE__); 298 SDL_mutexV(this->musicMutex);299 295 return true; 300 296 } … … 502 498 switch(code) 503 499 { 504 case OV_EREAD:505 return ("Read from media.");506 case OV_ENOTVORBIS:507 return ("Not Vorbis data.");508 case OV_EVERSION:509 return ("Vorbis version mismatch.");510 case OV_EBADHEADER:511 return ("Invalid Vorbis header.");512 case OV_EFAULT:513 return ("Internal logic fault (bug or heap/stack corruption.");514 default:515 return ("Unknown Ogg error.");500 case OV_EREAD: 501 return ("Read from media."); 502 case OV_ENOTVORBIS: 503 return ("Not Vorbis data."); 504 case OV_EVERSION: 505 return ("Vorbis version mismatch."); 506 case OV_EBADHEADER: 507 return ("Invalid Vorbis header."); 508 case OV_EFAULT: 509 return ("Internal logic fault (bug or heap/stack corruption."); 510 default: 511 return ("Unknown Ogg error."); 516 512 } 517 513 } -
trunk/src/lib/sound/ogg_player.h
r7460 r7737 87 87 88 88 SDL_Thread* musicThreadID; //!< The Thread in which music is Played back. 89 SDL_mutex*musicMutex; //!< A Mutex so that the two threads do not interfere.89 OrxThread::Mutex musicMutex; //!< A Mutex so that the two threads do not interfere. 90 90 }; 91 91
Note: See TracChangeset
for help on using the changeset viewer.