00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef JACK_BLOCKING_AUDIO_IO_HPP
00020 #define JACK_BLOCKING_AUDIO_IO_HPP
00021
00022 #include "jackaudioio.hpp"
00023 #include "jackringbuffer.hpp"
00024
00025 namespace JackCpp {
00026
00038 class BlockingAudioIO : public AudioIO {
00039 public:
00050 BlockingAudioIO(std::string name,
00051 unsigned int inChans = 2, unsigned int outChans = 2,
00052 unsigned int inBufSize = 0, unsigned int outBufSize = 0,
00053 #ifdef __APPLE__
00054 bool startServer = false)
00055 #else
00056 bool startServer = true)
00057 #endif
00058 throw(std::runtime_error);
00059 virtual ~BlockingAudioIO();
00060
00072 void write(unsigned int channel, jack_default_audio_sample_t val);
00073
00086 bool tryWrite(unsigned int channel, jack_default_audio_sample_t val);
00087
00098 jack_default_audio_sample_t read(unsigned int channel);
00099
00112 bool tryRead(unsigned int channel, jack_default_audio_sample_t &val);
00113
00114
00115
00117 virtual void reserveOutPorts(unsigned int num)
00118 throw(std::runtime_error);
00120 virtual void reserveInPorts(unsigned int num)
00121 throw(std::runtime_error);
00122
00132 virtual unsigned int addInPort(std::string name)
00133 throw(std::runtime_error);
00143 virtual unsigned int addOutPort(std::string name)
00144 throw(std::runtime_error);
00145
00146 protected:
00159 virtual int audioCallback(jack_nframes_t nframes,
00160 std::vector<jack_default_audio_sample_t *> inBufs,
00161 std::vector<jack_default_audio_sample_t *> outBufs);
00162 private:
00163 std::vector<RingBuffer<jack_default_audio_sample_t> *> mUserOutBuff;
00164 std::vector<RingBuffer<jack_default_audio_sample_t> *> mUserInBuff;
00165
00166
00167 const unsigned int mOutputBufferMaxSize;
00168 const unsigned int mInputBufferMaxSize;
00169
00170
00171 unsigned int mOutputBufferFreeSize;
00172 unsigned int mInputBufferFreeSize;
00173 };
00174 }
00175 #endif
00176