Index: trunk/src/lib/sound/sound_buffer.cc
===================================================================
--- trunk/src/lib/sound/sound_buffer.cc	(revision 6830)
+++ trunk/src/lib/sound/sound_buffer.cc	(revision 6836)
@@ -20,4 +20,7 @@
 #include "sound_engine.h"
 
+#include "sdlincl.h"
+#include <cassert>
+
 using namespace std;
 
@@ -34,41 +37,65 @@
   this->setName(fileName);
 
-  ALenum format;
-  ALvoid* data;
-  ALsizei freq;
-
-  ALenum result;
-
   // generate a Buffer
   alGenBuffers(1, &this->bufferID);
-  if ((result = alGetError()) != AL_NO_ERROR)
-    PRINTF(2)("%s\n", SoundEngine::getALErrorString(result));
-
-  // read in the wav data
-  /* according to http://www.edenwaith.com/products/pige/tutorials/openal.php the alutLoadWAVFile differs from platform to platform*/
-#ifdef __APPLE__
-  alutLoadWAVFile((ALbyte*)fileName, &format, &data, &this->size, &freq);
-#elif defined __WIN32__
-  alutLoadWAVFile((ALbyte*)fileName, &format, &data, &size, &freq, &this->loop);
-#else
-  alutLoadWAVFile((ALbyte*)fileName, &format, &data, &this->size, &freq, &this->loop);
-#endif
-  if ((result = alGetError()) != AL_NO_ERROR)
-    PRINTF(2)("%s\n", SoundEngine::getALErrorString(result));
-
-  // send the loaded wav data to the buffer
-  alBufferData(this->bufferID, format, data, this->size, freq);
-  if ((result = alGetError()) != AL_NO_ERROR)
-    PRINTF(2)("%s\n", SoundEngine::getALErrorString(result));
-
-  // remove the wav data (redundant)
-  alutUnloadWAV(format, data, this->size, freq);
-  if ((result = alGetError()) != AL_NO_ERROR)
-    PRINTF(2)("%s\n", SoundEngine::getALErrorString(result));
+  SoundEngine::checkError("Generate Buffer", __LINE__);
+  this->loadWAV(fileName);
 }
 
 SoundBuffer::~SoundBuffer()
 {
-//  SoundEngine::getInstance()->removeBuffer(this);
+  //  SoundEngine::getInstance()->removeBuffer(this);
   alDeleteBuffers(1, &this->bufferID);
 }
+
+/**
+ * @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 char* fileName)
+{
+  SDL_AudioSpec wavSpec;
+  Uint32 wavLength;
+  Uint8 *wavBuffer;
+
+  /* Load the WAV */
+  if( SDL_LoadWAV(fileName, &wavSpec, &wavBuffer, &wavLength) == NULL)
+  {
+    PRINTF(2)("Could not open %s: %s\n", fileName, SDL_GetError());
+    return false;
+  }
+
+  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;
+}
+
+/**
+ * @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 6830)
+++ trunk/src/lib/sound/sound_buffer.h	(revision 6836)
@@ -11,4 +11,5 @@
 
 // FORWARD DECLARATION
+typedef struct SDL_AudioSpec;
 
 //! A class that represents a datastructure to play Sounds.
@@ -19,6 +20,11 @@
     ~SoundBuffer();
 
+    bool loadWAV(const char* fileName);
+
     /** @returns the ID of the buffer used in this SoundBuffer */
     inline ALuint getID() const { return this->bufferID; }
+
+  private:
+    ALenum sdlAudioSpecToAlFormat(const SDL_AudioSpec* audiospec);
 
   private:
Index: trunk/src/lib/sound/sound_engine.cc
===================================================================
--- trunk/src/lib/sound/sound_engine.cc	(revision 6830)
+++ trunk/src/lib/sound/sound_engine.cc	(revision 6836)
@@ -307,5 +307,10 @@
   alcMakeContextCurrent(this->context);
 #else
-  alutInit(0, NULL);
+  this->device = alcOpenDevice(NULL);
+
+  this->context = alcCreateContext(this->device, NULL);
+
+  alcMakeContextCurrent(this->context);
+  //
 #endif
 
@@ -324,13 +329,11 @@
 bool SoundEngine::allocateSources(unsigned int count)
 {
-  ALenum result;
   // Setting default values.
   for (unsigned int i = 0; i < count; i++)
   {
-    ALuint source;
+    ALuint source = 0;
 
     alGenSources(1, &source);
-    if ((result = alGetError()) != AL_NO_ERROR)
-      PRINTF(1)("Error Generating Sources: '%s'\n", SoundEngine::getALErrorString(result));
+    this->checkError("loading Sources", __LINE__);
 
     alSourcef (source, AL_PITCH,    1.0      );
@@ -340,4 +343,16 @@
   }
   return true;
+}
+
+bool SoundEngine::checkError(const char* error, unsigned int line)
+{
+  ALenum errorCode;
+  if ((errorCode = alGetError()) != AL_NO_ERROR)
+  {
+    PRINTF(1)("Error %s (line:%d): '%s'\n", error, line, SoundEngine::getALErrorString(errorCode));
+    return false;
+  }
+  else
+    return true;
 }
 
Index: trunk/src/lib/sound/sound_engine.h
===================================================================
--- trunk/src/lib/sound/sound_engine.h	(revision 6830)
+++ trunk/src/lib/sound/sound_engine.h	(revision 6836)
@@ -59,4 +59,5 @@
 
   // error handling:
+    static bool checkError(const char* error, unsigned int line);
     static const char* getALErrorString(ALenum err);
 
