Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9805 in orxonox.OLD for branches/new_class_id/src/lib


Ignore:
Timestamp:
Sep 24, 2006, 3:21:12 PM (18 years ago)
Author:
bensch
Message:

orxonox/new_class_id: SoundSource completely added as a Resource

Location:
branches/new_class_id/src/lib
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/lang/base_object.cc

    r9730 r9805  
    4545  for (it = this->_classes.begin(); it != this->_classes.end(); ++it)
    4646  {
     47    PRINTF(5)("DELETING OBJECT %s::%s FROM %s\n", this->getClassCName(), getCName(), (*it)._objectList->name().c_str());
    4748    (*it)._objectList->unregisterObject((*it)._iterator);
    4849    delete (*it)._iterator;
  • branches/new_class_id/src/lib/lang/object_list.cc

    r9757 r9805  
    272272         ++it)
    273273    {
    274       printf("   + %s::%s\n", (*it)->getClassCName(), (*it)->getCName());
     274      printf("   + %s::%s (%p)\n", (*it)->getClassCName(), (*it)->getCName(), (*it));
    275275    }
    276276  }
  • branches/new_class_id/src/lib/shell/some_shell_commands.cc

    r9800 r9805  
    6767    ->setAlias("orxoquit");
    6868
     69#include "object_list.h"
     70SHELL_COMMAND_STATIC(debugAll, ObjectListBase, &ObjectListBase::debugAll);
  • branches/new_class_id/src/lib/sound/sound_buffer.cc

    r9804 r9805  
    2020namespace OrxSound
    2121{
    22   ObjectListDefinition(SoundBuffer);
    2322  //////////////////
    2423  /* SOUND-BUFFER */
    2524  //////////////////
    2625  SoundBuffer::SoundBuffer()
    27   : data(new SoundBufferData)
     26      : data(new SoundBufferData)
    2827  {
    29     this->registerObject(this, SoundBuffer::_objectList);
    3028  }
    3129  /**
     
    3432   */
    3533  SoundBuffer::SoundBuffer(const std::string& fileName)
    36   : data(new SoundBufferData)
     34      : data(new SoundBufferData)
    3735  {
    38     this->registerObject(this, SoundBuffer::_objectList);
    39     this->setName(fileName);
    40 
    4136    this->load(fileName);
    4237  }
     38
     39  SoundBuffer::SoundBuffer(const SoundBuffer& buffer)
     40      : data(buffer.data)
     41  {  }
     42
     43  SoundBuffer::SoundBuffer(const SoundBufferData::Pointer& dataPointer)
     44      : data(dataPointer)
     45  {  };
    4346}
  • branches/new_class_id/src/lib/sound/sound_buffer.h

    r9804 r9805  
    77#define _SOUND_BUFFER_H
    88
    9 #include "base_object.h"
    10 #include "alincl.h"
    11 
    129#include "sound_buffer_data.h"
    1310
     
    1512{
    1613  //! A class that represents a datastructure to play Sounds.
    17   class SoundBuffer : public BaseObject
     14  class SoundBuffer
    1815  {
    19     ObjectListDeclaration(SoundBuffer);
    2016  public:
    2117    SoundBuffer();
    22     SoundBuffer(const SoundBuffer& buffer) { this->data = buffer.data; }
    23     SoundBuffer(const SoundBufferData::Pointer& dataPointer) { this->data = dataPointer; };
     18    SoundBuffer(const SoundBuffer& buffer);
     19    SoundBuffer(const SoundBufferData::Pointer& dataPointer);
    2420    SoundBuffer(const std::string& fileName);
     21
     22    bool operator==(const SoundBuffer& buffer) const {return this->data == buffer.data; };
    2523
    2624    /** @see SoundBufferData::load */
     
    3331    /** @returns the ID of the buffer used in this SoundBuffer */
    3432    inline ALuint getID() const { return this->data->getID(); }
     33    inline bool loaded() const { return this->data->loaded(); }
    3534
    3635    /** @returns the DataPointer */
     
    3837    /** @param dataPointer the data to acquire @brief Buffer shall acquire dataPointers data */
    3938    void acquireData(const SoundBufferData::Pointer& dataPointer)  { data = dataPointer; };
     39
    4040  private:
    41     SoundBufferData::Pointer    data;
     41    SoundBufferData::Pointer    data;                //!< Pointer to the Stored Data
    4242  };
    4343}
  • branches/new_class_id/src/lib/sound/sound_buffer_data.cc

    r9803 r9805  
    5050    this->size = 0;
    5151    this->loop = AL_FALSE;
    52 
    53 
     52    this->bLoaded = false;
    5453  }
    5554
     
    112111    SDL_FreeWAV(wavBuffer);
    113112    if (SoundEngine::checkError("Could not load Wave file", __LINE__))
     113    {
     114      this->bLoaded = true;
    114115      return true;
     116    }
    115117    else
    116118      return false;
     
    160162      return false;
    161163
     164    this->bLoaded = true;
    162165    return true ;
    163 
    164166  }
    165167
  • branches/new_class_id/src/lib/sound/sound_buffer_data.h

    r9803 r9805  
    3333    /** @returns the ID of the buffer used in this SoundBuffer */
    3434    inline ALuint getID() const { return this->bufferID; }
     35    inline bool loaded() const { return bLoaded; };
    3536
    3637  private:
     
    4243    ALsizei       size;                 //!< The size of the Buffer.
    4344    ALboolean     loop;                 //!< loop information.
     45    bool          bLoaded;               //!< If the Sound was loaded this is true.
    4446  };
    4547}
  • branches/new_class_id/src/lib/sound/sound_engine.cc

    r9721 r9805  
    2626#include "util/preferences.h"
    2727#include "globals.h"
     28#include "resource_sound_buffer.h"
    2829
    2930namespace OrxSound
     
    119120  SoundSource* SoundEngine::createSource(const std::string& fileName, PNode* sourceNode)
    120121  {
    121     SoundBuffer* buffer = NULL;
     122    SoundBuffer buffer;
    122123    if (!fileName.empty())
    123124    {
    124       buffer= (SoundBuffer*)ResourceManager::getInstance()->load(fileName, WAV, RP_LEVEL);
    125       if (buffer == NULL)
     125      buffer = ResourceSoundBuffer(fileName);
     126      if (!buffer.loaded())
    126127        PRINTF(2)("Wav-Sound %s could not be loaded onto new Source\n", fileName.c_str());
    127128    }
     
    215216        if(play == AL_PLAYING)
    216217        {
    217           if (likely((*sourceIT)->getNode() != NULL))
     218          if (likely((*sourceIT)->getNode() != NULL))
    218219          {
    219220            alSource3f((*sourceIT)->getID(), AL_POSITION,
  • branches/new_class_id/src/lib/sound/sound_source.cc

    r9715 r9805  
    1919#include "sound_engine.h"
    2020
    21 #include "alincl.h"
    2221#include "compiler.h"
    2322#include "debug.h"
     
    2928  * @brief creates a SoundSource at position sourceNode with the SoundBuffer buffer
    3029  */
    31   SoundSource::SoundSource(const PNode* sourceNode, const SoundBuffer* buffer)
     30  SoundSource::SoundSource(const PNode* sourceNode, const SoundBuffer& buffer)
    3231  {
    3332    this->registerObject(this, SoundSource::_objectList);
     
    120119  void SoundSource::play()
    121120  {
    122     if (this->buffer && this->retrieveSource())
     121    if (this->retrieveSource())
    123122    {
    124123      if (this->bPlay)
    125124        alSourceStop(this->sourceID);
    126125
    127       alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
     126      alSourcei (this->sourceID, AL_BUFFER, this->buffer.getID());
    128127      alSourcei (this->sourceID, AL_LOOPING,  AL_FALSE);
    129128      alSourcef (this->sourceID, AL_GAIN, 1);
     
    141140  * @param buffer the buffer to play back on this Source
    142141  */
    143   void SoundSource::play(const SoundBuffer* buffer)
     142  void SoundSource::play(const SoundBuffer& buffer)
    144143  {
    145144    if (!this->retrieveSource())
     
    150149
    151150    alSourceStop(this->sourceID);
    152     alSourcei (this->sourceID, AL_BUFFER, buffer->getID());
     151    alSourcei (this->sourceID, AL_BUFFER, buffer.getID());
    153152    alSourcei (this->sourceID, AL_LOOPING,  AL_FALSE);
    154153    alSourcef (this->sourceID, AL_GAIN, 1);
     
    156155    alSourcePlay(this->sourceID);
    157156
    158     if (unlikely(this->buffer != NULL))
    159       alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
     157    if (unlikely(this->buffer.getID() != 0))
     158      alSourcei (this->sourceID, AL_BUFFER, this->buffer.getID());
    160159    this->bPlay = true;
    161160
     
    170169   * @param gain the gain of the sound buffer
    171170  */
    172   void SoundSource::play(const SoundBuffer* buffer, float gain)
     171  void SoundSource::play(const SoundBuffer& buffer, float gain)
    173172  {
    174173    if (!this->retrieveSource())
     
    179178
    180179    alSourceStop(this->sourceID);
    181     alSourcei (this->sourceID, AL_BUFFER, buffer->getID());
     180    alSourcei (this->sourceID, AL_BUFFER, buffer.getID());
    182181    alSourcei (this->sourceID, AL_LOOPING,  AL_FALSE);
    183182    alSourcef (this->sourceID, AL_GAIN, gain);
     
    185184    alSourcePlay(this->sourceID);
    186185
    187     if (unlikely(this->buffer != NULL))
    188       alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
     186    if (unlikely(this->buffer.getID() != 0))
     187      alSourcei (this->sourceID, AL_BUFFER, this->buffer.getID());
    189188    this->bPlay = true;
    190189
     
    199198   * @param loop if true, sound gets looped
    200199   */
    201   void SoundSource::play(const SoundBuffer* buffer, float gain, bool loop)
     200  void SoundSource::play(const SoundBuffer& buffer, float gain, bool loop)
    202201  {
    203202    if (!this->retrieveSource())
     
    208207
    209208    alSourceStop(this->sourceID);
    210     alSourcei (this->sourceID, AL_BUFFER, buffer->getID());
     209    alSourcei (this->sourceID, AL_BUFFER, buffer.getID());
    211210
    212211    if (loop)
     
    219218    alSourcePlay(this->sourceID);
    220219
    221     if (unlikely(this->buffer != NULL))
    222       alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
     220    if (unlikely(this->buffer.getID() != 0))
     221      alSourcei (this->sourceID, AL_BUFFER, this->buffer.getID());
    223222    this->bPlay = true;
    224223
     
    232231   * @param gain the new gain value
    233232   */
    234   void SoundSource::gain(const SoundBuffer* buffer, float gain)
     233  void SoundSource::gain(const SoundBuffer& buffer, float gain)
    235234  {
    236235    // alSourcei (this->sourceID, AL_BUFFER, buffer->getID());
     
    347346  * @param duration time perios to fade in
    348347  */
    349   void SoundSource::fadein(const SoundBuffer* buffer, ALfloat duration)
     348  void SoundSource::fadein(const SoundBuffer& buffer, ALfloat duration)
    350349  {
    351350    //if (this->buffer && this->retrieveSource())
  • branches/new_class_id/src/lib/sound/sound_source.h

    r9715 r9805  
    88
    99#include "base_object.h"
     10#include "sound_buffer.h"
    1011#include "alincl.h"
    1112
     
    1415namespace OrxSound
    1516{
    16   class SoundBuffer;
    1717  //! A class that represents a SoundSource
    1818  class SoundSource : public BaseObject
     
    2020    ObjectListDeclaration(SoundSource);
    2121  public:
    22     SoundSource(const PNode* sourceNode = NULL, const SoundBuffer* buffer = NULL);
     22    SoundSource(const PNode* sourceNode = NULL, const SoundBuffer& buffer = SoundBuffer());
    2323    SoundSource(const SoundSource& source);
    2424    SoundSource& operator=(const SoundSource& source);
     
    2929    // user interaction
    3030    void play();
    31     void play(const SoundBuffer* buffer);
    32     void play(const SoundBuffer* buffer, float gain);
    33     void play(const SoundBuffer* buffer, float gain, bool loop);
     31    void play(const SoundBuffer& buffer);
     32    void play(const SoundBuffer& buffer, float gain);
     33    void play(const SoundBuffer& buffer, float gain, bool loop);
    3434
    35     void gain(const SoundBuffer* buffer, float gain);
     35    void gain(const SoundBuffer& buffer, float gain);
    3636
    3737    void stop();
    3838    void pause();
    3939    void rewind();
    40     void fadein(const SoundBuffer* buffer, ALfloat duration);
     40    void fadein(const SoundBuffer& buffer, ALfloat duration);
    4141
    4242    // development functions
     
    4747    void setSourceNode(const PNode* sourceNode);
    4848    /** @returns the SoundBuffer of this Source */
    49     inline const SoundBuffer* getBuffer() const { return this->buffer; };
     49    inline const SoundBuffer& getBuffer() const { return this->buffer; };
    5050    /** @returns the SourceNode of this Source */
    5151    inline const PNode* getNode() const { return this->sourceNode; };
     
    6666    bool                   resident;    //!< If the alSource should be resident (if true, the alSource will be returned on deletion).
    6767    ALuint                 sourceID;    //!< The ID of the Source
    68     const SoundBuffer*     buffer;      //!< The buffer to play in this source.
     68    SoundBuffer            buffer;      //!< The buffer to play in this source.
    6969    const PNode*           sourceNode;  //!< The SourceNode representing the position/velocity... of this source.
    7070  };
  • branches/new_class_id/src/lib/util/loading/resource_manager.cc

    r9721 r9805  
    442442    case WAV:
    443443      if(File(fullName).isFile())
    444         tmpResource->pointer = new OrxSound::SoundBuffer(fullName);
     444//        tmpResource->pointer = new OrxSound::SoundBuffer(fullName);
    445445      break;
    446446    case OGG:
Note: See TracChangeset for help on using the changeset viewer.