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 Lesser General Public License as published by 00007 the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. 00014 00015 You should have received a copy of the GNU Lesser General Public License 00016 along with this program; if not, write to the Free Software 00017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 00019 */ 00020 00021 #ifndef __JackClient__ 00022 #define __JackClient__ 00023 00024 #include "JackClientInterface.h" 00025 #include "JackThread.h" 00026 #include "JackConstants.h" 00027 #include "JackSynchro.h" 00028 #include "JackPlatformPlug.h" 00029 #include "JackChannel.h" 00030 #include "types.h" 00031 #include "varargs.h" 00032 #include <list> 00033 00034 namespace Jack 00035 { 00036 00037 class JackGraphManager; 00038 class JackServer; 00039 class JackEngine; 00040 struct JackClientControl; 00041 struct JackEngineControl; 00042 00047 class JackClient : public JackClientInterface, public JackRunnableInterface 00048 { 00049 friend class JackDebugClient; 00050 00051 protected: 00052 00053 JackProcessCallback fProcess; 00054 JackGraphOrderCallback fGraphOrder; 00055 JackXRunCallback fXrun; 00056 JackShutdownCallback fShutdown; 00057 JackInfoShutdownCallback fInfoShutdown; 00058 JackThreadInitCallback fInit; 00059 JackBufferSizeCallback fBufferSize; 00060 JackSampleRateCallback fSampleRate; 00061 JackClientRegistrationCallback fClientRegistration; 00062 JackFreewheelCallback fFreewheel; 00063 JackPortRegistrationCallback fPortRegistration; 00064 JackPortConnectCallback fPortConnect; 00065 JackPortRenameCallback fPortRename; 00066 JackTimebaseCallback fTimebase; 00067 JackSyncCallback fSync; 00068 JackThreadCallback fThreadFun; 00069 00070 void* fProcessArg; 00071 void* fGraphOrderArg; 00072 void* fXrunArg; 00073 void* fShutdownArg; 00074 void* fInfoShutdownArg; 00075 void* fInitArg; 00076 void* fBufferSizeArg; 00077 void* fSampleRateArg; 00078 void* fClientRegistrationArg; 00079 void* fFreewheelArg; 00080 void* fPortRegistrationArg; 00081 void* fPortConnectArg; 00082 void* fPortRenameArg; 00083 void* fTimebaseArg; 00084 void* fSyncArg; 00085 void* fThreadFunArg; 00086 char fServerName[64]; 00087 00088 JackThread fThread; 00089 detail::JackClientChannelInterface* fChannel; 00090 JackSynchro* fSynchroTable; 00091 std::list<jack_port_id_t> fPortList; 00092 00093 int StartThread(); 00094 void SetupDriverSync(bool freewheel); 00095 bool IsActive(); 00096 00097 void CallSyncCallback(); 00098 void CallTimebaseCallback(); 00099 00100 virtual int ClientNotifyImp(int refnum, const char* name, int notify, int sync, const char* message, int value1, int value); 00101 00102 inline void DummyCycle(); 00103 inline void ExecuteThread(); 00104 inline bool WaitSync(); 00105 inline void SignalSync(); 00106 inline int CallProcessCallback(); 00107 inline void End(); 00108 inline void Error(); 00109 inline jack_nframes_t CycleWaitAux(); 00110 inline void CycleSignalAux(int status); 00111 inline void CallSyncCallbackAux(); 00112 inline void CallTimebaseCallbackAux(); 00113 inline int ActivateAux(); 00114 00115 public: 00116 00117 JackClient(); 00118 JackClient(JackSynchro* table); 00119 virtual ~JackClient(); 00120 00121 virtual int Open(const char* server_name, const char* name, jack_options_t options, jack_status_t* status) = 0; 00122 virtual int Close(); 00123 00124 virtual JackGraphManager* GetGraphManager() const = 0; 00125 virtual JackEngineControl* GetEngineControl() const = 0; 00126 00127 // Notifications 00128 virtual int ClientNotify(int refnum, const char* name, int notify, int sync, const char* message, int value1, int value2); 00129 00130 virtual int Activate(); 00131 virtual int Deactivate(); 00132 00133 // Context 00134 virtual int SetBufferSize(jack_nframes_t buffer_size); 00135 virtual int SetFreeWheel(int onoff); 00136 virtual void ShutDown(); 00137 virtual pthread_t GetThreadID(); 00138 00139 // Port management 00140 virtual int PortRegister(const char* port_name, const char* port_type, unsigned long flags, unsigned long buffer_size); 00141 virtual int PortUnRegister(jack_port_id_t port); 00142 00143 virtual int PortConnect(const char* src, const char* dst); 00144 virtual int PortDisconnect(const char* src, const char* dst); 00145 virtual int PortDisconnect(jack_port_id_t src); 00146 00147 virtual int PortIsMine(jack_port_id_t port_index); 00148 virtual int PortRename(jack_port_id_t port_index, const char* name); 00149 00150 // Transport 00151 virtual int ReleaseTimebase(); 00152 virtual int SetSyncCallback(JackSyncCallback sync_callback, void* arg); 00153 virtual int SetSyncTimeout(jack_time_t timeout); 00154 virtual int SetTimebaseCallback(int conditional, JackTimebaseCallback timebase_callback, void* arg); 00155 virtual void TransportLocate(jack_nframes_t frame); 00156 virtual jack_transport_state_t TransportQuery(jack_position_t* pos); 00157 virtual jack_nframes_t GetCurrentTransportFrame(); 00158 virtual int TransportReposition(jack_position_t* pos); 00159 virtual void TransportStart(); 00160 virtual void TransportStop(); 00161 00162 // Callbacks 00163 virtual void OnShutdown(JackShutdownCallback callback, void *arg); 00164 virtual void OnInfoShutdown(JackInfoShutdownCallback callback, void *arg); 00165 virtual int SetProcessCallback(JackProcessCallback callback, void* arg); 00166 virtual int SetXRunCallback(JackXRunCallback callback, void* arg); 00167 virtual int SetInitCallback(JackThreadInitCallback callback, void* arg); 00168 virtual int SetGraphOrderCallback(JackGraphOrderCallback callback, void* arg); 00169 virtual int SetBufferSizeCallback(JackBufferSizeCallback callback, void* arg); 00170 virtual int SetSampleRateCallback(JackBufferSizeCallback callback, void* arg); 00171 virtual int SetClientRegistrationCallback(JackClientRegistrationCallback callback, void* arg); 00172 virtual int SetFreewheelCallback(JackFreewheelCallback callback, void* arg); 00173 virtual int SetPortRegistrationCallback(JackPortRegistrationCallback callback, void* arg); 00174 virtual int SetPortConnectCallback(JackPortConnectCallback callback, void *arg); 00175 virtual int SetPortRenameCallback(JackPortRenameCallback callback, void *arg); 00176 00177 // Internal clients 00178 virtual char* GetInternalClientName(int ref); 00179 virtual int InternalClientHandle(const char* client_name, jack_status_t* status); 00180 virtual int InternalClientLoad(const char* client_name, jack_options_t options, jack_status_t* status, jack_varargs_t* va); 00181 virtual void InternalClientUnload(int ref, jack_status_t* status); 00182 00183 jack_nframes_t CycleWait(); 00184 void CycleSignal(int status); 00185 int SetProcessThread(JackThreadCallback fun, void *arg); 00186 00187 // JackRunnableInterface interface 00188 bool Init(); 00189 bool Execute(); 00190 }; 00191 00192 } // end of namespace 00193 00194 #endif