Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7298 in orxonox.OLD for trunk/src/lib


Ignore:
Timestamp:
Apr 15, 2006, 10:00:35 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: secured the sources-list with a fancy mutex. This should prevent source-stack-errors… (if they would ever occure )

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

Legend:

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

    r7292 r7298  
    5454  this->effectsVolume = .80;
    5555  this->musicVolume = .75;
     56
     57  this->sourceMutex = SDL_CreateMutex();
    5658}
    5759
     
    9799  //alutExit();
    98100
     101  SDL_DestroyMutex(this->sourceMutex);
     102
    99103  SoundEngine::singletonRef = NULL;
    100104}
     
    150154  if (!this->ALSources.empty())
    151155  {
     156    SDL_mutexP(this->sourceMutex);
    152157    source = this->ALSources.top();
    153158    this->ALSources.pop();
     159    SDL_mutexV(this->sourceMutex);
    154160    printf("Retrieve Source %d\n", source);
    155161  }
    156162}
     163
     164void SoundEngine::pushALSource(ALuint& source)
     165{
     166  if (source != 0)
     167  {
     168    SDL_mutexP(this->sourceMutex);
     169    this->ALSources.push(source);
     170    SDL_mutexV(this->sourceMutex);
     171  }
     172};
    157173
    158174
  • trunk/src/lib/sound/sound_engine.h

    r7256 r7298  
    1515#include <list>
    1616#include <stack>
     17#include <SDL_thread.h>
    1718
    1819#define SOUND_DOPPLER_FACTOR       0.001          //!< A factor for the audible doppler effect
     
    4950  // administrative
    5051    void popALSource(ALuint& source);
    51     void pushALSource(ALuint& source) { if (source != 0) this->ALSources.push(source); };
     52    void pushALSource(ALuint& source);
    5253
    5354    void flushUnusedBuffers();
     
    8485    unsigned int                   maxSourceCount;           //!< How many Sources is the Maximum
    8586    std::stack<ALuint>             ALSources;                //!< A list of real openAL-Sources, the engine allocates, and stores for reuse.
     87
     88    SDL_mutex*                     sourceMutex;              //!< A mutex so we can not harm the stack
    8689};
    8790
Note: See TracChangeset for help on using the changeset viewer.