JackMacEngineRPC.cpp 9.45 KB
Newer Older
sletz's avatar
sletz committed
1
/*
sletz's avatar
sletz committed
2
Copyright (C) 2004-2008 Grame
sletz's avatar
sletz committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

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.

*/

#include "JackServer.h"
sletz's avatar
sletz committed
21
#include "JackLockedEngine.h"
sletz's avatar
sletz committed
22
23
24
25
26
27
28
29
30
31
32
33
#include "JackRPCEngine.h"
#include "JackMachServerChannel.h"
#include <assert.h>

using namespace Jack;

//-------------------
// Client management
//-------------------

#define rpc_type kern_return_t // for astyle

34
rpc_type server_rpc_jack_client_check(mach_port_t private_port, client_name_t name, client_name_t name_res, int protocol, int options, int* status, int* result)
35
{
sletz's avatar
sletz committed
36
    jack_log("rpc_jack_client_check");
37
38
    JackMachServerChannel* channel = JackMachServerChannel::fPortTable[private_port];
    assert(channel);
39
    channel->ClientCheck((char*)name, (char*)name_res, protocol, options, status, result);
40
41
42
    return KERN_SUCCESS;
}

43
rpc_type server_rpc_jack_client_open(mach_port_t server_port, client_name_t name, int pid, mach_port_t* private_port, int* shared_engine, int* shared_client, int* shared_graph, int* result)
sletz's avatar
sletz committed
44
{
45
    jack_log("rpc_jack_client_open name = %s", name);
sletz's avatar
sletz committed
46
47
    JackMachServerChannel* channel = JackMachServerChannel::fPortTable[server_port];
    assert(channel);
48
    channel->ClientOpen((char*)name, pid, private_port, shared_engine, shared_client, shared_graph, result);
sletz's avatar
sletz committed
49
50
51
52
53
    return KERN_SUCCESS;
}

rpc_type server_rpc_jack_client_close(mach_port_t private_port, int refnum, int* result)
{
sletz's avatar
sletz committed
54
    jack_log("rpc_jack_client_close");
sletz's avatar
sletz committed
55
56
    JackMachServerChannel* channel = JackMachServerChannel::fPortTable[private_port];
    assert(channel);
57
    channel->ClientClose(private_port, refnum);
sletz's avatar
sletz committed
58
59
60
61
    *result = 0;
    return KERN_SUCCESS;
}

sletz's avatar
sletz committed
62
rpc_type server_rpc_jack_client_activate(mach_port_t private_port, int refnum, int is_real_time, int* result)
sletz's avatar
sletz committed
63
{
sletz's avatar
sletz committed
64
    jack_log("rpc_jack_client_activate");
sletz's avatar
sletz committed
65
66
    JackMachServerChannel* channel = JackMachServerChannel::fPortTable[private_port];
    assert(channel);
sletz's avatar
sletz committed
67
    *result = channel->GetEngine()->ClientActivate(refnum, is_real_time);
sletz's avatar
sletz committed
68
69
70
71
72
    return KERN_SUCCESS;
}

rpc_type server_rpc_jack_client_deactivate(mach_port_t private_port, int refnum, int* result)
{
sletz's avatar
sletz committed
73
    jack_log("rpc_jack_client_deactivate");
sletz's avatar
sletz committed
74
75
    JackMachServerChannel* channel = JackMachServerChannel::fPortTable[private_port];
    assert(channel);
sletz's avatar
sletz committed
76
    *result = channel->GetEngine()->ClientDeactivate(refnum);
sletz's avatar
sletz committed
77
78
79
80
81
82
83
    return KERN_SUCCESS;
}

//-----------------
// Port management
//-----------------

sletz's avatar
sletz committed
84
rpc_type server_rpc_jack_port_register(mach_port_t private_port, int refnum, client_port_name_t name, client_port_type_t type, unsigned int flags, unsigned int buffer_size, unsigned int* port_index, int* result)
sletz's avatar
sletz committed
85
{
86
    jack_log("rpc_jack_port_register ref = %d name = %s", refnum, name);
sletz's avatar
sletz committed
87
88
    JackMachServerChannel* channel = JackMachServerChannel::fPortTable[private_port];
    assert(channel);
sletz's avatar
sletz committed
89
    *result = channel->GetEngine()->PortRegister(refnum, name, type, flags, buffer_size, port_index);
sletz's avatar
sletz committed
90
91
92
93
94
    return KERN_SUCCESS;
}

