CoreAudio backend now issue a JackInfoShutdownCallback when an unrecoverable error...
[jack2.git] / common / JackLockedEngine.h
blobc841c465e1341a4d168ba2dae3fe26a42eb2f942
1 /*
2 Copyright (C) 2008 Grame
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 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 General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifndef __JackLockedEngine__
21 #define __JackLockedEngine__
23 #include "JackEngine.h"
24 #include "JackMutex.h"
26 namespace Jack
29 /*!
30 \brief Locked Engine, access to methods is serialized using a mutex.
33 class SERVER_EXPORT JackLockedEngine : public JackLockAble
35 private:
37 JackEngine fEngine;
39 public:
41 JackLockedEngine(JackGraphManager* manager, JackSynchro* table, JackEngineControl* controler):
42 fEngine(manager, table, controler)
44 ~JackLockedEngine()
47 int Open()
49 // No lock needed
50 return fEngine.Open();
52 int Close()
54 // No lock needed
55 return fEngine.Close();
58 // Client management
59 int ClientCheck(const char* name, char* name_res, int protocol, int options, int* status)
61 JackLock lock(this);
62 return fEngine.ClientCheck(name, name_res, protocol, options, status);
64 int ClientExternalOpen(const char* name, int pid, int* ref, int* shared_engine, int* shared_client, int* shared_graph_manager)
66 JackLock lock(this);
67 return fEngine.ClientExternalOpen(name, pid, ref, shared_engine, shared_client, shared_graph_manager);
69 int ClientInternalOpen(const char* name, int* ref, JackEngineControl** shared_engine, JackGraphManager** shared_manager, JackClientInterface* client, bool wait)
71 JackLock lock(this);
72 return fEngine.ClientInternalOpen(name, ref, shared_engine, shared_manager, client, wait);
75 int ClientExternalClose(int refnum)
77 JackLock lock(this);
78 return fEngine.ClientExternalClose(refnum);
80 int ClientInternalClose(int refnum, bool wait)
82 JackLock lock(this);
83 return fEngine.ClientInternalClose(refnum, wait);
86 int ClientActivate(int refnum, bool state)
88 JackLock lock(this);
89 return fEngine.ClientActivate(refnum, state);
91 int ClientDeactivate(int refnum)
93 JackLock lock(this);
94 return fEngine.ClientDeactivate(refnum);
97 // Internal client management
98 int GetInternalClientName(int int_ref, char* name_res)
100 JackLock lock(this);
101 return fEngine.GetInternalClientName(int_ref, name_res);
103 int InternalClientHandle(const char* client_name, int* status, int* int_ref)
105 JackLock lock(this);
106 return fEngine.InternalClientHandle(client_name, status, int_ref);
108 int InternalClientUnload(int refnum, int* status)
110 JackLock lock(this);
111 return fEngine.InternalClientUnload(refnum, status);
114 // Port management
115 int PortRegister(int refnum, const char* name, const char *type, unsigned int flags, unsigned int buffer_size, jack_port_id_t* port)
117 JackLock lock(this);
118 return fEngine.PortRegister(refnum, name, type, flags, buffer_size, port);
120 int PortUnRegister(int refnum, jack_port_id_t port)
122 JackLock lock(this);
123 return fEngine.PortUnRegister(refnum, port);
126 int PortConnect(int refnum, const char* src, const char* dst)
128 JackLock lock(this);
129 return fEngine.PortConnect(refnum, src, dst);
131 int PortDisconnect(int refnum, const char* src, const char* dst)
133 JackLock lock(this);
134 return fEngine.PortDisconnect(refnum, src, dst);
137 int PortConnect(int refnum, jack_port_id_t src, jack_port_id_t dst)
139 JackLock lock(this);
140 return fEngine.PortConnect(refnum, src, dst);
142 int PortDisconnect(int refnum, jack_port_id_t src, jack_port_id_t dst)
144 JackLock lock(this);
145 return fEngine.PortDisconnect(refnum, src, dst);
148 int PortRename(int refnum, jack_port_id_t port, const char* name)
150 JackLock lock(this);
151 return fEngine.PortRename(refnum, port, name);
154 // Graph
155 bool Process(jack_time_t cur_cycle_begin, jack_time_t prev_cycle_end)
157 // RT : no lock
158 return fEngine.Process(cur_cycle_begin, prev_cycle_end);
161 // Notifications
162 void NotifyXRun(jack_time_t cur_cycle_begin, float delayed_usecs)
164 // RT : no lock
165 fEngine.NotifyXRun(cur_cycle_begin, delayed_usecs);
168 void NotifyXRun(int refnum)
170 JackLock lock(this);
171 fEngine.NotifyXRun(refnum);
173 void NotifyGraphReorder()
175 JackLock lock(this);
176 fEngine.NotifyGraphReorder();
178 void NotifyBufferSize(jack_nframes_t buffer_size)
180 JackLock lock(this);
181 fEngine.NotifyBufferSize(buffer_size);
183 void NotifySampleRate(jack_nframes_t sample_rate)
185 JackLock lock(this);
186 fEngine.NotifySampleRate(sample_rate);
188 void NotifyFreewheel(bool onoff)
190 JackLock lock(this);
191 fEngine.NotifyFreewheel(onoff);
194 void NotifyFailure(int code, const char* reason)
196 JackLock lock(this);
197 fEngine.NotifyFailure(code, reason);
200 int GetClientPID(const char* name)
202 JackLock lock(this);
203 return fEngine.GetClientPID(name);
206 int GetClientRefNum(const char* name)
208 JackLock lock(this);
209 return fEngine.GetClientRefNum(name);
214 } // end of namespace
216 #endif