00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef SUBSYNTH_OPENAL_AUDIO_STREAM
00033 #define SUBSYNTH_OPENAL_AUDIO_STREAM
00034
00035 #ifdef HAVE_VPR
00036 # include "vpr/vpr.h"
00037 # ifdef VPR_USE_IRIX_SPROC
00038 #error "VPR_USE_IRIX_SPROC: you idiot"
00039 # endif
00040 #endif
00041
00042 #include "syn/Util/AudioFormat.h"
00043 #include "syn/Stream/AudioContext.h"
00044 #include "syn/Stream/AudioOStream.h"
00045
00046 namespace syn
00047 {
00051 class OpenALAudioOStream : public AudioOStream
00052 {
00053 public:
00054 OpenALAudioOStream();
00055 virtual ~OpenALAudioOStream(){}
00056
00057 void setContext( syn::AudioContext& ctx )
00058 {
00059 mCtx = &ctx;
00060 }
00061
00065 virtual bool open( const syn::AudioFormat& fmt );
00066
00067
00068 virtual bool isOpen() { return mIsOpen; }
00069
00071 void resizeBuffers( signed int numBuffers = 2 );
00072
00074 virtual bool canAcceptMoreData() const;
00075
00080 virtual bool write( const void* const data, signed int size );
00081
00083 virtual int pcount() const { return mPcount; }
00084
00086 virtual bool close();
00087
00088
00089 virtual void flush();
00090
00092 virtual const syn::AudioFormat& format() const
00093 {
00094 return mFmt;
00095 }
00096
00097 private:
00098
00099 bool isPlaying() const;
00100
00101 std::vector<unsigned int> mBuffers;
00102 unsigned int mFormat;
00103 std::vector<unsigned int> mSources;
00104 signed int mSampRate;
00105 bool mIsOpen;
00106 syn::AudioFormat mFmt;
00107 unsigned int mBufferHackSwitch;
00108 syn::AudioContext* mCtx;
00109 signed int mPcount;
00110 };
00111 }
00112
00113
00114 #endif