Index: trunk/src/lib/sound/Makefile.am
===================================================================
--- trunk/src/lib/sound/Makefile.am	(revision 9406)
+++ trunk/src/lib/sound/Makefile.am	(revision 9869)
@@ -7,4 +7,6 @@
 			sound_source.cc \
 			sound_buffer.cc \
+			sound_buffer_data.cc \
+			resource_sound_buffer.cc \
                         ogg_player.cc
 
@@ -12,3 +14,5 @@
 		 sound_source.h \
 		 sound_buffer.h \
+		 sound_buffer_data.h \
+		 resource_sound_buffer.h \
                  ogg_player.h
Index: trunk/src/lib/sound/ogg_player.cc
===================================================================
--- trunk/src/lib/sound/ogg_player.cc	(revision 9406)
+++ trunk/src/lib/sound/ogg_player.cc	(revision 9869)
@@ -34,19 +34,9 @@
 
 #include "helper_functions.h"
-
-#ifdef HAVE_SDL_SDL_H
-
-#include <SDL/SDL.h>
-#include <SDL/SDL_endian.h>
-
-#else
-
-#include <SDL.h>
-#include <SDL_endian.h>
-
-#endif
+#include "sdlincl.h"
 
 namespace OrxSound
 {
+  ObjectListDefinition(OggPlayer);
   /**
    * initializes an Ogg-player from a file
@@ -55,5 +45,5 @@
   OggPlayer::OggPlayer(const std::string& fileName)
   {
-    this->setClassID(CL_SOUND_OGG_PLAYER, "OggPlayer");
+    this->registerObject(this, OggPlayer::_objectList);
 
     this->state = OggPlayer::None;
@@ -276,5 +266,5 @@
         ogg->update();
       }
-      SDL_Delay(10);
+      SDL_Delay(1);
     }
     PRINTF(4)("End the AudioThread\n");
Index: trunk/src/lib/sound/ogg_player.h
===================================================================
--- trunk/src/lib/sound/ogg_player.h	(revision 9406)
+++ trunk/src/lib/sound/ogg_player.h	(revision 9869)
@@ -13,5 +13,5 @@
 #include <ogg/ogg.h>
 #include <vorbis/vorbisfile.h>
-#include "threading.h"
+#include "util/threading.h"
 
 struct File;
@@ -25,4 +25,6 @@
   class OggPlayer : public BaseObject
   {
+    ObjectListDeclaration(OggPlayer);
+
   public:
     /**
@@ -98,8 +100,8 @@
 
 
-    std::string         _title;
-    std::string         _artist;
-    std::string         _album;
-    std::string         _vendor;
+    std::string         _title;               //!< Song Title.
+    std::string         _artist;              //!< Artist Name of the current song.
+    std::string         _album;               //!< Album Name of the current song.
+    std::string         _vendor;              //!< Vendor Name of the current song.
   };
 
Index: trunk/src/lib/sound/resource_sound_buffer.cc
===================================================================
--- trunk/src/lib/sound/resource_sound_buffer.cc	(revision 9869)
+++ trunk/src/lib/sound/resource_sound_buffer.cc	(revision 9869)
@@ -0,0 +1,36 @@
+
+#include "resource_sound_buffer.h"
+#include "debug.h"
+
+
+namespace OrxSound
+{
+  ObjectListDefinition(ResourceSoundBuffer);
+
+  ResourceSoundBuffer::ResourceSoundBuffer(const std::string& soundName, const Resources::KeepLevel& keepLevel)
+      : SoundBuffer(), Resource(&ResourceSoundBuffer::type)
+  {
+    this->registerObject(this, ResourceSoundBuffer::_objectList);
+    Resources::StorePointer* ptr = this->acquireResource(soundName);
+
+    if (ptr)
+    {
+      assert(!static_cast<ResourceSoundBuffer::SoundBufferResourcePointer*>(ptr)->ptr().isNull());
+      PRINTF(5)("FOUND SOUND: %s\n", soundName.c_str());
+      this->acquireData(static_cast<ResourceSoundBuffer::SoundBufferResourcePointer*>(ptr)->ptr());
+    }
+    else
+    {
+      PRINTF(5)("SOUND NOT FOUND: %s\n", soundName.c_str());
+      std::string fileName = this->Resource::locateFile(soundName);
+      this->SoundBuffer::load(fileName);
+      this->Resource::addResource(new ResourceSoundBuffer::SoundBufferResourcePointer(soundName, keepLevel, this->SoundBuffer::dataPointer()));
+    }
+  }
+
+
+  Resources::tType<ResourceSoundBuffer> ResourceSoundBuffer::type("SoundBuffer");
+
+  ResourceSoundBuffer::SoundBufferResourcePointer::SoundBufferResourcePointer(const std::string& loadString, const Resources::KeepLevel& keepLevel, const SoundBufferData::Pointer& data)
+      : Resources::StorePointer(loadString, keepLevel) , pointer(data)
+{}}
Index: trunk/src/lib/sound/resource_sound_buffer.h
===================================================================
--- trunk/src/lib/sound/resource_sound_buffer.h	(revision 9869)
+++ trunk/src/lib/sound/resource_sound_buffer.h	(revision 9869)
@@ -0,0 +1,41 @@
+/*!
+ * @file resource_sound_buffer.h
+ * @brief Contains the ResourceSoundBuffer class, that handles the Resource-specific loading part of the SoundBuffer.
+ *
+ */
+
+#ifndef _RESOURCE_SOUND_BUFFER_H
+#define _RESOURCE_SOUND_BUFFER_H
+
+#include "util/loading/resource.h"
+#include "sound_buffer.h"
+
+namespace OrxSound
+{
+  class ResourceSoundBuffer : public SoundBuffer, public Resources::Resource
+  {
+    ObjectListDeclaration(ResourceSoundBuffer);
+  public:
+    ResourceSoundBuffer(const std::string& soundName,
+			const Resources::KeepLevel& keepLevel = Resources::KeepLevel());
+    static ResourceSoundBuffer createFromString(const std::string& loadString, const Resources::KeepLevel& keepLevel = Resources::KeepLevel())
+    { return ResourceSoundBuffer(loadString, keepLevel); };
+
+  private:
+  class SoundBufferResourcePointer : public Resources::StorePointer
+    {
+    public:
+      SoundBufferResourcePointer(const std::string& loadString, const Resources::KeepLevel& keepLevel, const SoundBufferData::Pointer& data);
+      inline const SoundBufferData::Pointer& ptr() const { return pointer; }
+      virtual bool last() const { return pointer.count() == 1; }
+    private:
+      SoundBufferData::Pointer pointer;
+    };
+
+  private:
+    static Resources::tType<ResourceSoundBuffer> type;
+  };
+}
+
+
+#endif /* _RESOURCE_SOUND_BUFFER_H */
Index: trunk/src/lib/sound/sound_buffer.cc
===================================================================
--- trunk/src/lib/sound/sound_buffer.cc	(revision 9406)
+++ trunk/src/lib/sound/sound_buffer.cc	(revision 9869)
@@ -18,159 +18,42 @@
 #include "sound_buffer.h"
 
-#include "sound_engine.h"
 
-#include "sdlincl.h"
-#include <cassert>
-#include "debug.h"
-#include "sys/stat.h"
-#include "helper_functions.h"
-
-#ifdef HAVE_SDL_SDL_H
-#include <SDL/SDL.h>
-#include <SDL/SDL_endian.h>
-#else
-#include <SDL.h>
-#include <SDL_endian.h>
-#endif
 namespace OrxSound
 {
+  ObjectListDefinition(SoundBuffer);
   //////////////////
   /* SOUND-BUFFER */
   //////////////////
+  SoundBuffer::SoundBuffer()
+      : data(new SoundBufferData)
+  {
+    this->registerObject(this, SoundBuffer::_objectList);
+  }
   /**
-   *  Creates a Soundbuffer out of an inputfile
+   * @brief Creates a Soundbuffer out of an inputfile
    * @param fileName The name of the File
    */
   SoundBuffer::SoundBuffer(const std::string& fileName)
+      : data(new SoundBufferData)
   {
-    this->setClassID(CL_SOUND_BUFFER, "SoundBuffer");
-    this->setName(fileName);
+    this->registerObject(this, SoundBuffer::_objectList);
+    this->load(fileName);
+  }
 
-    // generate a Buffer
-    alGenBuffers(1, &this->bufferID);
-    SoundEngine::checkError("Generate Buffer", __LINE__);
-    if (!nocaseCmp(fileName.substr(fileName.size() - 3), "WAV"))
-    {
-      this->loadWAV(fileName);
-    }
-    else if (!nocaseCmp(fileName.substr(fileName.size() - 3), "OGG"))
-      this->loadOGG(fileName);
+  SoundBuffer::SoundBuffer(const SoundBuffer& buffer)
+      : data(buffer.data)
+  {
+    this->registerObject(this, SoundBuffer::_objectList);
+  }
 
-  }
+  SoundBuffer::SoundBuffer(const SoundBufferData::Pointer& dataPointer)
+      : data(dataPointer)
+  {
+    this->registerObject(this, SoundBuffer::_objectList);
+  };
 
   SoundBuffer::~SoundBuffer()
   {
-    //  SoundEngine::getInstance()->removeBuffer(this);
-    alDeleteBuffers(1, &this->bufferID);
-    SoundEngine::checkError("SoundBuffer: Delete Buffer", __LINE__);
   }
 
-  /**
-   * @brief loads a Waveform from the local fileSystem into this Source.
-   * @param fileName the Name of the File to Load.
-   * @returns true on success.
-   */
-  bool SoundBuffer::loadWAV(const std::string& fileName)
-  {
-    SDL_AudioSpec wavSpec;
-    Uint32 wavLength;
-    Uint8 *wavBuffer;
-
-    /* Load the WAV */
-    if( SDL_LoadWAV(fileName.c_str(), &wavSpec, &wavBuffer, &wavLength) == NULL)
-    {
-      PRINTF(2)("Could not open %s: %s\n", fileName.c_str(), SDL_GetError());
-      return false;
-    }
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
-    if ( !( wavSpec.format == AUDIO_U8 || wavSpec.format == AUDIO_S8 ) )
-    {
-      int cnt = wavLength/2;
-      Uint16* wavBufferAsShorts = ( Uint16* )wavBuffer;
-      for ( int i = 0; i < cnt; ++i, ++wavBufferAsShorts )
-        *wavBufferAsShorts = SDL_Swap16( *wavBufferAsShorts );
-    }
-#endif
-    alBufferData(this->bufferID, SoundBuffer::sdlAudioSpecToAlFormat(&wavSpec),
-                 wavBuffer, wavLength, wavSpec.freq);
-
-    SDL_FreeWAV(wavBuffer);
-    if (SoundEngine::checkError("Could not load Wave file", __LINE__))
-      return true;
-    else
-      return false;
-  }
-
-
-#ifndef AL_FORMAT_VORBIS_EXT
-#define AL_FORMAT_VORBIS_EXT 0x100030
-#endif
-  /**
-   * @brief loads an OGG-file into a SOundBuffer
-   * @param fileName the Name of the File to load.
-   * @returns true on success (file exists and is fully loaded), false otherwise.
-   */
-  bool SoundBuffer::loadOGG(const std::string& fileName)
-  {
-    void*     ovdata;
-    FILE*     fh;
-
-    fh = fopen( fileName.c_str() , "rb") ;
-    if( fh != NULL )
-    {
-      struct stat sbuf ;
-
-      if(stat( fileName.c_str(), &sbuf ) != -1)
-      {
-        ovdata = malloc(sbuf.st_size);
-        if(ovdata != NULL)
-        {
-          fread( ovdata, 1, sbuf.st_size, fh);
-
-          alBufferData( this->bufferID,
-                        AL_FORMAT_VORBIS_EXT,
-                        ovdata,
-                        sbuf.st_size,
-                        1) ;
-          SoundEngine::checkError("Could not load OGG file", __LINE__);
-
-          free(ovdata);
-        }
-        fclose(fh);
-      }
-      else
-        return false;
-    }
-    else
-      return false;
-
-    return true ;
-
-  }
-
-
-  /**
-   * @brief converts an SDL_AudioSpec into a valid OpenAL AUDIO_FORMAT enumerator
-   * @param audiospec the AudioSpec to convert.
-   * @returns the AL_FORMAT
-   */
-  ALenum SoundBuffer::sdlAudioSpecToAlFormat(const SDL_AudioSpec* audiospec)
-  {
-    assert (audiospec != NULL);
-    bool stereo = true;
-    bool is16Bit = true;
-    if (audiospec->format == AUDIO_U8 || audiospec->format == AUDIO_S8)
-      is16Bit = false;
-    if (audiospec->channels == 1)
-      stereo = false;
-
-    if (!stereo && !is16Bit)
-      return AL_FORMAT_MONO8;
-    else if (!stereo && is16Bit)
-      return AL_FORMAT_MONO16;
-    else if (stereo && !is16Bit)
-      return AL_FORMAT_STEREO8;
-    else /* if (stereo && is16Bit) */
-      return AL_FORMAT_STEREO16;
-  }
 }
