src/audio/stream_sound_source.hpp

Go to the documentation of this file.
00001 //  SuperTux
00002 //  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
00003 //
00004 //  This program is free software: you can redistribute it and/or modify
00005 //  it under the terms of the GNU General Public License as published by
00006 //  the Free Software Foundation, either version 3 of the License, or
00007 //  (at your option) any later version.
00008 //
00009 //  This program is distributed in the hope that it will be useful,
00010 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 //  GNU General Public License for more details.
00013 //
00014 //  You should have received a copy of the GNU General Public License
00015 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016 
00017 #ifndef HEADER_SUPERTUX_AUDIO_STREAM_SOUND_SOURCE_HPP
00018 #define HEADER_SUPERTUX_AUDIO_STREAM_SOUND_SOURCE_HPP
00019 
00020 #include "audio/openal_sound_source.hpp"
00021 
00022 class SoundFile;
00023 
00024 class StreamSoundSource : public OpenALSoundSource
00025 {
00026 public:
00027   StreamSoundSource();
00028   virtual ~StreamSoundSource();
00029 
00030   void set_sound_file(SoundFile* file);
00031 
00032   enum FadeState { NoFading, FadingOn, FadingOff };
00033 
00034   void set_fading(FadeState state, float fadetime);
00035   FadeState get_fade_state() const
00036   {
00037     return fade_state;
00038   }
00039   void update();
00040 
00041   void set_looping(bool looping)
00042   {
00043     this->looping = looping;
00044   }
00045   bool get_looping() const
00046   {
00047     return looping;
00048   }
00049 
00050 private:
00051   static const size_t STREAMBUFFERSIZE = 1024 * 500;
00052   static const size_t STREAMFRAGMENTS = 5;
00053   static const size_t STREAMFRAGMENTSIZE
00054   = STREAMBUFFERSIZE / STREAMFRAGMENTS;
00055 
00056   bool fillBufferAndQueue(ALuint buffer);
00057   SoundFile* file;
00058   ALuint buffers[STREAMFRAGMENTS];
00059 
00060   FadeState fade_state;
00061   float fade_start_time;
00062   float fade_time;
00063   bool looping;
00064 
00065 private:
00066   StreamSoundSource(const StreamSoundSource&);
00067   StreamSoundSource& operator=(const StreamSoundSource&);
00068 };
00069 
00070 #endif
00071 
00072 /* EOF */

Generated on Mon Jun 9 03:38:16 2014 for SuperTux by  doxygen 1.5.1