Jack2 1.9.6
|
00001 /* 00002 Copyright (C) 2001 Paul Davis 00003 Copyright (C) 2004-2008 Grame 00004 00005 This program is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 2 of the License, or 00008 (at your option) any later version. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with this program; if not, write to the Free Software 00017 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00018 00019 */ 00020 00021 #ifndef __JackDriver__ 00022 #define __JackDriver__ 00023 00024 #include "types.h" 00025 #include "JackClientInterface.h" 00026 #include "JackConstants.h" 00027 #include "JackPlatformPlug.h" 00028 #include "JackClientControl.h" 00029 #include <list> 00030 00031 namespace Jack 00032 { 00033 00034 class JackLockedEngine; 00035 class JackGraphManager; 00036 struct JackEngineControl; 00037 00042 class SERVER_EXPORT JackDriverInterface 00043 { 00044 00045 public: 00046 00047 JackDriverInterface() 00048 {} 00049 virtual ~JackDriverInterface() 00050 {} 00051 00052 virtual int Open() = 0; 00053 00054 virtual int Open (bool capturing, 00055 bool playing, 00056 int inchannels, 00057 int outchannels, 00058 bool monitor, 00059 const char* capture_driver_name, 00060 const char* playback_driver_name, 00061 jack_nframes_t capture_latency, 00062 jack_nframes_t playback_latency) = 0; 00063 00064 virtual int Open(jack_nframes_t buffer_size, 00065 jack_nframes_t samplerate, 00066 bool capturing, 00067 bool playing, 00068 int inchannels, 00069 int outchannels, 00070 bool monitor, 00071 const char* capture_driver_name, 00072 const char* playback_driver_name, 00073 jack_nframes_t capture_latency, 00074 jack_nframes_t playback_latency) = 0; 00075 00076 virtual int Attach() = 0; 00077 virtual int Detach() = 0; 00078 00079 virtual int Read() = 0; 00080 virtual int Write() = 0; 00081 00082 virtual int Start() = 0; 00083 virtual int Stop() = 0; 00084 00085 virtual bool IsFixedBufferSize() = 0; 00086 virtual int SetBufferSize(jack_nframes_t buffer_size) = 0; 00087 virtual int SetSampleRate(jack_nframes_t sample_rate) = 0; 00088 00089 virtual int Process() = 0; 00090 virtual int ProcessNull() = 0; 00091 00092 virtual void SetMaster(bool onoff) = 0; 00093 virtual bool GetMaster() = 0; 00094 virtual void AddSlave(JackDriverInterface* slave) = 0; 00095 virtual void RemoveSlave(JackDriverInterface* slave) = 0; 00096 virtual std::list<JackDriverInterface*> GetSlaves() = 0; 00097 virtual int ProcessSlaves() = 0; 00098 00099 virtual bool IsRealTime() const = 0; 00100 }; 00101 00106 class SERVER_EXPORT JackDriverClientInterface : public JackDriverInterface, public JackClientInterface 00107 {}; 00108 00113 #define CaptureDriverFlags static_cast<JackPortFlags>(JackPortIsOutput | JackPortIsPhysical | JackPortIsTerminal | JackPortIsActive) 00114 #define PlaybackDriverFlags static_cast<JackPortFlags>(JackPortIsInput | JackPortIsPhysical | JackPortIsTerminal | JackPortIsActive) 00115 #define MonitorDriverFlags static_cast<JackPortFlags>(JackPortIsOutput | JackPortIsActive) 00116 00117 class SERVER_EXPORT JackDriver : public JackDriverClientInterface 00118 { 00119 00120 protected: 00121 00122 char fCaptureDriverName[JACK_CLIENT_NAME_SIZE + 1]; 00123 char fPlaybackDriverName[JACK_CLIENT_NAME_SIZE + 1]; 00124 char fAliasName[JACK_CLIENT_NAME_SIZE + 1]; 00125 jack_nframes_t fCaptureLatency; 00126 jack_nframes_t fPlaybackLatency; 00127 jack_time_t fBeginDateUst; 00128 jack_time_t fEndDateUst; 00129 float fDelayedUsecs; 00130 JackLockedEngine* fEngine; 00131 JackGraphManager* fGraphManager; 00132 JackSynchro* fSynchroTable; 00133 JackEngineControl* fEngineControl; 00134 JackClientControl fClientControl; 00135 std::list<JackDriverInterface*> fSlaveList; 00136 bool fIsMaster; 00137 00138 void CycleIncTime(); 00139 void CycleTakeBeginTime(); 00140 void CycleTakeEndTime(); 00141 00142 void SetupDriverSync(int ref, bool freewheel); 00143 00144 void NotifyXRun(jack_time_t callback_usecs, float delayed_usecs); // XRun notification sent by the driver 00145 void NotifyBufferSize(jack_nframes_t buffer_size); // BufferSize notification sent by the driver 00146 void NotifySampleRate(jack_nframes_t sample_rate); // SampleRate notification sent by the driver 00147 void NotifyFailure(int code, const char* reason); // Failure notification sent by the driver 00148 00149 public: 00150 00151 JackDriver(const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table); 00152 JackDriver(); 00153 virtual ~JackDriver(); 00154 00155 void SetMaster(bool onoff); 00156 bool GetMaster(); 00157 00158 void AddSlave(JackDriverInterface* slave); 00159 void RemoveSlave(JackDriverInterface* slave); 00160 std::list<JackDriverInterface*> GetSlaves() 00161 { 00162 return fSlaveList; 00163 } 00164 int ProcessSlaves(); 00165 00166 virtual int Open(); 00167 00168 virtual int Open (bool capturing, 00169 bool playing, 00170 int inchannels, 00171 int outchannels, 00172 bool monitor, 00173 const char* capture_driver_name, 00174 const char* playback_driver_name, 00175 jack_nframes_t capture_latency, 00176 jack_nframes_t playback_latency); 00177 00178 virtual int Open(jack_nframes_t buffer_size, 00179 jack_nframes_t samplerate, 00180 bool capturing, 00181 bool playing, 00182 int inchannels, 00183 int outchannels, 00184 bool monitor, 00185 const char* capture_driver_name, 00186 const char* playback_driver_name, 00187 jack_nframes_t capture_latency, 00188 jack_nframes_t playback_latency); 00189 virtual int Close(); 00190 00191 virtual int Process(); 00192 virtual int ProcessNull(); 00193 00194 virtual int Attach(); 00195 virtual int Detach(); 00196 00197 virtual int Read(); 00198 virtual int Write(); 00199 00200 virtual int Start(); 00201 virtual int Stop(); 00202 00203 virtual bool IsFixedBufferSize(); 00204 virtual int SetBufferSize(jack_nframes_t buffer_size); 00205 virtual int SetSampleRate(jack_nframes_t sample_rate); 00206 00207 virtual int ClientNotify(int refnum, const char* name, int notify, int sync, const char* message, int value1, int value2); 00208 virtual JackClientControl* GetClientControl() const; 00209 00210 virtual bool IsRealTime() const; 00211 virtual bool Initialize(); // To be called by the wrapping thread Init method when the driver is a "blocking" one 00212 00213 }; 00214 00215 } // end of namespace 00216 00217 #endif