Index: trunk/src/lib/sound/sound_buffer.h
===================================================================
--- trunk/src/lib/sound/sound_buffer.h	(revision 9406)
+++ trunk/src/lib/sound/sound_buffer.h	(revision 9869)
@@ -8,32 +8,41 @@
 
 #include "base_object.h"
-#include "alincl.h"
-
-// FORWARD DECLARATION
-typedef struct SDL_AudioSpec;
+#include "sound_buffer_data.h"
 
 namespace OrxSound
 {
   //! A class that represents a datastructure to play Sounds.
-  class SoundBuffer : public BaseObject
+  class SoundBuffer : virtual public BaseObject
   {
+    ObjectListDeclaration(SoundBuffer);
   public:
+    SoundBuffer();
+    SoundBuffer(const SoundBuffer& buffer);
+    SoundBuffer(const SoundBufferData::Pointer& dataPointer);
     SoundBuffer(const std::string& fileName);
     virtual ~SoundBuffer();
 
-    bool loadWAV(const std::string& fileName);
-    bool loadOGG(const std::string& fileName);
+    /** @brief assignment operator */
+    SoundBuffer& operator=(const SoundBuffer& buffer) { this->data = buffer.data; return *this; };
+    bool operator==(const SoundBuffer& buffer) const {return this->data == buffer.data; };
+
+    /** @see SoundBufferData::load */
+    inline bool load(const std::string& fileName) { return this->data->load(fileName); };
+    /** @see SoundBufferData::loadWav */
+    inline bool loadWAV(const std::string& fileName) { return this->data->loadWAV(fileName); };
+    /** @see SoundBufferData::loadOgg */
+    inline bool loadOGG(const std::string& fileName) { return this->data->loadOGG(fileName); };
 
     /** @returns the ID of the buffer used in this SoundBuffer */
-    inline ALuint getID() const { return this->bufferID; }
+    inline ALuint getID() const { return this->data->getID(); }
+    inline bool loaded() const { return this->data->loaded(); }
+
+    /** @returns the DataPointer */
+    const SoundBufferData::Pointer& dataPointer() const { return data; }
+    /** @param dataPointer the data to acquire @brief Buffer shall acquire dataPointers data */
+    void acquireData(const SoundBufferData::Pointer& dataPointer)  { data = dataPointer; };
 
   private:
-    ALenum sdlAudioSpecToAlFormat(const SDL_AudioSpec* audiospec);
-
-  private:
-    ALuint        bufferID;             //!< The address of the Buffer.
-
-    ALsizei       size;                 //!< The size of the Buffer.
-    ALboolean     loop;                 //!< loop information.
+    SoundBufferData::Pointer    data;                //!< Pointer to the Stored Data
   };
 }
