SoundPlayer.h

Go to the documentation of this file.
00001 #ifndef SOUNDPLAYER_H_
00002 #define SOUNDPLAYER_H_
00003 
00004 #include <string>
00005 #include "OpenAL.h"
00006 #include "gtkutil/timer.h"
00007 
00008 class ArchiveFile;
00009 
00010 namespace sound
00011 {
00012 
00013     class SoundPlayer
00014     {
00015         protected:
00016             // Are we set up yet? Defer initialisation until we play something.
00017             bool _initialised;
00018 
00019             ALCcontext* _context;
00020 
00021             // The buffer containing the currently played audio data
00022             ALuint _buffer;
00023 
00024             // The source playing the buffer
00025             ALuint _source;
00026 
00027             // The timer object to check whether the sound is done playing
00028             // to destroy the buffer afterwards
00029             gtkutil::Timer _timer;
00030 
00031         public:
00032             // Constructor
00033             SoundPlayer ();
00034 
00038             virtual ~SoundPlayer ();
00039 
00043             virtual void play (ArchiveFile& file);
00044 
00047             virtual void stop ();
00048 
00049         protected:
00050             // Initialises the AL context
00051             void initialise ();
00052 
00053             // Clears the buffer, stops playing
00054             void clearBuffer ();
00055 
00056             // This is called periodically to check whether the buffer can be cleared
00057             static gboolean checkBuffer (gpointer data);
00058     };
00059 
00060 } // namespace sound
00061 
00062 #endif /*SOUNDPLAYER_H_*/

Generated by  doxygen 1.6.2