Jack2  1.9.8
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         PortAudioDevices* fPaDevices;
00040         PaStream* fStream;
00041         jack_default_audio_sample_t** fInputBuffer;
00042         jack_default_audio_sample_t** fOutputBuffer;
00043         PaDeviceIndex fInputDevice;
00044         PaDeviceIndex fOutputDevice;
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 
00055     public:
00056 
00057         JackPortAudioDriver(const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table, PortAudioDevices* pa_devices)
00058                 : JackMMCSS(), JackAudioDriver(name, alias, engine, table), fStream(NULL), fInputBuffer(NULL), fOutputBuffer(NULL),
00059                 fInputDevice(paNoDevice), fOutputDevice(paNoDevice)
00060         {
00061             fPaDevices = pa_devices;
00062         }
00063 
00064         virtual ~JackPortAudioDriver()
00065         {
00066             delete fPaDevices;
00067         }
00068 
00069         int Open(jack_nframes_t buffe_size,
00070                  jack_nframes_t samplerate,
00071                  bool capturing,
00072                  bool playing,
00073                  int chan_in,
00074                  int chan_out,
00075                  bool monitor,
00076                  const char* capture_driver_name,
00077                  const char* playback_driver_name,
00078                  jack_nframes_t capture_latency,
00079                  jack_nframes_t playback_latency);
00080 
00081         int Close();
00082 
00083         int Start();
00084         int Stop();
00085 
00086         int Read();
00087         int Write();
00088 
00089         // BufferSize can be changed
00090         bool IsFixedBufferSize()
00091         {
00092             return false;
00093         }
00094 
00095         int SetBufferSize(jack_nframes_t buffer_size);
00096 };
00097 
00098 } // end of namespace
00099 
00100 #endif