Index: orxonox/trunk/src/lib/sound/Makefile.am
===================================================================
--- orxonox/trunk/src/lib/sound/Makefile.am	(revision 4746)
+++ orxonox/trunk/src/lib/sound/Makefile.am	(revision 4750)
@@ -2,7 +2,9 @@
 include $(MAINSRCDIR)/defs/include_paths.am
 
-noinst_LIBRARIES = libORXsound.a 
+noinst_LIBRARIES = libORXsound.a
 
-libORXsound_a_SOURCES = sound_engine.cc
+libORXsound_a_SOURCES = sound_engine.cc \
+                        ogg_player.cc
 
-noinst_HEADERS= sound_engine.h
+noinst_HEADERS = sound_engine.h \
+                 ogg_player.h
Index: orxonox/trunk/src/lib/sound/Makefile.in
===================================================================
--- orxonox/trunk/src/lib/sound/Makefile.in	(revision 4746)
+++ orxonox/trunk/src/lib/sound/Makefile.in	(revision 4750)
@@ -54,10 +54,11 @@
 libORXsound_a_AR = $(AR) $(ARFLAGS)
 libORXsound_a_LIBADD =
-am_libORXsound_a_OBJECTS = sound_engine.$(OBJEXT)
+am_libORXsound_a_OBJECTS = sound_engine.$(OBJEXT) ogg_player.$(OBJEXT)
 libORXsound_a_OBJECTS = $(am_libORXsound_a_OBJECTS)
 DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
 depcomp = $(SHELL) $(top_srcdir)/depcomp
 am__depfiles_maybe = depfiles
-@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/sound_engine.Po
+@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/ogg_player.Po \
+@AMDEP_TRUE@	./$(DEPDIR)/sound_engine.Po
 CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
 	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
@@ -180,7 +181,11 @@
 target_vendor = @target_vendor@
 MAINSRCDIR = ../..
-noinst_LIBRARIES = libORXsound.a 
-libORXsound_a_SOURCES = sound_engine.cc
-noinst_HEADERS = sound_engine.h
+noinst_LIBRARIES = libORXsound.a
+libORXsound_a_SOURCES = sound_engine.cc \
+                        ogg_player.cc
+
+noinst_HEADERS = sound_engine.h \
+                 ogg_player.h
+
 all: all-am
 
@@ -230,4 +235,5 @@
 	-rm -f *.tab.c
 
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ogg_player.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sound_engine.Po@am__quote@
 
