Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 7, 2005, 4:16:51 PM (18 years ago)
Author:
patrick
Message:

network: merged the trunk into the network with the command svn merge -r5824:HEAD ../trunk network, changes changed… bla bla..

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/lib/sound/sound_source.cc

    r5386 r5968  
    1818#include "sound_source.h"
    1919#include "sound_engine.h"
     20
    2021#include "alincl.h"
    2122#include "compiler.h"
     
    3334
    3435  // adding the Source to the SourcesList of the SoundEngine
    35   SoundEngine::getInstance()->addSource(this);
    36 
    3736  this->buffer = buffer;
    3837  this->sourceNode = sourceNode;
    3938
    40   alGenSources(1, &this->sourceID);
    41   if ((result = alGetError()) != AL_NO_ERROR)
    42     SoundEngine::PrintALErrorString(result);
    43   if (this->buffer != NULL)
    44     alSourcei (this->sourceID, AL_BUFFER,   this->buffer->getID());
    45   alSourcef (this->sourceID, AL_PITCH,    1.0      );
    46   alSourcef (this->sourceID, AL_GAIN,     SoundEngine::getInstance()->getEffectsVolume() );
    47   alSourcei (sourceID, AL_LOOPING,  AL_FALSE     );
     39  this->sourceID = 0;
     40  this->bPlay = false;
    4841}
    4942
     
    5346SoundSource::~SoundSource()
    5447{
    55   //SoundEngine::getInstance()->removeSource(this);
    56   alDeleteSources(1, &this->sourceID);
     48  SoundEngine::getInstance()->pushALSource(this->sourceID);
    5749}
    5850
     
    6254void SoundSource::play()
    6355{
     56  if (this->sourceID == 0)
     57    SoundEngine::getInstance()->popALSource(this->sourceID);
    6458  alSourcePlay(this->sourceID);
     59  this->bPlay = true;
    6560}
    6661
     
    7166void SoundSource::play(const SoundBuffer* buffer)
    7267{
     68  if (unlikely(this->sourceID == 0))
     69    SoundEngine::getInstance()->popALSource(this->sourceID);
     70
     71  printf("%d\n",sourceID);
    7372  alSourceStop(this->sourceID);
    7473  alSourcei (this->sourceID, AL_BUFFER, buffer->getID());
     
    7776  if (unlikely(this->buffer != NULL))
    7877    alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
     78  this->bPlay = true;
    7979}
    8080
     
    8484void SoundSource::stop()
    8585{
     86  this->bPlay = false;
    8687  alSourceStop(this->sourceID);
     88  SoundEngine::getInstance()->pushALSource(this->sourceID);
    8789}
    8890
Note: See TracChangeset for help on using the changeset viewer.