Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

output_al.hpp

Go to the documentation of this file.
00001 #ifndef OUTPUT_AL_HPP
00002 #define OUTPUT_AL_HPP
00003 
00004 
00005 #include <list>
00006 #include <AL/al.h>
00007 #include <AL/alc.h>
00008 #include "input.hpp"
00009 #include "output.hpp"
00010 
00011 
00012 // XXX hack around the fact that the Linux headers don't have ALCcontext yet
00013 #ifndef _WIN32
00014 typedef void ALCcontext;
00015 #endif
00016 
00017 
00018 class ALOutputStream;
00019 
00020 
00021 class ALOutputContext : public IOutputContext
00022 {
00023 public:
00024   ALOutputContext();
00025   ~ALOutputContext();
00026 
00027   bool Initialize(const char* parameters);
00028   void Update();
00029   IOutputStream* OpenStream(ISampleSource* source);
00030 
00031 private:
00032   ALCdevice*  m_Device;
00033   ALCcontext* m_Context;
00034 
00035   typedef std::list<ALOutputStream*> StreamList;
00036   StreamList m_OpenStreams;
00037 
00038   friend class ALOutputStream;
00039 };
00040 
00041 
00042 class ALOutputStream : public IOutputStream
00043 {
00044 public:
00045   void Play();
00046   void Stop();
00047   void Reset();
00048   bool IsPlaying();
00049   void SetVolume(int volume);
00050   int  GetVolume();
00051 
00052 private:
00053   ALOutputStream(
00054     ALOutputContext* context,
00055     ISampleSource* source,
00056     ALuint al_source,
00057     ALuint* buffers,
00058     ALenum format,
00059     int sample_rate);
00060   ~ALOutputStream();
00061   void Update();
00062 
00063   int Read(void* samples, int sample_count);
00064   void FillBuffers();
00065 
00066 private:
00067   ALOutputContext* m_Context;
00068 
00069   // sample stream
00070   ISampleSource* m_Source;
00071 
00072   // informational (convenience)
00073   ALenum m_Format;
00074   int    m_SampleSize;  // (num channels * bits per sample / 8)
00075   int    m_SampleRate;
00076 
00077   // the last sample read
00078   ALubyte* m_LastSample;  
00079   
00080   // AL objects
00081   ALuint  m_ALSource;
00082   ALuint* m_Buffers;
00083 
00084   int m_BufferLength;  // in samples
00085   bool m_IsPlaying;
00086   int m_Volume;
00087 
00088   friend class ALOutputContext;
00089 };
00090 
00091 
00092 #endif

Generated at Mon Jun 10 02:55:12 2002 for audiere by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001