Index: trunk/src/lib/sound/sound_buffer_data.cc
===================================================================
--- trunk/src/lib/sound/sound_buffer_data.cc	(revision 9869)
+++ trunk/src/lib/sound/sound_buffer_data.cc	(revision 9869)
@@ -0,0 +1,193 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   ### File Specific:
+   main-programmer: Benjamin Grauer
+   co-programmer: ...
+*/
+
+#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_SOUND
+
+#include "sound_buffer_data.h"
+
+#include "sound_engine.h"
+
+#include "sdlincl.h"
+#include <cassert>
+#include "debug.h"
+#include "sys/stat.h"
+#include "helper_functions.h"
+
+/*#ifdef HAVE_SDL_SDL_H
+ #include <SDL/SDL.h>
+ // #include <SDL/SDL_endian.h>
+#else
+ #include <SDL.h>
+ //#include <SDL_endian.h>
+#endif*/
+namespace OrxSound
+{
+  ObjectListDefinition(SoundBufferData);
+  //////////////////
+  /* SOUND-BUFFER */
+  //////////////////
+  /**
+   * @brief Creates a SoundbufferData out of an inputfile
+   * @param fileName The name of the File
+   */
+  SoundBufferData::SoundBufferData()
+  {
+    this->registerObject(this, SoundBufferData::_objectList);
+    this->bufferID = 0;
+
+    this->size = 0;
+    this->loop = AL_FALSE;
+    this->bLoaded = false;
+  }
+
+  SoundBufferData::~SoundBufferData()
+  {
+    //  SoundEngine::getInstance()->removeBuffer(this);
+    alDeleteBuffers(1, &this->bufferID);
+    SoundEngine::checkError("SoundBuffer: Delete Buffer", __LINE__);
+  }
+
+  /**
+   * @brief check the File-extension and loads either Wav of Ogg
+   * @param fileName the Name of the File to load.
+   * @returns true on success (file found, and loaded.)
+   */
+  bool SoundBufferData::load(const std::string& fileName)
+  {
+    // generate a Buffer
+    alGenBuffers(1, &this->bufferID);
+    SoundEngine::checkError("Generate Buffer", __LINE__);
+    if (!nocaseCmp(fileName.substr(fileName.size() - 3), "WAV"))
+    {
+      return this->loadWAV(fileName);
+    }
+    else if (!nocaseCmp(fileName.substr(fileName.size() - 3), "OGG"))
+      return this->loadOGG(fileName);
+    else
+      return false;
+  }
+
+  /**
+   * @brief loads a Waveform from the local fileSystem into this Source.
+   * @param fileName the Name of the File to Load.
+   * @returns true on success.
+   */
+  bool SoundBufferData::loadWAV(const std::string& fileName)
+  {
+    SDL_AudioSpec wavSpec;
+    Uint32 wavLength;
+    Uint8 *wavBuffer;
+
+    /* Load the WAV */
+    if( SDL_LoadWAV(fileName.c_str(), &wavSpec, &wavBuffer, &wavLength) == NULL)
+    {
+      PRINTF(2)("Could not open %s: %s\n", fileName.c_str(), SDL_GetError());
+      return false;
+    }
+#if SDL_BYTEORDER == SDL_BIG_ENDIAN
+    if ( !( wavSpec.format == AUDIO_U8 || wavSpec.format == AUDIO_S8 ) )
+    {
+      int cnt = wavLength/2;
+      Uint16* wavBufferAsShorts = ( Uint16* )wavBuffer;
+      for ( int i = 0; i < cnt; ++i, ++wavBufferAsShorts )
+        *wavBufferAsShorts = SDL_Swap16( *wavBufferAsShorts );
+    }
+#endif
+    alBufferData(this->bufferID, SoundBufferData::sdlAudioSpecToAlFormat(&wavSpec),
+                 wavBuffer, wavLength, wavSpec.freq);
+
+    SDL_FreeWAV(wavBuffer);
+    if (SoundEngine::checkError("Could not load Wave file", __LINE__))
+    {
+      this->bLoaded = true;
+      return true;
+    }
+    else
+      return false;
+  }
+
+
+#ifndef AL_FORMAT_VORBIS_EXT
+#define AL_FORMAT_VORBIS_EXT 0x100030
+#endif
+  /**
+   * @brief loads an OGG-file into a SOundBuffer
+   * @param fileName the Name of the File to load.
+   * @returns true on success (file exists and is fully loaded), false otherwise.
+   */
+  bool SoundBufferData::loadOGG(const std::string& fileName)
+  {
+    void*     ovdata;
+    FILE*     fh;
+
+    fh = fopen( fileName.c_str() , "rb") ;
+    if( fh != NULL )
+    {
+      struct stat sbuf ;
+
+      if(stat( fileName.c_str(), &sbuf ) != -1)
+      {
+        ovdata = malloc(sbuf.st_size);
+        if(ovdata != NULL)
+        {
+          fread( ovdata, 1, sbuf.st_size, fh);
+
+          alBufferData( this->bufferID,
+                        AL_FORMAT_VORBIS_EXT,
+                        ovdata,
+                        sbuf.st_size,
+                        1) ;
+          SoundEngine::checkError("Could not load OGG file", __LINE__);
+
+          free(ovdata);
+        }
+        fclose(fh);
+      }
+      else
+        return false;
+    }
+    else
+      return false;
+
+    this->bLoaded = true;
+    return true ;
+  }
+
+
+  /**
+   * @brief converts an SDL_AudioSpec into a valid OpenAL AUDIO_FORMAT enumerator
+   * @param audiospec the AudioSpec to convert.
+   * @returns the AL_FORMAT
+   */
+  ALenum SoundBufferData::sdlAudioSpecToAlFormat(const SDL_AudioSpec* audiospec)
+  {
+    assert (audiospec != NULL);
+    bool stereo = true;
+    bool is16Bit = true;
+    if (audiospec->format == AUDIO_U8 || audiospec->format == AUDIO_S8)
+      is16Bit = false;
+    if (audiospec->channels == 1)
+      stereo = false;
+
+    if (!stereo && !is16Bit)
+      return AL_FORMAT_MONO8;
+    else if (!stereo && is16Bit)
+      return AL_FORMAT_MONO16;
+    else if (stereo && !is16Bit)
+      return AL_FORMAT_STEREO8;
+    else /* if (stereo && is16Bit) */
+      return AL_FORMAT_STEREO16;
+  }
+}
Index: trunk/src/lib/sound/sound_buffer_data.h
===================================================================
--- trunk/src/lib/sound/sound_buffer_data.h	(revision 9869)
+++ trunk/src/lib/sound/sound_buffer_data.h	(revision 9869)
@@ -0,0 +1,48 @@
+/*!
+ * @file sound_buffer_data.h
+ * @brief Definition of the sound-buffer-datacontainer-class
+*/
+
+#ifndef _SOUND_BUFFER_DATA_H
+#define _SOUND_BUFFER_DATA_H
+
+#include "base_object.h"
+#include "alincl.h"
+#include "util/count_pointer.h"
+
+// FORWARD DECLARATION
+typedef struct SDL_AudioSpec;
+
+namespace OrxSound
+{
+  //! A class that represents a datastructure to play Sounds.
+  class SoundBufferData : public BaseObject
+  {
+    ObjectListDeclaration(SoundBufferData);
+  public:
+    typedef CountPointer<SoundBufferData> Pointer;
+
+  public:
+    SoundBufferData();
+    virtual ~SoundBufferData();
+
+    bool load(const std::string& fileName);
+    bool loadWAV(const std::string& fileName);
+    bool loadOGG(const std::string& fileName);
+
+    /** @returns the ID of the buffer used in this SoundBuffer */
+    inline ALuint getID() const { return this->bufferID; }
+    inline bool loaded() const { return bLoaded; };
+
+  private:
+    ALenum sdlAudioSpecToAlFormat(const SDL_AudioSpec* audiospec);
+
+  private:
+    ALuint        bufferID;             //!< The address of the Buffer.
+
+    ALsizei       size;                 //!< The size of the Buffer.
+    ALboolean     loop;                 //!< loop information.
+    bool          bLoaded;               //!< If the Sound was loaded this is true.
+  };
+}
+#endif /* _SOUND_BUFFER_DATA_H */
Index: trunk/src/lib/sound/sound_engine.cc
===================================================================
--- trunk/src/lib/sound/sound_engine.cc	(revision 9406)
+++ trunk/src/lib/sound/sound_engine.cc	(revision 9869)
@@ -21,15 +21,13 @@
 #include "sound_engine.h"
 
