Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7299 in orxonox.OLD


Ignore:
Timestamp:
Apr 16, 2006, 5:48:40 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: some nice Class-Stuff

Location:
trunk/src
Files:
7 edited

Legend:

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

    r7297 r7299  
    102102    return false;
    103103  }
     104  this->state |= FileOpened;
    104105
    105106  // acquiring the vorbis-properties.
    106107  vorbisInfo = ov_info(&oggStream, -1);
    107108  vorbisComment = ov_comment(&oggStream, -1);
    108   this->state |= FileOpened;
     109
    109110  if(vorbisInfo->channels == 1)
    110111    format = AL_FORMAT_MONO16;
     
    129130void OggPlayer::release()
    130131{
    131   this->printState();
    132132  if (this->state & SourceAllocated)
    133133  {
  • trunk/src/lib/sound/ogg_player.h

    r7295 r7299  
    1919
    2020
    21 #define BUFFER_SIZE (8096 * 16)
     21#define BUFFER_SIZE (8096 * 2)
    2222
    2323
  • trunk/src/lib/sound/sound_engine.cc

    r7298 r7299  
    3636//////////////////
    3737/**
    38  * standard constructor
     38 * @brief standard constructor
    3939*/
    4040SoundEngine::SoundEngine ()
     
    5959
    6060/**
    61  * the singleton reference to this class
     61 * @brief the singleton reference to this class
    6262*/
    6363SoundEngine* SoundEngine::singletonRef = NULL;
    6464
    6565/**
    66  *  standard deconstructor
     66 * @brief standard destructor
    6767 */
    6868SoundEngine::~SoundEngine ()
     
    105105
    106106/**
    107  * loads the settings of the SoundEngine from an ini-file
     107 * @brief loads the settings of the SoundEngine from an ini-file
    108108 */
    109109void SoundEngine::loadSettings()
     
    120120
    121121/**
    122  * creates a new SoundSource.
     122 * @brief creates a new SoundSource.
    123123 * @param fileName The Name to load the SoundBuffer from
    124124 * @param sourceNode The sourceNode to bind this SoundSource to.
     
    133133
    134134/**
    135  * Sets the doppler values of openAL
     135 * @brief Sets the doppler values of openAL
    136136 * @param dopplerFactor the extent of the doppler-effect
    137137 * @param dopplerVelocity the Speed the sound travels
     
    147147
    148148
     149/**
     150 * @brief retrieves an OpenAL Source from the availiable Sources.
     151 * @param source the Source to fill with the Value.
     152 */
    149153void SoundEngine::popALSource(ALuint& source)
    150154{
     
    158162    this->ALSources.pop();
    159163    SDL_mutexV(this->sourceMutex);
    160     printf("Retrieve Source %d\n", source);
    161   }
    162 }
    163 
     164  }
     165}
     166
     167
     168/**
     169 * @brief Pushes an OpenAL Source back into the Stack of known sources
     170 * @param source the Source to push onto the top of the SourceStack
     171 */
    164172void SoundEngine::pushALSource(ALuint& source)
    165173{
     
    174182
    175183/**
    176  * updates all The positions, Directions and Velocities of all Sounds
    177 */
     184 * @brief updates all The positions, Directions and Velocities of all Sounds
     185 */
    178186void SoundEngine::update()
    179187{
     
    239247}
    240248
    241 /**
    242  *  Removes all the Buffers that are not anymore needed by any Sources
    243 */
    244 void SoundEngine::flushUnusedBuffers()
    245 {
    246   /// FIXME
    247   /*  if(this->sourceList && this->bufferList)
    248     {
    249       tIterator<BaseObject>* bufferIterator = this->bufferList->getIterator();
    250       SoundBuffer* enumBuffer = (SoundBuffer*)bufferIterator->firstElement();
    251       while (enumBuffer)
    252       {
    253         tIterator<BaseObject>* sourceIterator = this->sourceList->getIterator();
    254         SoundSource* enumSource = (SoundSource*)sourceIterator->firstElement();
    255         while (enumSource)
    256         {
    257           if (enumBuffer == enumSource->getBuffer())
    258             break;
    259           enumSource = (SoundSource*)sourceIterator->nextElement();
    260         }
    261         delete sourceIterator;
    262         if (enumSource == NULL)
    263           ResourceManager::getInstance()->unload(enumBuffer);
    264         enumBuffer = (SoundBuffer*)bufferIterator->nextElement();
    265       }
    266       delete bufferIterator;
    267   }*/ /// FIXME
    268 }
    269 
    270 /**
    271  * flushes all the Buffers
    272  * deletes them from the BufferList, and also removes them via the ResourceManager.
    273  */
    274 void SoundEngine::flushAllBuffers()
    275 {
    276   if (this->bufferList)
    277   {
    278     while (this->bufferList->size() > 0)
    279       ResourceManager::getInstance()->unload(static_cast<SoundBuffer*>(this->bufferList->front()), RP_LEVEL);
    280   }
    281 }
    282 
    283 /**
    284  * deletes all the Sources.
    285  */
    286 void SoundEngine::flushAllSources()
    287 {
    288   if (this->sourceList)
    289   {
    290     while(this->sourceList->size() > 0)
    291       delete this->sourceList->front();
    292   }
    293 }
    294249
    295250/**
     
    378333}
    379334
     335/**
     336 * @brief checks for an OpenAL error
     337 * @param error the ErrorMessage to display
     338 * @param line on what line did the error occure.
     339 */
    380340bool SoundEngine::checkError(const std::string& error, unsigned int line)
    381341{
     
    390350}
    391351
     352/**
     353 * @brief check for an ALC error.
     354 * @brief error the Error-String to display
     355 * @param line on that line, the error occured (debugging mode).
     356 */
    392357bool SoundEngine::checkALCError(const std::string& error, unsigned int line)
    393358{
  • trunk/src/lib/sound/sound_engine.h

    r7298 r7299  
    5252    void pushALSource(ALuint& source);
    5353
    54     void flushUnusedBuffers();
    55     void flushAllBuffers();
    56     void flushAllSources();
    5754
    5855    bool initAudio();
  • trunk/src/lib/sound/sound_source.cc

    r7297 r7299  
    3131  this->setClassID(CL_SOUND_SOURCE, "SoundSource");
    3232
    33   ALenum result;
    34 
    3533  // adding the Source to the SourcesList of the SoundEngine
    3634  this->buffer = buffer;
     
    3937  this->sourceID = 0;
    4038  this->bPlay = false;
     39}
     40
     41/**
     42 * @brief construct a SoundSource out of the another soundSource
     43 * @param source the Source to create this source from.
     44 *
     45 * Copies the buffer from source to this Source.
     46 * Acquires a new SourceID if source is Playing.
     47 */
     48SoundSource::SoundSource(const SoundSource& source)
     49{
     50  this->setClassID(CL_SOUND_SOURCE, "SoundSource");
     51
     52  // adding the Source to the SourcesList of the SoundEngine
     53  this->buffer = source.buffer;
     54  this->sourceNode = source.sourceNode;
     55
     56  this->sourceID = 0;
     57  if (source.bPlay == true)
     58  {
     59    this->bPlay = true;
     60    SoundEngine::getInstance()->popALSource(this->sourceID);
     61  }
     62  else
     63    this->bPlay = false;
     64}
     65
     66/**
     67 * @brief paste a copy of the source into this Source.
     68 * @param source the SoundSource to paste into this one.
     69 * @returns a Reference to this Source.
     70 *
     71 */
     72SoundSource& SoundSource::operator=(const SoundSource& source)
     73{
     74  this->buffer = source.buffer;
     75  this->sourceNode = sourceNode;
     76
     77  if (source.bPlay)
     78    this->play();
     79  else
     80    this->stop();
     81}
     82
     83/**
     84 * @brief compares two Sources with each other.
     85 * @param source the Source to compare against this One.
     86 * Two Sources are the same, if the PNodes match, and the Sound Played are the same.
     87 * The alSource must not match, because no two Sources can have the same alSource.
     88 */
     89bool SoundSource::operator==(const SoundSource& source)
     90{
     91  return (this->buffer == source.buffer &&
     92          this->bPlay == source.bPlay &&
     93          this->sourceNode == source.sourceNode);
    4194}
    4295
     
    77130    }
    78131  }
    79 //  assert (this->sourceID != 0);
     132  //  assert (this->sourceID != 0);
    80133
    81134  alSourceStop(this->sourceID);
  • trunk/src/lib/sound/sound_source.h

    r7065 r7299  
    1919  public:
    2020    SoundSource(const PNode* sourceNode = NULL, const SoundBuffer* buffer = NULL);
     21    SoundSource(const SoundSource& source);
     22    SoundSource& operator=(const SoundSource& source);
     23    bool operator==(const SoundSource& source);
     24
    2125    virtual ~SoundSource();
    2226
  • trunk/src/story_entities/game_world_data.cc

    r7287 r7299  
    345345    this->setSoundTrack("");
    346346  this->music = NULL;
    347   /* stop the sound eninge */
    348   SoundEngine::getInstance()->flushAllBuffers();
    349   SoundEngine::getInstance()->flushAllSources();
    350347
    351348  /* unload the shaders */
Note: See TracChangeset for help on using the changeset viewer.