FIFE  2008.0
 All Classes Namespaces Functions Variables Enumerations Enumerator
sounddecoder.h
00001 /***************************************************************************
00002  *   Copyright (C) 2005-2008 by the FIFE team                              *
00003  *   http://www.fifengine.de                                               *
00004  *   This file is part of FIFE.                                            *
00005  *                                                                         *
00006  *   FIFE is free software; you can redistribute it and/or                 *
00007  *   modify it under the terms of the GNU Lesser General Public            *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2.1 of the License, or (at your option) any later version.    *
00010  *                                                                         *
00011  *   This library 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 GNU     *
00014  *   Lesser General Public License for more details.                       *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Lesser General Public      *
00017  *   License along with this library; if not, write to the                 *
00018  *   Free Software Foundation, Inc.,                                       *
00019  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
00020  ***************************************************************************/
00021 
00022 #ifndef FIFE_SOUNDDECODER_H
00023 #define FIFE_SOUNDDECODER_H
00024 
00025 // Standard C++ library includes
00026 
00027 // Platform specific includes
00028 
00029 // 3rd party library includes
00030 
00031 // FIFE includes
00032 // These includes are split up in two parts, separated by one empty line
00033 // First block: files included from the FIFE root src directory
00034 // Second block: files included from the same folder
00035 
00036 #include "soundconfig.h"
00037 #include "fife_openal.h"
00038 
00039 namespace FIFE {
00040     
00041     class SoundDecoder {
00042     public:
00043         
00044         virtual ~SoundDecoder() {}
00045         
00048         virtual unsigned long getDecodedLength() const = 0;
00049         
00059         bool needsStreaming() const { return getDecodedLength() > MAX_KEEP_IN_MEM; }
00060         
00065         virtual bool setCursor(unsigned long pos) = 0;
00066         
00072         virtual bool decode(unsigned long length) = 0;
00073         
00078         virtual void *getBuffer() const = 0;
00079         
00082         virtual unsigned long getBufferSize() = 0;
00083         
00086         virtual void releaseBuffer() = 0;
00087         
00092         bool isStereo() const {
00093             return m_isstereo;
00094         }
00095         
00098         ALenum getALFormat() const {
00099             if (m_isstereo) {
00100                 return m_is8bit ? AL_FORMAT_STEREO8 : AL_FORMAT_STEREO16;
00101             } else {
00102                 return m_is8bit ? AL_FORMAT_MONO8 : AL_FORMAT_MONO16;
00103             }
00104         }
00105         
00108         short getBitResolution() const {
00109             return m_is8bit ? 8 : 16; 
00110         }
00111         
00114         unsigned long getSampleRate() const{
00115             return m_samplerate;
00116         }
00117         
00118     protected:
00119         bool                    m_isstereo;
00120         bool                    m_is8bit;
00121         unsigned long   m_samplerate;
00122     };
00123 }
00124 
00125 #endif