-#include "class_list.h"
-
 #include "p_node.h"
-#include "util/loading/resource_manager.h"
 #include "debug.h"
-#include "util/preferences.h"
+#include "parser/preferences/preferences.h"
 #include "globals.h"
+#include "resource_sound_buffer.h"
 
 namespace OrxSound
 {
-
+  ObjectListDefinition(SoundEngine);
   //////////////////
   /* SOUND-ENGINE */
@@ -40,10 +38,8 @@
   SoundEngine::SoundEngine ()
   {
-    this->setClassID(CL_SOUND_ENGINE, "SoundEngine");
+    this->registerObject(this, SoundEngine::_objectList);
     this->setName("SoundEngine");
 
     this->listener = NULL;
-    this->bufferList = NULL;
-    this->sourceList = NULL;
 
     this->device = NULL;
@@ -69,9 +65,6 @@
   {
     // deleting all the SoundSources
-    if(this->sourceList != NULL)
-    {
-      while (this->sourceList->size() > 0)
-        delete static_cast<SoundSource*>(this->sourceList->front());
-    }
+    while (!SoundSource::objectList().empty())
+      delete (SoundSource::objectList().front());
 
     while(!this->ALSources.empty())
@@ -89,9 +82,6 @@
 
     // deleting all the SoundBuffers
-    if (this->bufferList != NULL)
-    {
-      while(this->bufferList->size() > 0)
-        ResourceManager::getInstance()->unload(static_cast<SoundBuffer*>(this->bufferList->front()));
-    }
+    //    while(!SoundBuffer::objectList().empty())
+    //ResourceManager::getInstance()->unload(SoundBuffer::objectList().front());
 
     // removing openAL from AudioResource
@@ -129,9 +119,9 @@
   SoundSource* SoundEngine::createSource(const std::string& fileName, PNode* sourceNode)
   {
-    SoundBuffer* buffer = NULL;
+    SoundBuffer buffer;
     if (!fileName.empty())
     {
-      buffer= (SoundBuffer*)ResourceManager::getInstance()->load(fileName, WAV, RP_LEVEL);
-      if (buffer == NULL)
+      buffer = ResourceSoundBuffer(fileName);
+      if (!buffer.loaded())
         PRINTF(2)("Wav-Sound %s could not be loaded onto new Source\n", fileName.c_str());
     }
@@ -212,39 +202,36 @@
 
     // updating all the Sources positions
-    if (likely(this->sourceList != NULL || (this->sourceList = ClassList::getList(CL_SOUND_SOURCE)) != NULL))
-    {
-      std::list<BaseObject*>::const_iterator sourceIT;
-      SoundSource* source;
-      for (sourceIT = this->sourceList->begin(); sourceIT != this->sourceList->end(); sourceIT++)
+    ObjectList<SoundSource>::const_iterator sourceIT;
+    for (sourceIT = SoundSource::objectList().begin();
+         sourceIT != SoundSource::objectList().end();
+         sourceIT++)
+    {
+      if ((*sourceIT)->isPlaying())
       {
-        source = static_cast<SoundSource*>(*sourceIT);
-        if (source->isPlaying())
+        int play = 0x000;
+        alGetSourcei((*sourceIT)->getID(), AL_SOURCE_STATE, &play);
+        if (DEBUG_LEVEL > 2)
+          SoundEngine::checkError("SoundEngine::update() Play", __LINE__);
+        if(play == AL_PLAYING)
         {
-          int play = 0x000;
-          alGetSourcei(source->getID(), AL_SOURCE_STATE, &play);
-          if (DEBUG_LEVEL > 2)
-            SoundEngine::checkError("SoundEngine::update() Play", __LINE__);
-          if(play == AL_PLAYING)
+          if (likely((*sourceIT)->getNode() != NULL))
           {
-            if (likely(source->getNode() != NULL))
-            {
-              alSource3f(source->getID(), AL_POSITION,
-                         source->getNode()->getAbsCoor().x,
-                         source->getNode()->getAbsCoor().y,
-                         source->getNode()->getAbsCoor().z);
-              if (DEBUG_LEVEL > 2)
-                SoundEngine::checkError("SoundEngine::update() Set Source Position", __LINE__);
-              alSource3f(source->getID(), AL_VELOCITY,
-                         source->getNode()->getVelocity().x,
-                         source->getNode()->getVelocity().y,
-                         source->getNode()->getVelocity().z);
-              if (DEBUG_LEVEL > 2)
-                SoundEngine::checkError("SoundEngine::update() Set Source Velocity", __LINE__);
-            }
+            alSource3f((*sourceIT)->getID(), AL_POSITION,
+                       (*sourceIT)->getNode()->getAbsCoor().x,
+                       (*sourceIT)->getNode()->getAbsCoor().y,
+                       (*sourceIT)->getNode()->getAbsCoor().z);
+            if (DEBUG_LEVEL > 2)
+              SoundEngine::checkError("SoundEngine::update() Set Source Position", __LINE__);
+            alSource3f((*sourceIT)->getID(), AL_VELOCITY,
+                       (*sourceIT)->getNode()->getVelocity().x,
+                       (*sourceIT)->getNode()->getVelocity().y,
+                       (*sourceIT)->getNode()->getVelocity().z);
+            if (DEBUG_LEVEL > 2)
+              SoundEngine::checkError("SoundEngine::update() Set Source Velocity", __LINE__);
           }
-          else
-          {
-            source->stop();
-          }
+        }
+        else
+        {
+          (*sourceIT)->stop();
         }
       }
@@ -393,15 +380,15 @@
       default:
       case AL_NO_ERROR:
-        return ("AL_NO_ERROR");
+      return ("AL_NO_ERROR");
       case AL_INVALID_NAME:
-        return ("AL_INVALID_NAME");
+      return ("AL_INVALID_NAME");
       case AL_INVALID_ENUM:
-        return ("AL_INVALID_ENUM");
+      return ("AL_INVALID_ENUM");
       case AL_INVALID_VALUE:
-        return ("AL_INVALID_VALUE");
+      return ("AL_INVALID_VALUE");
       case AL_INVALID_OPERATION:
-        return ("AL_INVALID_OPERATION");
+      return ("AL_INVALID_OPERATION");
       case AL_OUT_OF_MEMORY:
-        return ("AL_OUT_OF_MEMORY");
+      return ("AL_OUT_OF_MEMORY");
     };
   }
@@ -414,15 +401,15 @@
       default:
       case ALC_NO_ERROR:
-        return ("AL_NO_ERROR");
+      return ("AL_NO_ERROR");
       case ALC_INVALID_DEVICE:
-        return ("ALC_INVALID_DEVICE");
+      return ("ALC_INVALID_DEVICE");
       case ALC_INVALID_CONTEXT:
-        return("ALC_INVALID_CONTEXT");
+      return("ALC_INVALID_CONTEXT");
       case ALC_INVALID_ENUM:
-        return("ALC_INVALID_ENUM");
+      return("ALC_INVALID_ENUM");
       case ALC_INVALID_VALUE:
-        return ("ALC_INVALID_VALUE");
+      return ("ALC_INVALID_VALUE");
       case ALC_OUT_OF_MEMORY:
-        return("ALC_OUT_OF_MEMORY");
+      return("ALC_OUT_OF_MEMORY");
     };
   }
Index: trunk/src/lib/sound/sound_engine.h
===================================================================
--- trunk/src/lib/sound/sound_engine.h	(revision 9406)
+++ trunk/src/lib/sound/sound_engine.h	(revision 9869)
@@ -27,5 +27,6 @@
   class SoundEngine : public BaseObject
   {
-  public:
+    ObjectListDeclaration(SoundEngine);
+    public:
     virtual ~SoundEngine();
     /** @returns a Pointer to the only object of this Class */
@@ -75,7 +76,4 @@
     const PNode*                   listener;                 //!< The listener of the Scene
 
-    const std::list<BaseObject*>*  bufferList;               //!< A list of buffers
-    const std::list<BaseObject*>*  sourceList;               //!< A list for all the sources in the scene.
-
     unsigned int                   maxSourceCount;           //!< How many Sources is the Maximum
     std::stack<ALuint>             ALSources;                //!< A list of real openAL-Sources, the engine allocates, and stores for reuse.
Index: trunk/src/lib/sound/sound_source.cc
===================================================================
--- trunk/src/lib/sound/sound_source.cc	(revision 9406)
+++ trunk/src/lib/sound/sound_source.cc	(revision 9869)
@@ -19,5 +19,4 @@
 #include "sound_engine.h"
 
-#include "alincl.h"
 #include "compiler.h"
 #include "debug.h"
@@ -25,11 +24,11 @@
 namespace OrxSound
 {
+  ObjectListDefinition(SoundSource);
   /**
   * @brief creates a SoundSource at position sourceNode with the SoundBuffer buffer
   */
-  SoundSource::SoundSource(const PNode* sourceNode, const SoundBuffer* buffer)
-  {
-    this->setClassID(CL_SOUND_SOURCE, "SoundSource");
-
+  SoundSource::SoundSource(const PNode* sourceNode, const SoundBuffer& buffer)
+  {
+    this->registerObject(this, SoundSource::_objectList);
     // adding the Source to the SourcesList of the SoundEngine
     this->buffer = buffer;
@@ -51,5 +50,5 @@
   SoundSource::SoundSource(const SoundSource& source)
   {
-    this->setClassID(CL_SOUND_SOURCE, "SoundSource");
+    this->registerObject(this, SoundSource::_objectList);
 
     // adding the Source to the SourcesList of the SoundEngine
@@ -120,10 +119,10 @@
   void SoundSource::play()
   {
-    if (this->buffer && this->retrieveSource())
+    if (this->retrieveSource())
     {
       if (this->bPlay)
         alSourceStop(this->sourceID);
 
-      alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
+      alSourcei (this->sourceID, AL_BUFFER, this->buffer.getID());
       alSourcei (this->sourceID, AL_LOOPING,  AL_FALSE);
       alSourcef (this->sourceID, AL_GAIN, 1);
@@ -141,5 +140,5 @@
   * @param buffer the buffer to play back on this Source
   */
-  void SoundSource::play(const SoundBuffer* buffer)
+  void SoundSource::play(const SoundBuffer& buffer)
   {
     if (!this->retrieveSource())
@@ -150,5 +149,5 @@
 
     alSourceStop(this->sourceID);
-    alSourcei (this->sourceID, AL_BUFFER, buffer->getID());
+    alSourcei (this->sourceID, AL_BUFFER, buffer.getID());
     alSourcei (this->sourceID, AL_LOOPING,  AL_FALSE);
     alSourcef (this->sourceID, AL_GAIN, 1);
@@ -156,6 +155,6 @@
     alSourcePlay(this->sourceID);
 
-    if (unlikely(this->buffer != NULL))
-      alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
+    if (unlikely(this->buffer.getID() != 0))
+      alSourcei (this->sourceID, AL_BUFFER, this->buffer.getID());
     this->bPlay = true;
 
@@ -170,5 +169,5 @@
    * @param gain the gain of the sound buffer
   */
-  void SoundSource::play(const SoundBuffer* buffer, float gain)
+  void SoundSource::play(const SoundBuffer& buffer, float gain)
   {
     if (!this->retrieveSource())
@@ -179,5 +178,5 @@
 
     alSourceStop(this->sourceID);
-    alSourcei (this->sourceID, AL_BUFFER, buffer->getID());
+    alSourcei (this->sourceID, AL_BUFFER, buffer.getID());
     alSourcei (this->sourceID, AL_LOOPING,  AL_FALSE);
     alSourcef (this->sourceID, AL_GAIN, gain);
@@ -185,6 +184,6 @@
     alSourcePlay(this->sourceID);
 
-    if (unlikely(this->buffer != NULL))
-      alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
+    if (unlikely(this->buffer.getID() != 0))
+      alSourcei (this->sourceID, AL_BUFFER, this->buffer.getID());
     this->bPlay = true;
 
@@ -199,5 +198,5 @@
    * @param loop if true, sound gets looped
    */
-  void SoundSource::play(const SoundBuffer* buffer, float gain, bool loop)
+  void SoundSource::play(const SoundBuffer& buffer, float gain, bool loop)
   {
     if (!this->retrieveSource())
@@ -208,5 +207,5 @@
 
     alSourceStop(this->sourceID);
-    alSourcei (this->sourceID, AL_BUFFER, buffer->getID());
+    alSourcei (this->sourceID, AL_BUFFER, buffer.getID());
 
     if (loop)
@@ -219,6 +218,6 @@
     alSourcePlay(this->sourceID);
 
-    if (unlikely(this->buffer != NULL))
-      alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
+    if (unlikely(this->buffer.getID() != 0))
+      alSourcei (this->sourceID, AL_BUFFER, this->buffer.getID());
     this->bPlay = true;
 
@@ -232,5 +231,5 @@
    * @param gain the new gain value
    */
-  void SoundSource::gain(const SoundBuffer* buffer, float gain)
+  void SoundSource::gain(const SoundBuffer& buffer, float gain)
   {
     // alSourcei (this->sourceID, AL_BUFFER, buffer->getID());
@@ -347,5 +346,5 @@
   * @param duration time perios to fade in
   */
-  void SoundSource::fadein(const SoundBuffer* buffer, ALfloat duration)
+  void SoundSource::fadein(const SoundBuffer& buffer, ALfloat duration)
   {
     //if (this->buffer && this->retrieveSource())
Index: trunk/src/lib/sound/sound_source.h
===================================================================
--- trunk/src/lib/sound/sound_source.h	(revision 9406)
+++ trunk/src/lib/sound/sound_source.h	(revision 9869)
@@ -8,4 +8,5 @@
 
 #include "base_object.h"
+#include "sound_buffer.h"
 #include "alincl.h"
 
@@ -14,10 +15,10 @@
 namespace OrxSound
 {
-  class SoundBuffer;
   //! A class that represents a SoundSource
   class SoundSource : public BaseObject
   {
+    ObjectListDeclaration(SoundSource);
   public:
-    SoundSource(const PNode* sourceNode = NULL, const SoundBuffer* buffer = NULL);
+    SoundSource(const PNode* sourceNode = NULL, const SoundBuffer& buffer = SoundBuffer());
     SoundSource(const SoundSource& source);
     SoundSource& operator=(const SoundSource& source);
@@ -28,14 +29,14 @@
     // user interaction
     void play();
-    void play(const SoundBuffer* buffer);
-    void play(const SoundBuffer* buffer, float gain);
-    void play(const SoundBuffer* buffer, float gain, bool loop);
+    void play(const SoundBuffer& buffer);
+    void play(const SoundBuffer& buffer, float gain);
+    void play(const SoundBuffer& buffer, float gain, bool loop);
 
-    void gain(const SoundBuffer* buffer, float gain);
+    void gain(const SoundBuffer& buffer, float gain);
 
     void stop();
     void pause();
     void rewind();
-    void fadein(const SoundBuffer* buffer, ALfloat duration);
+    void fadein(const SoundBuffer& buffer, ALfloat duration);
 
     // development functions
@@ -46,5 +47,5 @@
     void setSourceNode(const PNode* sourceNode);
     /** @returns the SoundBuffer of this Source */
-    inline const SoundBuffer* getBuffer() const { return this->buffer; };
+    inline const SoundBuffer& getBuffer() const { return this->buffer; };
     /** @returns the SourceNode of this Source */
     inline const PNode* getNode() const { return this->sourceNode; };
@@ -65,5 +66,5 @@
     bool                   resident;    //!< If the alSource should be resident (if true, the alSource will be returned on deletion).
     ALuint                 sourceID;    //!< The ID of the Source
-    const SoundBuffer*     buffer;      //!< The buffer to play in this source.
+    SoundBuffer            buffer;      //!< The buffer to play in this source.
     const PNode*           sourceNode;  //!< The SourceNode representing the position/velocity... of this source.
   };
