Back to index

supertuxkart  0.5+dfsg1
music_ogg.hpp
Go to the documentation of this file.
00001 //  $Id$
00002 //
00003 //  SuperTuxKart - a fun racing game with go-kart
00004 //  Copyright (C) 2007 Damien Morel <divdams@free.fr>
00005 //
00006 //  This program is free software; you can redistribute it and/or
00007 //  modify it under the terms of the GNU General Public License
00008 //  as published by the Free Software Foundation; either version 2
00009 //  of the License, or (at your option) any later version.
00010 //
00011 //  This program is distributed in the hope that it will be useful,
00012 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //  GNU General Public License for more details.
00015 //
00016 //  You should have received a copy of the GNU General Public License
00017 //  along with this program; if not, write to the Free Software
00018 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019 
00020 #ifndef HEADER_MUSICOGG_H
00021 #define HEADER_MUSICOGG_H
00022 
00023 #include <string>
00024 #include <iostream>
00025 using namespace std;
00026 
00027 #include <ogg/ogg.h>
00028 #include <vorbis/vorbisfile.h>
00029 #ifdef __APPLE__
00030 #  include <OpenAL/al.h>
00031 #else
00032 #  include <AL/al.h>
00033 #endif
00034 #include "music.hpp"
00035 
00036 class MusicOggStream : public Music
00037 {
00038 public:
00039     MusicOggStream();
00040     virtual ~MusicOggStream();
00041 
00042     virtual void update();
00043     virtual void updateFading(float percent);
00044     virtual void updateFaster(float percent, float max_pitch);
00045 
00046     virtual bool load(const std::string& filename);
00047 
00048     virtual bool playMusic();
00049     virtual bool stopMusic();
00050     virtual bool pauseMusic();
00051     virtual bool resumeMusic();
00052 
00053 
00054 protected:
00055     bool empty();
00056     bool check();
00057     string errorString(int code);
00058 
00059 private:
00060     bool release();
00061     bool isPlaying();
00062     bool streamIntoBuffer(ALuint buffer);
00063 
00064     string          m_fileName;
00065     FILE*           m_oggFile;
00066     OggVorbis_File  m_oggStream;
00067     vorbis_info*    m_vorbisInfo;
00068     bool            m_error;
00069 
00070     ALuint m_soundBuffers[2];
00071     ALuint m_soundSource;
00072     ALenum nb_channels;
00073 
00074     bool m_pausedMusic;
00075 };
00076 
00077 #endif // HEADER_MUSICOGG_H