1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
|
/*
Copyright (C) 2004-2008 Grame
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __JackEngine__
#define __JackEngine__
#include "JackConstants.h"
#include "JackGraphManager.h"
#include "JackSynchro.h"
#include "JackMutex.h"
#include "JackTransportEngine.h"
#include "JackPlatformPlug.h"
#include "JackRequest.h"
#include "JackChannel.h"
#include <map>
namespace Jack
{
class JackClientInterface;
struct JackEngineControl;
class JackExternalClient;
/*!
\brief Engine description.
*/
class SERVER_EXPORT JackEngine : public JackLockAble
{
friend class JackLockedEngine;
private:
JackGraphManager* fGraphManager;
JackEngineControl* fEngineControl;
char fSelfConnectMode;
JackClientInterface* fClientTable[CLIENT_NUM];
JackSynchro* fSynchroTable;
JackServerNotifyChannel fChannel; /*! To communicate between the RT thread and server */
JackProcessSync fSignal;
jack_time_t fLastSwitchUsecs;
JackMetadata fMetadata;
int fSessionPendingReplies;
detail::JackChannelTransactionInterface* fSessionTransaction;
JackSessionNotifyResult* fSessionResult;
std::map<int,std::string> fReservationMap;
int ClientCloseAux(int refnum, bool wait);
void CheckXRun(jack_time_t callback_usecs);
int NotifyAddClient(JackClientInterface* new_client, const char* new_name, int refnum);
void NotifyRemoveClient(const char* name, int refnum);
void ProcessNext(jack_time_t callback_usecs);
void ProcessCurrent(jack_time_t callback_usecs);
bool ClientCheckName(const char* name);
bool GenerateUniqueName(char* name);
int AllocateRefnum();
void ReleaseRefnum(int refnum);
int ClientNotify(JackClientInterface* client, int refnum, const char* name, int notify, int sync, const char* message, int value1, int value2);
void NotifyClient(int refnum, int event, int sync, const char* message, int value1, int value2);
void NotifyClients(int event, int sync, const char* message, int value1, int value2);
void NotifyPortRegistation(jack_port_id_t port_index, bool onoff);
void NotifyPortConnect(jack_port_id_t src, jack_port_id_t dst, bool onoff);
void NotifyPortRename(jack_port_id_t src, const char* old_name);
void NotifyActivate(int refnum);
void EnsureUUID(jack_uuid_t uuid);
bool CheckClient(int refnum)
{
return (refnum >= 0 && refnum < CLIENT_NUM && fClientTable[refnum] != NULL);
}
int CheckPortsConnect(int refnum, jack_port_id_t src, jack_port_id_t dst);
public:
JackEngine(JackGraphManager* manager, JackSynchro* table, JackEngineControl* controler, char self_connect_mode);
~JackEngine();
int Open();
int Close();
// Client management
int ClientCheck(const char* name, jack_uuid_t uuid, char* name_res, int protocol, int options, int* status);
int ClientExternalOpen(const char* name, int pid, jack_uuid_t uuid, int* ref, int* shared_engine, int* shared_client, int* shared_graph_manager);
int ClientInternalOpen(const char* name, int* ref, JackEngineControl** shared_engine, JackGraphManager** shared_manager, JackClientInterface* client, bool wait);
int ClientExternalClose(int refnum);
int ClientInternalClose(int refnum, bool wait);
int ClientActivate(int refnum, bool is_real_time);
int ClientDeactivate(int refnum);
void ClientKill(int refnum);
int GetClientPID(const char* name);
int GetClientRefNum(const char* name);
// Internal client management
int GetInternalClientName(int int_ref, char* name_res);
int InternalClientHandle(const char* client_name, int* status, int* int_ref);
int InternalClientUnload(int refnum, int* status);
// Port management
int PortRegister(int refnum, const char* name, const char *type, unsigned int flags, unsigned int buffer_size, jack_port_id_t* port);
int PortUnRegister(int refnum, jack_port_id_t port);
int PortConnect(int refnum, const char* src, const char* dst);
int PortDisconnect(int refnum, const char* src, const char* dst);
int PortConnect(int refnum, jack_port_id_t src, jack_port_id_t dst);
int PortDisconnect(int refnum, jack_port_id_t src, jack_port_id_t dst);
int PortRename(int refnum, jack_port_id_t port, const char* name);
int PortSetDefaultMetadata(jack_port_id_t port, const char* pretty_name);
int ComputeTotalLatencies();
int PropertyChangeNotify(jack_uuid_t subject, const char* key,jack_property_change_t change);
// Graph
bool Process(jack_time_t cur_cycle_begin, jack_time_t prev_cycle_end);
// Notifications
void NotifyDriverXRun();
void NotifyClientXRun(int refnum);
void NotifyFailure(int code, const char* reason);
void NotifyGraphReorder();
void NotifyBufferSize(jack_nframes_t buffer_size);
void NotifySampleRate(jack_nframes_t sample_rate);
void NotifyFreewheel(bool onoff);
void NotifyQuit();
// Session management
void SessionNotify(int refnum, const char *target, jack_session_event_type_t type, const char *path, detail::JackChannelTransactionInterface *socket, JackSessionNotifyResult** result);
int SessionReply(int refnum);
int GetUUIDForClientName(const char *client_name, char *uuid_res);
int GetClientNameForUUID(const char *uuid, char *name_res);
int ReserveClientName(const char *name, const char *uuid);
int ClientHasSessionCallback(const char *name);
};
} // end of namespace
#endif
|