rpc_type server_rpc_jack_port_unregister(mach_port_t private_port, int refnum, int port, int* result)
{
95
    jack_log("rpc_jack_port_unregister ref = %d port = %d ", refnum, port);
sletz's avatar
sletz committed
96
97
98
99
100
101
102
103
    JackMachServerChannel* channel = JackMachServerChannel::fPortTable[private_port];
    assert(channel);
    *result = channel->GetEngine()->PortUnRegister(refnum, port);
    return KERN_SUCCESS;
}

rpc_type server_rpc_jack_port_connect_name(mach_port_t private_port, int refnum, client_port_name_t src, client_port_name_t dst, int* result)
{
sletz's avatar
sletz committed
104
    jack_log("rpc_jack_port_connect_name");
sletz's avatar
sletz committed
105
106
107
108
109
110
111
112
    JackMachServerChannel* channel = JackMachServerChannel::fPortTable[private_port];
    assert(channel);
    *result = channel->GetEngine()->PortConnect(refnum, src, dst);
    return KERN_SUCCESS;
}

rpc_type server_rpc_jack_port_disconnect_name(mach_port_t private_port, int refnum, client_port_name_t src, client_port_name_t dst, int* result)
{
sletz's avatar
sletz committed
113
    jack_log("rpc_jack_port_disconnect_name");
sletz's avatar
sletz committed
114
115
116
117
118
119
120
121
    JackMachServerChannel* channel = JackMachServerChannel::fPortTable[private_port];
    assert(channel);
    *result = channel->GetEngine()->PortDisconnect(refnum, src, dst);
    return KERN_SUCCESS;
}

rpc_type server_rpc_jack_port_connect(mach_port_t private_port, int refnum, int src, int dst, int* result)
{
sletz's avatar
sletz committed
122
    jack_log("rpc_jack_port_connect");
sletz's avatar
sletz committed
123
124
125
126
127
128
129
130
    JackMachServerChannel* channel = JackMachServerChannel::fPortTable[private_port];
    assert(channel);
    *result = channel->GetEngine()->PortConnect(refnum, src, dst);
    return KERN_SUCCESS;
}

rpc_type server_rpc_jack_port_disconnect(mach_port_t private_port, int refnum, int src, int dst, int* result)
{
sletz's avatar
sletz committed
131
    jack_log("rpc_jack_port_disconnect");
sletz's avatar
sletz committed
132
133
134
135
136
137
    JackMachServerChannel* channel = JackMachServerChannel::fPortTable[private_port];
    assert(channel);
    *result = channel->GetEngine()->PortDisconnect(refnum, src, dst);
    return KERN_SUCCESS;
}

138
139
140
141
142
143
144
145
146
rpc_type server_rpc_jack_port_rename(mach_port_t private_port, int refnum, int port, client_port_name_t name, int* result)
{
    jack_log("server_rpc_jack_port_rename");
    JackMachServerChannel* channel = JackMachServerChannel::fPortTable[private_port];
    assert(channel);
    *result = channel->GetEngine()->PortRename(refnum, port, name);
    return KERN_SUCCESS;
}

sletz's avatar
sletz committed
147
148
149
150
151
152
//------------------------
// Buffer size, freewheel
//------------------------

rpc_type server_rpc_jack_set_buffer_size(mach_port_t private_port, int buffer_size, int* result)
{
sletz's avatar
sletz committed
153
    jack_log("server_rpc_jack_set_buffer_size");
sletz's avatar
sletz committed
154
155
156
157
158
159
160
161
    JackMachServerChannel* channel = JackMachServerChannel::fPortTable[private_port];
    assert(channel);
    *result = channel->GetServer()->SetBufferSize(buffer_size);
    return KERN_SUCCESS;
}

rpc_type server_rpc_jack_set_freewheel(mach_port_t private_port, int onoff, int* result)
{
sletz's avatar
sletz committed
162
    jack_log("server_rpc_jack_set_freewheel");
sletz's avatar
sletz committed
163
164
165
166
167
168
169
170
171
172
173
174
    JackMachServerChannel* channel = JackMachServerChannel::fPortTable[private_port];
    assert(channel);
    *result = channel->GetServer()->SetFreewheel(onoff);
    return KERN_SUCCESS;
}

