| 1 |
/* |
|---|
| 2 |
Copyright (C) 2004-2008 Grame |
|---|
| 3 |
|
|---|
| 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. |
|---|
| 8 |
|
|---|
| 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. |
|---|
| 13 |
|
|---|
| 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. |
|---|
| 17 |
|
|---|
| 18 |
*/ |
|---|
| 19 |
|
|---|
| 20 |
#ifndef __JackEngine__ |
|---|
| 21 |
#define __JackEngine__ |
|---|
| 22 |
|
|---|
| 23 |
#include "JackConstants.h" |
|---|
| 24 |
#include "JackGraphManager.h" |
|---|
| 25 |
#include "JackSynchro.h" |
|---|
| 26 |
#include "JackTransportEngine.h" |
|---|
| 27 |
#include "JackPlatformPlug.h" |
|---|
| 28 |
|
|---|
| 29 |
namespace Jack |
|---|
| 30 |
{ |
|---|
| 31 |
|
|---|
| 32 |
class JackClientInterface; |
|---|
| 33 |
struct JackEngineControl; |
|---|
| 34 |
class JackExternalClient; |
|---|
| 35 |
|
|---|
| 36 |
/*! |
|---|
| 37 |
\brief Engine description. |
|---|
| 38 |
*/ |
|---|
| 39 |
|
|---|
| 40 |
class SERVER_EXPORT JackEngine |
|---|
| 41 |
{ |
|---|
| 42 |
private: |
|---|
| 43 |
|
|---|
| 44 |
JackGraphManager* fGraphManager; |
|---|
| 45 |
JackEngineControl* fEngineControl; |
|---|
| 46 |
JackClientInterface* fClientTable[CLIENT_NUM]; |
|---|
| 47 |
JackSynchro* fSynchroTable; |
|---|
| 48 |
JackServerNotifyChannel fChannel; /*! To communicate between the RT thread and server */ |
|---|
| 49 |
JackProcessSync fSignal; |
|---|
| 50 |
jack_time_t fLastSwitchUsecs; |
|---|
| 51 |
|
|---|
| 52 |
int ClientCloseAux(int refnum, JackClientInterface* client, bool wait); |
|---|
| 53 |
void CheckXRun(jack_time_t callback_usecs); |
|---|
| 54 |
|
|---|
| 55 |
int NotifyAddClient(JackClientInterface* new_client, const char* name, int refnum); |
|---|
| 56 |
void NotifyRemoveClient(const char* name, int refnum); |
|---|
| 57 |
|
|---|
| 58 |
void ProcessNext(jack_time_t callback_usecs); |
|---|
| 59 |
void ProcessCurrent(jack_time_t callback_usecs); |
|---|
| 60 |
|
|---|
| 61 |
bool ClientCheckName(const char* name); |
|---|
| 62 |
bool GenerateUniqueName(char* name); |
|---|
| 63 |
|
|---|
| 64 |
int AllocateRefnum(); |
|---|
| 65 |
void ReleaseRefnum(int ref); |
|---|
| 66 |
|
|---|
| 67 |
void NotifyClient(int refnum, int event, int sync, const char* message, int value1, int value2); |
|---|
| 68 |
void NotifyClients(int event, int sync, const char* message, int value1, int value2); |
|---|
| 69 |
|
|---|
| 70 |
void NotifyPortRegistation(jack_port_id_t port_index, bool onoff); |
|---|
| 71 |
void NotifyPortConnect(jack_port_id_t src, jack_port_id_t dst, bool onoff); |
|---|
| 72 |
void NotifyPortRename(jack_port_id_t src, const char* old_name); |
|---|
| 73 |
void NotifyActivate(int refnum); |
|---|
| 74 |
|
|---|
| 75 |
public: |
|---|
| 76 |
|
|---|
| 77 |
JackEngine(JackGraphManager* manager, JackSynchro* table, JackEngineControl* controler); |
|---|
| 78 |
~JackEngine(); |
|---|
| 79 |
|
|---|
| 80 |
int Open(); |
|---|
| 81 |
int Close(); |
|---|
| 82 |
|
|---|
| 83 |
// Client management |
|---|
| 84 |
int ClientCheck(const char* name, char* name_res, int protocol, int options, int* status); |
|---|
| 85 |
int ClientExternalOpen(const char* name, int pid, int* ref, int* shared_engine, int* shared_client, int* shared_graph_manager); |
|---|
| 86 |
int ClientInternalOpen(const char* name, int* ref, JackEngineControl** shared_engine, JackGraphManager** shared_manager, JackClientInterface* client, bool wait); |
|---|
| 87 |
|
|---|
| 88 |
int ClientExternalClose(int refnum); |
|---|
| 89 |
int ClientInternalClose(int refnum, bool wait); |
|---|
| 90 |
|
|---|
| 91 |
int ClientActivate(int refnum, bool is_real_time); |
|---|
| 92 |
int ClientDeactivate(int refnum); |
|---|
| 93 |
|
|---|
| 94 |
int GetClientPID(const char* name); |
|---|
| 95 |
int GetClientRefNum(const char* name); |
|---|
| 96 |
|
|---|
| 97 |
// Internal client management |
|---|
| 98 |
int GetInternalClientName(int int_ref, char* name_res); |
|---|
| 99 |
int InternalClientHandle(const char* client_name, int* status, int* int_ref); |
|---|
| 100 |
int InternalClientUnload(int refnum, int* status); |
|---|
| 101 |
|
|---|
| 102 |
// Port management |
|---|
| 103 |
int PortRegister(int refnum, const char* name, const char *type, unsigned int flags, unsigned int buffer_size, jack_port_id_t* port); |
|---|
| 104 |
int PortUnRegister(int refnum, jack_port_id_t port); |
|---|
| 105 |
|
|---|
| 106 |
int PortConnect(int refnum, const char* src, const char* dst); |
|---|
| 107 |
int PortDisconnect(int refnum, const char* src, const char* dst); |
|---|
| 108 |
|
|---|
| 109 |
int PortConnect(int refnum, jack_port_id_t src, jack_port_id_t dst); |
|---|
| 110 |
int PortDisconnect(int refnum, jack_port_id_t src, jack_port_id_t dst); |
|---|
| 111 |
|
|---|
| 112 |
int PortRename(int refnum, jack_port_id_t port, const char* name); |
|---|
| 113 |
|
|---|
| 114 |
// Graph |
|---|
| 115 |
bool Process(jack_time_t cur_cycle_begin, jack_time_t prev_cycle_end); |
|---|
| 116 |
|
|---|
| 117 |
// Notifications |
|---|
| 118 |
void NotifyXRun(jack_time_t callback_usecs, float delayed_usecs); |
|---|
| 119 |
void NotifyFailure(int code, const char* reason); |
|---|
| 120 |
void NotifyXRun(int refnum); |
|---|
| 121 |
void NotifyGraphReorder(); |
|---|
| 122 |
void NotifyBufferSize(jack_nframes_t buffer_size); |
|---|
| 123 |
void NotifySampleRate(jack_nframes_t sample_rate); |
|---|
| 124 |
void NotifyFreewheel(bool onoff); |
|---|
| 125 |
void NotifyQuit(); |
|---|
| 126 |
}; |
|---|
| 127 |
|
|---|
| 128 |
|
|---|
| 129 |
} // end of namespace |
|---|
| 130 |
|
|---|
| 131 |
#endif |
|---|
| 132 |
|
|---|