2 Copyright (C) 2001 Paul Davis
3 Copyright (C) 2004-2006 Grame
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #ifndef __JackClient__
22 #define __JackClient__
24 #include "JackClientInterface.h"
25 #include "JackThread.h"
26 #include "JackConstants.h"
27 #include "JackSynchro.h"
29 #include "transport_types.h"
35 class JackClientChannelInterface
;
36 class JackGraphManager
;
40 struct JackClientControl
;
41 struct JackEngineControl
;
42 class JackSyncInterface
;
44 typedef void (*JackShutdownCallback
)(void *arg
);
47 \brief The base class for clients: share part of the implementation for JackInternalClient and JackLibClient.
50 class JackClient
: public JackClientInterface
, public JackRunnableInterface
55 JackProcessCallback fProcess
;
56 JackGraphOrderCallback fGraphOrder
;
57 JackXRunCallback fXrun
;
58 JackShutdownCallback fShutdown
;
59 JackThreadInitCallback fInit
;
60 JackBufferSizeCallback fBufferSize
;
61 JackFreewheelCallback fFreewheel
;
62 JackPortRegistrationCallback fPortRegistration
;
63 JackTimebaseCallback fTimebase
;
64 JackSyncCallback fSync
;
72 void* fPortRegistrationArg
;
77 JackThread
* fThread
; /*! Thread to execute the Process function */
78 JackClientChannelInterface
* fChannel
;
79 JackSynchro
** fSynchroTable
;
80 std::list
<jack_port_id_t
> fPortList
;
83 void SetupDriverSync(bool freewheel
);
86 bool CallProcessCallback();
87 void CallSyncCallback();
88 void CallTimebaseCallback();
89 int RequestNewPos(jack_position_t
* pos
);
91 virtual int ClientNotifyImp(int refnum
, const char* name
, int notify
, int sync
, int value
);
96 JackClient(JackSynchro
** table
);
97 virtual ~JackClient();
99 virtual int Open(const char* name
) = 0;
102 virtual JackGraphManager
* GetGraphManager() const = 0;
103 virtual JackEngineControl
* GetEngineControl() const = 0;
106 virtual int ClientNotify(int refnum
, const char* name
, int notify
, int sync
, int value
);
108 virtual int Activate();
109 virtual int Deactivate();
112 virtual int SetBufferSize(jack_nframes_t buffer_size
);
113 virtual int SetFreeWheel(int onoff
);
114 virtual void ShutDown();
115 virtual pthread_t
GetThreadID();
118 virtual int PortRegister(const char* port_name
, const char* port_type
, unsigned long flags
, unsigned long buffer_size
);
119 virtual int PortUnRegister(jack_port_id_t port
);
121 virtual int PortConnect(const char* src
, const char* dst
);
122 virtual int PortDisconnect(const char* src
, const char* dst
);
123 virtual int PortConnect(jack_port_id_t src
, jack_port_id_t dst
);
124 virtual int PortDisconnect(jack_port_id_t src
);
126 virtual int PortIsMine(jack_port_id_t port_index
);
129 virtual int ReleaseTimebase();
130 virtual int SetSyncCallback(JackSyncCallback sync_callback
, void* arg
);
131 virtual int SetSyncTimeout(jack_time_t timeout
);
132 virtual int SetTimebaseCallback(int conditional
, JackTimebaseCallback timebase_callback
, void* arg
);
133 virtual int TransportLocate(jack_nframes_t frame
);
134 virtual jack_transport_state_t
TransportQuery(jack_position_t
* pos
);
135 virtual jack_nframes_t
GetCurrentTransportFrame();
136 virtual int TransportReposition(jack_position_t
* pos
);
137 virtual void TransportStart();
138 virtual void TransportStop();
141 virtual void OnShutdown(JackShutdownCallback callback
, void *arg
);
142 virtual int SetProcessCallback(JackProcessCallback callback
, void* arg
);
143 virtual int SetXRunCallback(JackXRunCallback callback
, void* arg
);
144 virtual int SetInitCallback(JackThreadInitCallback callback
, void* arg
);
145 virtual int SetGraphOrderCallback(JackGraphOrderCallback callback
, void* arg
);
146 virtual int SetBufferSizeCallback(JackBufferSizeCallback callback
, void* arg
);
147 virtual int SetFreewheelCallback(JackFreewheelCallback callback
, void* arg
);
148 virtual int SetPortRegistrationCallback(JackPortRegistrationCallback callback
, void* arg
);
150 // JackRunnableInterface interface
155 // Each "side" server and client will implement this to get the shared graph manager, engine control and inter-process synchro table.
156 extern JackGraphManager
* GetGraphManager();
157 extern JackEngineControl
* GetEngineControl();
158 extern JackSynchro
** GetSynchroTable();
160 } // end of namespace