//----------------------
// Transport management
//----------------------

rpc_type server_rpc_jack_release_timebase(mach_port_t private_port, int refnum, int* result)
{
sletz's avatar
sletz committed
175
    jack_log("server_rpc_jack_release_timebase");
sletz's avatar
sletz committed
176
177
    JackMachServerChannel* channel = JackMachServerChannel::fPortTable[private_port];
    assert(channel);
178
    *result = channel->GetServer()->ReleaseTimebase(refnum);
sletz's avatar
sletz committed
179
180
181
182
183
    return KERN_SUCCESS;
}

rpc_type server_rpc_jack_set_timebase_callback(mach_port_t private_port, int refnum, int conditional, int* result)
{
sletz's avatar
sletz committed
184
    jack_log("server_rpc_jack_set_timebase_callback");
sletz's avatar
sletz committed
185
186
    JackMachServerChannel* channel = JackMachServerChannel::fPortTable[private_port];
    assert(channel);
187
    *result = channel->GetServer()->SetTimebaseCallback(refnum, conditional);
sletz's avatar
sletz committed
188
189
190
    return KERN_SUCCESS;
}

191
192
193
194
195
196
//------------------
// Internal clients
//------------------

rpc_type server_rpc_jack_get_internal_clientname(mach_port_t private_port, int refnum, int int_ref, client_name_t name_res, int* result)
{
sletz's avatar
sletz committed
197
    jack_log("server_rpc_jack_get_internal_clientname");
198
199
    JackMachServerChannel* channel = JackMachServerChannel::fPortTable[private_port];
    assert(channel);
sletz's avatar
sletz committed
200
201
    *result = channel->GetServer()->GetEngine()->GetInternalClientName(int_ref, (char*)name_res);
    return KERN_SUCCESS;
202
203
204
205
}

rpc_type server_rpc_jack_internal_clienthandle(mach_port_t private_port, int refnum, client_name_t client_name, int* status, int* int_ref, int* result)
{
sletz's avatar
sletz committed
206
    jack_log("server_rpc_jack_internal_clienthandle");
207
208
    JackMachServerChannel* channel = JackMachServerChannel::fPortTable[private_port];
    assert(channel);
sletz's avatar
sletz committed
209
210
    *result = channel->GetServer()->GetEngine()->InternalClientHandle(client_name, status, int_ref);
    return KERN_SUCCESS;
211
212
213
214
}

rpc_type server_rpc_jack_internal_clientload(mach_port_t private_port, int refnum, client_name_t client_name, so_name_t so_name, objet_data_t objet_data, int options, int* status, int* int_ref, int* result)
{
sletz's avatar
sletz committed
215
    jack_log("server_rpc_jack_internal_clientload");
216
    JackMachServerChannel* channel = JackMachServerChannel::fPortTable[private_port];
sletz's avatar
sletz committed
217
218
219
    assert(channel);
    *result = channel->GetServer()->InternalClientLoad(client_name, so_name, objet_data, options, int_ref, status);
    return KERN_SUCCESS;
220
221
222
223
}

rpc_type server_rpc_jack_internal_clientunload(mach_port_t private_port, int refnum, int int_ref, int* status, int* result)
{
sletz's avatar
sletz committed
224
    jack_log("server_rpc_jack_internal_clientunload");
225
226
    JackMachServerChannel* channel = JackMachServerChannel::fPortTable[private_port];
    assert(channel);
sletz's avatar
sletz committed
227
228
    *result = channel->GetServer()->GetEngine()->InternalClientUnload(int_ref, status);
    return KERN_SUCCESS;
229
230
}

sletz's avatar
sletz committed
231
232
233
234
235
236
//-----------------
// RT notification
//-----------------

rpc_type server_rpc_jack_client_rt_notify(mach_port_t server_port, int refnum, int notify, int value)
{
237
    jack_log("rpc_jack_client_rt_notify ref = %d notify = %d value = %d", refnum, notify, value);
sletz's avatar
sletz committed
238
239
240
241
242
243
    JackMachServerChannel* channel = JackMachServerChannel::fPortTable[server_port];
    assert(channel);
    assert(channel->GetServer());
    channel->GetServer()->Notify(refnum, notify, value);
    return KERN_SUCCESS;
}