Jack2  1.9.10
JackDebugClient.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 Lesser General Public License as published by
00006 the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
00013 
00014 You should have received a copy of the GNU Lesser General Public License
00015 along with this program; if not, write to the Free Software
00016 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017 
00018 */
00019 
00020 #ifndef __JackDebugClient__
00021 #define __JackDebugClient__
00022 
00023 #define MAX_PORT_HISTORY 2048
00024 
00025 #include "JackClient.h"
00026 #include <list>
00027 #include <fstream>
00028 
00029 namespace Jack
00030 {
00031 
00036 typedef struct
00037 {
00038     jack_port_id_t idport;
00039     char name[JACK_PORT_NAME_SIZE]; //portname
00040     int IsConnected;
00041     int IsUnregistered;
00042 }
00043 PortFollower;
00044 
00049 class JackDebugClient : public JackClient
00050 {
00051     protected:
00052 
00053         JackClient* fClient;
00054         std::ofstream* fStream;
00055         PortFollower fPortList[MAX_PORT_HISTORY]; // Arbitrary value... To be tuned...
00056         int fTotalPortNumber;   // The total number of port opened and maybe closed. Historical view.
00057         int fOpenPortNumber;    // The current number of opened port.
00058         int fIsActivated;
00059         int fIsDeactivated;
00060         int fIsClosed;
00061         bool fFreewheel;
00062         char fClientName[JACK_CLIENT_NAME_SIZE + 1];
00063         JackProcessCallback fProcessTimeCallback;
00064         void* fProcessTimeCallbackArg;
00065 
00066     public:
00067 
00068         JackDebugClient(JackClient* fTheClient);
00069         virtual ~JackDebugClient();
00070 
00071         virtual int Open(const char* server_name, const char* name, int uuid, jack_options_t options, jack_status_t* status);
00072         int Close();
00073 
00074         virtual JackGraphManager* GetGraphManager() const;
00075         virtual JackEngineControl* GetEngineControl() const;
00076 
00077         // Notifications
00078         int ClientNotify(int refnum, const char* name, int notify, int sync, const char* message, int value1, int value2);
00079 
00080         int Activate();
00081         int Deactivate();
00082 
00083         // Context
00084         int SetBufferSize(jack_nframes_t buffer_size);
00085         int SetFreeWheel(int onoff);
00086         int ComputeTotalLatencies();
00087         void ShutDown(jack_status_t code, const char* message);
00088         jack_native_thread_t GetThreadID();
00089 
00090         // Port management
00091         int PortRegister(const char* port_name, const char* port_type, unsigned long flags, unsigned long buffer_size);
00092         int PortUnRegister(jack_port_id_t port);
00093 
00094         int PortConnect(const char* src, const char* dst);
00095         int PortDisconnect(const char* src, const char* dst);
00096         int PortDisconnect(jack_port_id_t src);
00097 
00098         int PortIsMine(jack_port_id_t port_index);
00099         int PortRename(jack_port_id_t port_index, const char* name);
00100 
00101         // Transport
00102         int ReleaseTimebase();
00103         int SetSyncCallback(JackSyncCallback sync_callback, void* arg);
00104         int SetSyncTimeout(jack_time_t timeout);
00105         int SetTimebaseCallback(int conditional, JackTimebaseCallback timebase_callback, void* arg);
00106         void TransportLocate(jack_nframes_t frame);
00107         jack_transport_state_t TransportQuery(jack_position_t* pos);
00108         jack_nframes_t GetCurrentTransportFrame();
00109         int TransportReposition(const jack_position_t* pos);
00110         void TransportStart();
00111         void TransportStop();
00112 
00113         // Callbacks
00114         void OnShutdown(JackShutdownCallback callback, void *arg);
00115         void OnInfoShutdown(JackInfoShutdownCallback callback, void *arg);
00116         int SetProcessCallback(JackProcessCallback callback, void* arg);
00117         int SetXRunCallback(JackXRunCallback callback, void* arg);
00118         int SetInitCallback(JackThreadInitCallback callback, void* arg);
00119         int SetGraphOrderCallback(JackGraphOrderCallback callback, void* arg);
00120         int SetBufferSizeCallback(JackBufferSizeCallback callback, void* arg);
00121         int SetClientRegistrationCallback(JackClientRegistrationCallback callback, void* arg);
00122         int SetFreewheelCallback(JackFreewheelCallback callback, void* arg);
00123         int SetPortRegistrationCallback(JackPortRegistrationCallback callback, void* arg);
00124         int SetPortConnectCallback(JackPortConnectCallback callback, void *arg);
00125         int SetPortRenameCallback(JackPortRenameCallback callback, void *arg);
00126         int SetSessionCallback(JackSessionCallback callback, void *arg);
00127         int SetLatencyCallback(JackLatencyCallback callback, void *arg);
00128 
00129         // Internal clients
00130         char* GetInternalClientName(int ref);
00131         int InternalClientHandle(const char* client_name, jack_status_t* status);
00132         int InternalClientLoad(const char* client_name, jack_options_t options, jack_status_t* status, jack_varargs_t* va);
00133         void InternalClientUnload(int ref, jack_status_t* status);
00134         
00135         // RT Thread
00136         int SetProcessThread(JackThreadCallback fun, void *arg);
00137 
00138         // Session API
00139         jack_session_command_t* SessionNotify(const char* target, jack_session_event_type_t type, const char* path);
00140         int SessionReply(jack_session_event_t* ev);
00141         char* GetUUIDForClientName(const char* client_name);
00142         char* GetClientNameByUUID(const char* uuid);
00143         int ReserveClientName(const char* client_name, const char* uuid);
00144         int ClientHasSessionCallback(const char* client_name);
00145 
00146         JackClientControl* GetClientControl() const;
00147         void CheckClient(const char* function_name) const;
00148 
00149         static int TimeCallback(jack_nframes_t nframes, void *arg);
00150 };
00151 
00152 
00153 } // end of namespace
00154 
00155 #endif