Jack2  1.9.10
JackPortAudioDriver.h
00001 /*
00002 Copyright (C) 2004-2008 Grame
00003 
00004 This program is free software; you can redistribute it and/or modify
00005 it under the terms of the GNU General Public License as published by
00006 the Free Software Foundation; either version 2 of the License, or
00007 (at your option) any later version.
00008 
00009 This program is distributed in the hope that it will be useful,
00010 but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 GNU General Public License for more details.
00013 
00014 You should have received a copy of the GNU General Public License
00015 along with this program; if not, write to the Free Software
00016 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017 
00018 */
00019 
00020 #ifndef __JackPortAudioDriver__
00021 #define __JackPortAudioDriver__
00022 
00023 #include "JackAudioDriver.h"
00024 #include "JackPortAudioDevices.h"
00025 #include "JackMMCSS.h"
00026 
00027 namespace Jack
00028 {
00029 
00034 class JackPortAudioDriver : public JackMMCSS, public JackAudioDriver
00035 {
00036 
00037     private:
00038 
00039         PaStream* fStream;
00040         jack_default_audio_sample_t** fInputBuffer;
00041         jack_default_audio_sample_t** fOutputBuffer;
00042         PaDeviceIndex fInputDevice;
00043         PaDeviceIndex fOutputDevice;
00044         PortAudioDevices* fPaDevices;
00045 
00046         static int Render(const void* inputBuffer, void* outputBuffer,
00047                           unsigned long framesPerBuffer,
00048                           const PaStreamCallbackTimeInfo* timeInfo,
00049                           PaStreamCallbackFlags statusFlags,
00050                           void* userData);
00051 
00052         PaError OpenStream(jack_nframes_t buffer_size);
00053         void UpdateLatencies();
00054         int Render(const void* inputBuffer, void* outputBuffer, PaStreamCallbackFlags statusFlags);
00055 
00056     public:
00057 
00058         JackPortAudioDriver(const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table, PortAudioDevices* pa_devices)
00059                 : JackMMCSS(), JackAudioDriver(name, alias, engine, table), fStream(NULL), fInputBuffer(NULL), fOutputBuffer(NULL),
00060                 fInputDevice(paNoDevice), fOutputDevice(paNoDevice), fPaDevices(pa_devices)
00061         {}
00062 
00063         virtual ~JackPortAudioDriver()
00064         {
00065             delete fPaDevices;
00066         }
00067 
00068         int Open(jack_nframes_t buffe_size,
00069                  jack_nframes_t samplerate,
00070                  bool capturing,
00071                  bool playing,
00072                  int chan_in,
00073                  int chan_out,
00074                  bool monitor,
00075                  const char* capture_driver_name,
00076                  const char* playback_driver_name,
00077                  jack_nframes_t capture_latency,
00078                  jack_nframes_t playback_latency);
00079 
00080         int Close();
00081 
00082         int Attach();
00083 
00084         int Start();
00085         int Stop();
00086 
00087         int Read();
00088         int Write();
00089 
00090         // BufferSize can be changed
00091         bool IsFixedBufferSize()
00092         {
00093             return false;
00094         }
00095 
00096         int SetBufferSize(jack_nframes_t buffer_size);
00097 };
00098 
00099 } // end of namespace
00100 
00101 #endif