Merge branch 'master' into develop
[jack2.git] / common / JackDebugClient.h
blob9e82f1d4904a83af288537b7c587d1ab5ddf835e
1 /*
2 Copyright (C) 2004-2008 Grame
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published by
6 the Free Software Foundation; either version 2.1 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #ifndef __JackDebugClient__
21 #define __JackDebugClient__
23 #define MAX_PORT_HISTORY 2048
25 #include "JackClient.h"
26 #include <list>
27 #include <fstream>
29 namespace Jack
32 /*!
33 \brief Follow a single port.
36 typedef struct
38 jack_port_id_t idport;
39 char name[JACK_PORT_NAME_SIZE]; //portname
40 int IsConnected;
41 int IsUnregistered;
43 PortFollower;
45 /*!
46 \brief A "decorator" debug client to validate API use.
49 class JackDebugClient : public JackClient
51 protected:
53 JackClient* fClient;
54 std::ofstream* fStream;
55 PortFollower fPortList[MAX_PORT_HISTORY]; // Arbitrary value... To be tuned...
56 int fTotalPortNumber; // The total number of port opened and maybe closed. Historical view.
57 int fOpenPortNumber; // The current number of opened port.
58 int fIsActivated;
59 int fIsDeactivated;
60 int fIsClosed;
61 bool fFreewheel;
62 char fClientName[JACK_CLIENT_NAME_SIZE+1];
63 JackProcessCallback fProcessTimeCallback;
64 void* fProcessTimeCallbackArg;
66 public:
68 JackDebugClient(JackClient* fTheClient);
69 virtual ~JackDebugClient();
71 virtual int Open(const char* server_name, const char* name, jack_uuid_t uuid, jack_options_t options, jack_status_t* status);
72 int Close();
74 virtual JackGraphManager* GetGraphManager() const;
75 virtual JackEngineControl* GetEngineControl() const;
77 // Notifications
78 int ClientNotify(int refnum, const char* name, int notify, int sync, const char* message, int value1, int value2);
80 int Activate();
81 int Deactivate();
83 // Context
84 int SetBufferSize(jack_nframes_t buffer_size);
85 int SetFreeWheel(int onoff);
86 int ComputeTotalLatencies();
87 void ShutDown(jack_status_t code, const char* message);
88 jack_native_thread_t GetThreadID();
90 // Port management
91 int PortRegister(const char* port_name, const char* port_type, unsigned long flags, unsigned long buffer_size);
92 int PortUnRegister(jack_port_id_t port);
94 int PortConnect(const char* src, const char* dst);
95 int PortDisconnect(const char* src, const char* dst);
96 int PortDisconnect(jack_port_id_t src);
98 int PortIsMine(jack_port_id_t port_index);
99 int PortRename(jack_port_id_t port_index, const char* name);
101 // Transport
102 int ReleaseTimebase();
103 int SetSyncCallback(JackSyncCallback sync_callback, void* arg);
104 int SetSyncTimeout(jack_time_t timeout);
105 int SetTimebaseCallback(int conditional, JackTimebaseCallback timebase_callback, void* arg);
106 void TransportLocate(jack_nframes_t frame);
107 jack_transport_state_t TransportQuery(jack_position_t* pos);
108 jack_nframes_t GetCurrentTransportFrame();
109 int TransportReposition(const jack_position_t* pos);
110 void TransportStart();
111 void TransportStop();
113 // Callbacks
114 void OnShutdown(JackShutdownCallback callback, void *arg);
115 void OnInfoShutdown(JackInfoShutdownCallback callback, void *arg);
116 int SetProcessCallback(JackProcessCallback callback, void* arg);
117 int SetXRunCallback(JackXRunCallback callback, void* arg);
118 int SetInitCallback(JackThreadInitCallback callback, void* arg);
119 int SetGraphOrderCallback(JackGraphOrderCallback callback, void* arg);
120 int SetBufferSizeCallback(JackBufferSizeCallback callback, void* arg);
121 int SetClientRegistrationCallback(JackClientRegistrationCallback callback, void* arg);
122 int SetFreewheelCallback(JackFreewheelCallback callback, void* arg);
123 int SetPortRegistrationCallback(JackPortRegistrationCallback callback, void* arg);
124 int SetPortConnectCallback(JackPortConnectCallback callback, void *arg);
125 int SetPortRenameCallback(JackPortRenameCallback callback, void *arg);
126 int SetSessionCallback(JackSessionCallback callback, void *arg);
127 int SetLatencyCallback(JackLatencyCallback callback, void *arg);
129 // Internal clients
130 char* GetInternalClientName(int ref);
131 int InternalClientHandle(const char* client_name, jack_status_t* status);
132 int InternalClientLoad(const char* client_name, jack_options_t options, jack_status_t* status, jack_varargs_t* va);
133 void InternalClientUnload(int ref, jack_status_t* status);
135 // RT Thread
136 int SetProcessThread(JackThreadCallback fun, void *arg);
138 // Session API
139 jack_session_command_t* SessionNotify(const char* target, jack_session_event_type_t type, const char* path);
140 int SessionReply(jack_session_event_t* ev);
141 char* GetUUIDForClientName(const char* client_name);
142 char* GetClientNameByUUID(const char* uuid);
143 int ReserveClientName(const char* client_name, const char* uuid);
144 int ClientHasSessionCallback(const char* client_name);
146 JackClientControl* GetClientControl() const;
147 void CheckClient(const char* function_name) const;
149 static int TimeCallback(jack_nframes_t nframes, void *arg);
153 } // end of namespace
155 #endif