• Main Page
  • Classes
  • Files
  • File List

jackblockingaudioio.hpp

00001 //C++ Classes that wrap JACK
00002 //Copyright 2007 Alex Norman
00003 //
00004 //This file is part of JACKC++.
00005 //
00006 //JACKC++ is free software: you can redistribute it and/or modify
00007 //it under the terms of the GNU General Public License as published by
00008 //the Free Software Foundation, either version 3 of the License, or
00009 //(at your option) any later version.
00010 //
00011 //JACKC++ is distributed in the hope that it will be useful,
00012 //but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //GNU General Public License for more details.
00015 //
00016 //You should have received a copy of the GNU General Public License
00017 //along with JACKC++.  If not, see <http://www.gnu.org/licenses/>.
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                         //XXX reserve exists but is basically useless as you cannot
00115                         //add ports while the client is active
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                         //this is the size of the ring buffers that we alloc
00167                         const unsigned int mOutputBufferMaxSize;
00168                         const unsigned int mInputBufferMaxSize;
00169                         //this is the amount of free space we leave in the ring buffers
00170                         //this can decrease so that we'll have more latency but fewer glitches
00171                         unsigned int mOutputBufferFreeSize;
00172                         unsigned int mInputBufferFreeSize;
00173         };
00174 }
00175 #endif
00176 

Generated on Wed Apr 20 2011 13:46:10 for JackCpp by  doxygen 1.7.1