Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7299 in orxonox.OLD for trunk/src/lib/sound/sound_source.cc


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

orxonox/trunk: some nice Class-Stuff

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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);
Note: See TracChangeset for help on using the changeset viewer.