Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9686 in orxonox.OLD for branches/new_class_id/src/lib/sound


Ignore:
Timestamp:
Aug 22, 2006, 2:36:54 PM (18 years ago)
Author:
bensch
Message:

new_class_id: many more classes done

Location:
branches/new_class_id/src/lib/sound
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/sound/ogg_player.cc

    r9406 r9686  
    4949namespace OrxSound
    5050{
     51  NewObjectListDefinition(OggPlayer);
    5152  /**
    5253   * initializes an Ogg-player from a file
     
    5556  OggPlayer::OggPlayer(const std::string& fileName)
    5657  {
    57     this->setClassID(CL_SOUND_OGG_PLAYER, "OggPlayer");
     58    this->registerObject(this, OggPlayer::_objectList);
    5859
    5960    this->state = OggPlayer::None;
  • branches/new_class_id/src/lib/sound/ogg_player.h

    r9019 r9686  
    2525  class OggPlayer : public BaseObject
    2626  {
     27    NewObjectListDeclaration(OggPlayer);
     28
    2729  public:
    2830    /**
  • branches/new_class_id/src/lib/sound/sound_buffer.cc

    r8971 r9686  
    3535namespace OrxSound
    3636{
     37  NewObjectListDefinition(SoundBuffer);
    3738  //////////////////
    3839  /* SOUND-BUFFER */
     
    4445  SoundBuffer::SoundBuffer(const std::string& fileName)
    4546  {
    46     this->setClassID(CL_SOUND_BUFFER, "SoundBuffer");
     47    this->registerObject(this, SoundBuffer::_objectList);
    4748    this->setName(fileName);
    4849
  • branches/new_class_id/src/lib/sound/sound_buffer.h

    r8969 r9686  
    1818  class SoundBuffer : public BaseObject
    1919  {
     20    NewObjectListDeclaration(SoundBuffer);
    2021  public:
    2122    SoundBuffer(const std::string& fileName);
  • branches/new_class_id/src/lib/sound/sound_engine.cc

    r9235 r9686  
    2020
    2121#include "sound_engine.h"
    22 
    23 #include "class_list.h"
    2422
    2523#include "p_node.h"
     
    3129namespace OrxSound
    3230{
    33 
     31  NewObjectListDefinition(SoundEngine);
    3432  //////////////////
    3533  /* SOUND-ENGINE */
     
    4038  SoundEngine::SoundEngine ()
    4139  {
    42     this->setClassID(CL_SOUND_ENGINE, "SoundEngine");
     40    this->registerObject(this, SoundEngine::_objectList);
    4341    this->setName("SoundEngine");
    4442
    4543    this->listener = NULL;
    46     this->bufferList = NULL;
    47     this->sourceList = NULL;
    4844
    4945    this->device = NULL;
     
    6965  {
    7066    // deleting all the SoundSources
    71     if(this->sourceList != NULL)
    72     {
    73       while (this->sourceList->size() > 0)
    74         delete static_cast<SoundSource*>(this->sourceList->front());
    75     }
     67    while (!SoundSource::objectList().empty())
     68      delete (SoundSource::objectList().front());
    7669
    7770    while(!this->ALSources.empty())
     
    8982
    9083    // deleting all the SoundBuffers
    91     if (this->bufferList != NULL)
    92     {
    93       while(this->bufferList->size() > 0)
    94         ResourceManager::getInstance()->unload(static_cast<SoundBuffer*>(this->bufferList->front()));
    95     }
     84    while(!SoundBuffer::objectList().empty())
     85      ResourceManager::getInstance()->unload(SoundBuffer::objectList().front());
    9686
    9787    // removing openAL from AudioResource
     
    212202
    213203    // updating all the Sources positions
    214     if (likely(this->sourceList != NULL || (this->sourceList = ClassList::getList(CL_SOUND_SOURCE)) != NULL))
    215     {
    216       std::list<BaseObject*>::const_iterator sourceIT;
    217       SoundSource* source;
    218       for (sourceIT = this->sourceList->begin(); sourceIT != this->sourceList->end(); sourceIT++)
     204    NewObjectList<SoundSource>::const_iterator sourceIT;
     205    for (sourceIT = SoundSource::objectList().begin();
     206         sourceIT != SoundSource::objectList().end();
     207         sourceIT++)
     208    {
     209      if ((*sourceIT)->isPlaying())
    219210      {
    220         source = static_cast<SoundSource*>(*sourceIT);
    221         if (source->isPlaying())
     211        int play = 0x000;
     212        alGetSourcei((*sourceIT)->getID(), AL_SOURCE_STATE, &play);
     213        if (DEBUG_LEVEL > 2)
     214          SoundEngine::checkError("SoundEngine::update() Play", __LINE__);
     215        if(play == AL_PLAYING)
    222216        {
    223           int play = 0x000;
    224           alGetSourcei(source->getID(), AL_SOURCE_STATE, &play);
    225           if (DEBUG_LEVEL > 2)
    226             SoundEngine::checkError("SoundEngine::update() Play", __LINE__);
    227           if(play == AL_PLAYING)
     217          if (likely((*sourceIT)->getNode() != NULL))
    228218          {
    229             if (likely(source->getNode() != NULL))
    230             {
    231               alSource3f(source->getID(), AL_POSITION,
    232                          source->getNode()->getAbsCoor().x,
    233                          source->getNode()->getAbsCoor().y,
    234                          source->getNode()->getAbsCoor().z);
    235               if (DEBUG_LEVEL > 2)
    236                 SoundEngine::checkError("SoundEngine::update() Set Source Position", __LINE__);
    237               alSource3f(source->getID(), AL_VELOCITY,
    238                          source->getNode()->getVelocity().x,
    239                          source->getNode()->getVelocity().y,
    240                          source->getNode()->getVelocity().z);
    241               if (DEBUG_LEVEL > 2)
    242                 SoundEngine::checkError("SoundEngine::update() Set Source Velocity", __LINE__);
    243             }
     219            alSource3f((*sourceIT)->getID(), AL_POSITION,
     220                       (*sourceIT)->getNode()->getAbsCoor().x,
     221                       (*sourceIT)->getNode()->getAbsCoor().y,
     222                       (*sourceIT)->getNode()->getAbsCoor().z);
     223            if (DEBUG_LEVEL > 2)
     224              SoundEngine::checkError("SoundEngine::update() Set Source Position", __LINE__);
     225            alSource3f((*sourceIT)->getID(), AL_VELOCITY,
     226                       (*sourceIT)->getNode()->getVelocity().x,
     227                       (*sourceIT)->getNode()->getVelocity().y,
     228                       (*sourceIT)->getNode()->getVelocity().z);
     229            if (DEBUG_LEVEL > 2)
     230              SoundEngine::checkError("SoundEngine::update() Set Source Velocity", __LINE__);
    244231          }
    245           else
    246           {
    247             source->stop();
    248           }
     232        }
     233        else
     234        {
     235          (*sourceIT)->stop();
    249236        }
    250237      }
     
    393380      default:
    394381      case AL_NO_ERROR:
    395         return ("AL_NO_ERROR");
     382      return ("AL_NO_ERROR");
    396383      case AL_INVALID_NAME:
    397         return ("AL_INVALID_NAME");
     384      return ("AL_INVALID_NAME");
    398385      case AL_INVALID_ENUM:
    399         return ("AL_INVALID_ENUM");
     386      return ("AL_INVALID_ENUM");
    400387      case AL_INVALID_VALUE:
    401         return ("AL_INVALID_VALUE");
     388      return ("AL_INVALID_VALUE");
    402389      case AL_INVALID_OPERATION:
    403         return ("AL_INVALID_OPERATION");
     390      return ("AL_INVALID_OPERATION");
    404391      case AL_OUT_OF_MEMORY:
    405         return ("AL_OUT_OF_MEMORY");
     392      return ("AL_OUT_OF_MEMORY");
    406393    };
    407394  }
     
    414401      default:
    415402      case ALC_NO_ERROR:
    416         return ("AL_NO_ERROR");
     403      return ("AL_NO_ERROR");
    417404      case ALC_INVALID_DEVICE:
    418         return ("ALC_INVALID_DEVICE");
     405      return ("ALC_INVALID_DEVICE");
    419406      case ALC_INVALID_CONTEXT:
    420         return("ALC_INVALID_CONTEXT");
     407      return("ALC_INVALID_CONTEXT");
    421408      case ALC_INVALID_ENUM:
    422         return("ALC_INVALID_ENUM");
     409      return("ALC_INVALID_ENUM");
    423410      case ALC_INVALID_VALUE:
    424         return ("ALC_INVALID_VALUE");
     411      return ("ALC_INVALID_VALUE");
    425412      case ALC_OUT_OF_MEMORY:
    426         return("ALC_OUT_OF_MEMORY");
     413      return("ALC_OUT_OF_MEMORY");
    427414    };
    428415  }
  • branches/new_class_id/src/lib/sound/sound_engine.h

    r7847 r9686  
    2727  class SoundEngine : public BaseObject
    2828  {
    29   public:
     29    NewObjectListDeclaration(SoundEngine);
     30    public:
    3031    virtual ~SoundEngine();
    3132    /** @returns a Pointer to the only object of this Class */
     
    7576    const PNode*                   listener;                 //!< The listener of the Scene
    7677
    77     const std::list<BaseObject*>*  bufferList;               //!< A list of buffers
    78     const std::list<BaseObject*>*  sourceList;               //!< A list for all the sources in the scene.
    79 
    8078    unsigned int                   maxSourceCount;           //!< How many Sources is the Maximum
    8179    std::stack<ALuint>             ALSources;                //!< A list of real openAL-Sources, the engine allocates, and stores for reuse.
  • branches/new_class_id/src/lib/sound/sound_source.cc

    r8969 r9686  
    2525namespace OrxSound
    2626{
     27  NewObjectListDefinition(SoundSource);
    2728  /**
    2829  * @brief creates a SoundSource at position sourceNode with the SoundBuffer buffer
     
    3031  SoundSource::SoundSource(const PNode* sourceNode, const SoundBuffer* buffer)
    3132  {
    32     this->setClassID(CL_SOUND_SOURCE, "SoundSource");
    33 
     33    this->registerObject(this, SoundSource::_objectList);
    3434    // adding the Source to the SourcesList of the SoundEngine
    3535    this->buffer = buffer;
     
    5151  SoundSource::SoundSource(const SoundSource& source)
    5252  {
    53     this->setClassID(CL_SOUND_SOURCE, "SoundSource");
     53    this->registerObject(this, SoundSource::_objectList);
    5454
    5555    // adding the Source to the SourcesList of the SoundEngine
  • branches/new_class_id/src/lib/sound/sound_source.h

    r8793 r9686  
    1818  class SoundSource : public BaseObject
    1919  {
     20    NewObjectListDeclaration(SoundSource);
    2021  public:
    2122    SoundSource(const PNode* sourceNode = NULL, const SoundBuffer* buffer = NULL);
Note: See TracChangeset for help on using the changeset viewer.