Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7310 in orxonox.OLD


Ignore:
Timestamp:
Apr 17, 2006, 12:07:57 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: added a simple class MutexLock, that acts as a ScopeThreadMutex

Location:
trunk/src/lib/sound
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/sound/ogg_player.cc

    r7309 r7310  
    6969bool OggPlayer::open(const std::string& fileName)
    7070{
     71  MutexLock(this->musicMutex);
    7172  // release old Ogg-File (if loaded)
    7273  if (this->state & OggPlayer::FileOpened)
     
    300301  {
    301302    assert (!(this->state & Playing));
    302     this->printState();
    303303    SDL_WaitThread(this->musicThreadID, NULL);
    304304    this->musicThreadID = NULL;
     
    389389    if (this->state & OggPlayer::Playing);
    390390    {
     391      // Kill the Music Thread.
    391392      this->state &= ~OggPlayer::Playing;
    392       // Kill the Music Thread.
    393       if (this->musicThreadID != NULL)
    394         this->suspend();
     393      this->suspend();
    395394
    396395      SoundEngine::checkError("OggPlayer::release()::alSourceStop", __LINE__);
  • trunk/src/lib/sound/ogg_player.h

    r7309 r7310  
    8989  SDL_Thread*         musicThreadID;        //!< The Thread in which music is Played back.
    9090  SDL_mutex*          musicMutex;           //!< A Mutex so that the two threads do not interfere.
     91
     92  class MutexLock
     93  {
     94  public:
     95    MutexLock(SDL_mutex* mutex) { SDL_mutexP(mutex); this->mutex = mutex; };
     96    ~MutexLock() { SDL_mutexV(mutex); };
     97  private:
     98    SDL_mutex* mutex;
     99  };
    91100};
    92101
Note: See TracChangeset for help on using the changeset viewer.