Index: orxonox/trunk/src/lib/sound/ogg_player.cc
===================================================================
--- orxonox/trunk/src/lib/sound/ogg_player.cc	(revision 4750)
+++ orxonox/trunk/src/lib/sound/ogg_player.cc	(revision 4750)
@@ -0,0 +1,235 @@
+/*
+   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: ...
+
+
+   -------------------------------------------------------------------
+   The source of this file comes stright from http://www.devmaster.net
+   Thanks a lot for the nice work, and the easy portability to our Project.
+*/
+
+#include "ogg_player.h"
+
+#include "debug.h"
+
+void OggStream::open(string path)
+{
+    int result;
+
+    if(!(oggFile = fopen(path.c_str(), "rb")))
+        PRINTF(2)("Could not open Ogg file.");
+
+    if((result = ov_open(oggFile, &oggStream, NULL, 0)) < 0)
+    {
+        fclose(oggFile);
+
+        PRINTF(2)("Could not open Ogg stream. %s", errorString(result));
+    }
+
+    vorbisInfo = ov_info(&oggStream, -1);
+    vorbisComment = ov_comment(&oggStream, -1);
+
+    if(vorbisInfo->channels == 1)
+        format = AL_FORMAT_MONO16;
+    else
+        format = AL_FORMAT_STEREO16;
+
+
+    alGenBuffers(2, buffers);
+    check();
+    alGenSources(1, &source);
+    check();
+
+    alSource3f(source, AL_POSITION,        0.0, 0.0, 0.0);
+    alSource3f(source, AL_VELOCITY,        0.0, 0.0, 0.0);
+    alSource3f(source, AL_DIRECTION,       0.0, 0.0, 0.0);
+    alSourcef (source, AL_ROLLOFF_FACTOR,  0.0          );
+    alSourcei (source, AL_SOURCE_RELATIVE, AL_TRUE      );
+}
+
+
+
+
+void OggStream::release()
+{
+    alSourceStop(source);
+    empty();
+    alDeleteSources(1, &source);
+    check();
+    alDeleteBuffers(1, buffers);
+    check();
+
+    ov_clear(&oggStream);
+}
+
+
+
+
+void OggStream::display()
+{
+    cout
+        << "version         " << vorbisInfo->version         << "\n"
+        << "channels        " << vorbisInfo->channels        << "\n"
+        << "rate (hz)       " << vorbisInfo->rate            << "\n"
+        << "bitrate upper   " << vorbisInfo->bitrate_upper   << "\n"
+        << "bitrate nominal " << vorbisInfo->bitrate_nominal << "\n"
+        << "bitrate lower   " << vorbisInfo->bitrate_lower   << "\n"
+        << "bitrate window  " << vorbisInfo->bitrate_window  << "\n"
+        << "\n"
+        << "vendor " << vorbisComment->vendor << "\n";
+
+    for(int i = 0; i < vorbisComment->comments; i++)
+        cout << "   " << vorbisComment->user_comments[i] << "\n";
+
+    cout << endl;
+}
+
+
+
+
+bool OggStream::playback()
+{
+    if(playing())
+        return true;
+
+    if(!stream(buffers[0]))
+        return false;
+
+    if(!stream(buffers[1]))
+        return false;
+
+    alSourceQueueBuffers(source, 2, buffers);
+    alSourcePlay(source);
+
+    return true;
+}
+
+
+
+
+bool OggStream::playing()
+{
+    ALenum state;
+
+    alGetSourcei(source, AL_SOURCE_STATE, &state);
+
+    return (state == AL_PLAYING);
+}
+
+
+
+
+bool OggStream::update()
+{
+    int processed;
+    bool active = true;
+
+    alGetSourcei(source, AL_BUFFERS_PROCESSED, &processed);
+
+    while(processed--)
+    {
+        ALuint buffer;
+
+        alSourceUnqueueBuffers(source, 1, &buffer);
+        check();
+
+        active = stream(buffer);
+
+        alSourceQueueBuffers(source, 1, &buffer);
+        check();
+    }
+
+    return active;
+}
+
+
+
+
+bool OggStream::stream(ALuint buffer)
+{
+    char pcm[BUFFER_SIZE];
+    int  size = 0;
+    int  section;
+    int  result;
+
+    while(size < BUFFER_SIZE)
+    {
+        result = ov_read(&oggStream, pcm + size, BUFFER_SIZE - size, 0, 2, 1, &section);
+
+        if(result > 0)
+            size += result;
+        else
+            if(result < 0)
+                throw errorString(result);
+            else
+                break;
+    }
+
+    if(size == 0)
+        return false;
+
+    alBufferData(buffer, format, pcm, size, vorbisInfo->rate);
+    check();
+
+    return true;
+}
+
+
+
+
+void OggStream::empty()
+{
+    int queued;
+
+    alGetSourcei(source, AL_BUFFERS_QUEUED, &queued);
+
+    while(queued--)
+    {
+        ALuint buffer;
+
+        alSourceUnqueueBuffers(source, 1, &buffer);
+        check();
+    }
+}
+
+
+
+
+void OggStream::check()
+{
+        int error = alGetError();
+
+        if(error != AL_NO_ERROR)
+                PRINTF(2)("OpenAL error was raised.");
+}
+
+
+
+const char* OggStream::errorString(int code)
+{
+     switch(code)
+     {
+       case OV_EREAD:
+         return ("Read from media.");
+       case OV_ENOTVORBIS:
+         return ("Not Vorbis data.");
+       case OV_EVERSION:
+         return ("Vorbis version mismatch.");
+       case OV_EBADHEADER:
+         return ("Invalid Vorbis header.");
+       case OV_EFAULT:
+         return ("Internal logic fault (bug or heap/stack corruption.");
+       default:
+         return ("Unknown Ogg error.");
+     }
+}
Index: orxonox/trunk/src/lib/sound/ogg_player.h
===================================================================
--- orxonox/trunk/src/lib/sound/ogg_player.h	(revision 4750)
+++ orxonox/trunk/src/lib/sound/ogg_player.h	(revision 4750)
@@ -0,0 +1,55 @@
+/*!
+ * @file ogg_player.h
+ * @brief Ogg-Player definition
+ */
+
+
+#ifndef _OGG_PLAYER_H
+#define _OGG_PLAYER_H
+
+#include <string>
+#include <iostream>
+using namespace std;
+
+#include <AL/al.h>
+#include <ogg/ogg.h>
+#include <vorbis/vorbisfile.h>
+
+
+
+#define BUFFER_SIZE (4096 * 4)
+
+
+
+class OggStream
+{
+    public:
+
+        void open(string path);
+        void release();
+        void display();
+        bool playback();
+        bool playing();
+        bool update();
+
+    protected:
+
+        bool stream(ALuint buffer);
+        void empty();
+        void check();
+        const char* errorString(int code);
+
+    private:
+
+        FILE*             oggFile;
+        OggVorbis_File    oggStream;
+        vorbis_info*      vorbisInfo;
+        vorbis_comment*   vorbisComment;
+
+        ALuint            buffers[2];
+        ALuint            source;
+        ALenum            format;
+};
+
+
+#endif /* _OGG_PLAYER_H */
