Commit e4ef948e authored by Stéphane LETZ's avatar Stéphane LETZ Committed by Torben Hohn
Browse files

OSX IPC code removed from repository.

parent 5d18946a
......@@ -97,7 +97,7 @@ def build(bld):
'../posix/JackPosixThread.cpp',
'../macosx/JackMachThread.cpp',
'../macosx/JackMachSemaphore.cpp',
'../macosx/JackMachPort.cpp',
'../posix/JackSocket.cpp',
'../macosx/JackMachTime.c',
]
includes = ['../macosx', '../macosx/RPC', '../posix'] + includes
......@@ -152,11 +152,9 @@ def build(bld):
if bld.env['IS_MACOSX']:
serverlib.source += [
'../macosx/JackMachServerChannel.cpp',
'../macosx/JackMachNotifyChannel.cpp',
'../macosx/JackMachServerNotifyChannel.cpp',
'../macosx/JackMacEngineRPC.cpp',
'../macosx/RPC/JackRPCClientUser.c',
'../posix/JackSocketServerChannel.cpp',
'../posix/JackSocketNotifyChannel.cpp',
'../posix/JackSocketServerNotifyChannel.cpp',
'../posix/JackNetUnixSocket.cpp',
]
......@@ -205,9 +203,7 @@ def build(bld):
if bld.env['IS_MACOSX']:
clientlib.source += [
'../macosx/JackMachClientChannel.cpp',
'../macosx/RPC/JackRPCEngineUser.c',
'../macosx/JackMacLibClientRPC.cpp',
'../posix/JackSocketClientChannel.cpp',
'../posix/JackPosixServerLaunch.cpp',
]
......
/*
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.
*/
#include "JackServer.h"
#include "JackNotification.h"
#include "JackLockedEngine.h"
#include "JackRPCEngine.h"
#include "JackMachServerChannel.h"
#include "JackException.h"
#include <assert.h>
using namespace Jack;
//-------------------
// Client management
//-------------------
#define rpc_type kern_return_t // for astyle
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)
{
jack_log("rpc_jack_client_check");
JackMachServerChannel* channel = JackMachServerChannel::fPortTable[private_port];
assert(channel);
channel->ClientCheck((char*)name, (char*)name_res, protocol, options, status, result);
return KERN_SUCCESS;
}
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)
{
jack_log("rpc_jack_client_open name = %s", name);
JackMachServerChannel* channel = JackMachServerChannel::fPortTable[server_port];
assert(channel);
channel->ClientOpen((char*)name, pid, private_port, shared_engine, shared_client, shared_graph, result);
return KERN_SUCCESS;
}
rpc_type server_rpc_jack_client_close(mach_port_t private_port, int refnum, int* result)
{
jack_log("rpc_jack_client_close");
JackMachServerChannel* channel = JackMachServerChannel::fPortTable[private_port];
assert(channel);
channel->ClientClose(private_port, refnum);
*result = 0;
return KERN_SUCCESS;
}
rpc_type server_rpc_jack_client_activate(mach_port_t private_port, int refnum, int is_real_time, int* result)
{
jack_log("rpc_jack_client_activate");
JackMachServerChannel* channel = JackMachServerChannel::fPortTable[private_port];
assert(channel);
*result = channel->GetEngine()->ClientActivate(refnum, is_real_time);
return KERN_SUCCESS;
}
rpc_type server_rpc_jack_client_deactivate(mach_port_t private_port, int refnum, int* result)
{
jack_log("rpc_jack_client_deactivate");
JackMachServerChannel* channel = JackMachServerChannel::fPortTable[private_port];
assert(channel);
*result = channel->GetEngine()->ClientDeactivate(refnum);
return KERN_SUCCESS;
}
//-----------------
// Port management
//-----------------
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)
{
jack_log("rpc_jack_port_register ref = %d name = %s", refnum, name);
JackMachServerChannel* channel = JackMachServerChannel::fPortTable[private_port];
assert(channel);
*result = channel->GetEngine()->PortRegister(refnum, name, type, flags, buffer_size, port_index);
return KERN_SUCCESS;
}
rpc_type server_rpc_jack_port_unregister(mach_port_t private_port, int refnum, int port, int* result)
{
jack_log("rpc_jack_port_unregister ref = %d port = %d ", refnum, port);
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)
{
jack_log("rpc_jack_port_connect_name");
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)
{
jack_log("rpc_jack_port_disconnect_name");
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)
{
jack_log("rpc_jack_port_connect");
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)
{
jack_log("rpc_jack_port_disconnect");
JackMachServerChannel* channel = JackMachServerChannel::fPortTable[private_port];
assert(channel);
*result = channel->GetEngine()->PortDisconnect(refnum, src, dst);
return KERN_SUCCESS;
}
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;
}
//------------------------
// Buffer size, freewheel
//------------------------
rpc_type server_rpc_jack_set_buffer_size(mach_port_t private_port, int buffer_size, int* result)
{
jack_log("server_rpc_jack_set_buffer_size");
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)
{
jack_log("server_rpc_jack_set_freewheel");
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)
{
jack_log("server_rpc_jack_release_timebase");
JackMachServerChannel* channel = JackMachServerChannel::fPortTable[private_port];
assert(channel);
*result = channel->GetServer()->ReleaseTimebase(refnum);
return KERN_SUCCESS;
}
rpc_type server_rpc_jack_set_timebase_callback(mach_port_t private_port, int refnum, int conditional, int* result)
{
jack_log("server_rpc_jack_set_timebase_callback");
JackMachServerChannel* channel = JackMachServerChannel::fPortTable[private_port];
assert(channel);
*result = channel->GetServer()->SetTimebaseCallback(refnum, conditional);
return KERN_SUCCESS;
}
//------------------
// 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)
{
jack_log("server_rpc_jack_get_internal_clientname");
JackMachServerChannel* channel = JackMachServerChannel::fPortTable[private_port];
assert(channel);
*result = channel->GetServer()->GetEngine()->GetInternalClientName(int_ref, (char*)name_res);
return KERN_SUCCESS;
}
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)
{
jack_log("server_rpc_jack_internal_clienthandle");
JackMachServerChannel* channel = JackMachServerChannel::fPortTable[private_port];
assert(channel);
*result = channel->GetServer()->GetEngine()->InternalClientHandle(client_name, status, int_ref);
return KERN_SUCCESS;
}
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)
{
jack_log("server_rpc_jack_internal_clientload");
JackMachServerChannel* channel = JackMachServerChannel::fPortTable[private_port];
assert(channel);
*result = channel->GetServer()->InternalClientLoad(client_name, so_name, objet_data, options, int_ref, status);
return KERN_SUCCESS;
}
rpc_type server_rpc_jack_internal_clientunload(mach_port_t private_port, int refnum, int int_ref, int* status, int* result)
{
jack_log("server_rpc_jack_internal_clientunload");
JackMachServerChannel* channel = JackMachServerChannel::fPortTable[private_port];
assert(channel);
*result = channel->GetServer()->GetEngine()->InternalClientUnload(int_ref, status);
return KERN_SUCCESS;
}
//-----------------
// RT notification
//-----------------
rpc_type server_rpc_jack_client_rt_notify(mach_port_t server_port, int refnum, int notify, int value)
{
jack_log("rpc_jack_client_rt_notify ref = %d notify = %d value = %d", refnum, notify, value);
JackMachServerChannel* channel = JackMachServerChannel::fPortTable[server_port];
assert(channel);
assert(channel->GetServer());
if (notify == kQUIT) {
throw JackQuitException();
} else {
channel->GetServer()->Notify(refnum, notify, value);
return KERN_SUCCESS;
}
}
/*
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.
*/
#include "JackLibClient.h"
#include "JackMachClientChannel.h"
#include "JackRPCEngine.h"
#include "JackLibGlobals.h"
#include <assert.h>
using namespace Jack;
#define rpc_type kern_return_t // for astyle
rpc_type rpc_jack_client_sync_notify(mach_port_t client_port, int refnum, client_name_t name, int notify, message_t message, int value1, int value2, int* result)
{
jack_log("rpc_jack_client_sync_notify ref = %ld name = %s notify = %ld message %s val1 = %ld val2 = %ld", refnum, name, notify, message, value1, value2);
JackClient* client = gClientTable[client_port];
assert(client);
*result = client->ClientNotify(refnum, name, notify, true, message, value1, value2);
return KERN_SUCCESS;
}
rpc_type rpc_jack_client_async_notify(mach_port_t client_port, int refnum, client_name_t name, int notify, message_t message, int value1, int value2)
{
jack_log("rpc_jack_client_async_notify ref = %ld name = %s notify = %ld message %s val1 = %ld val2 = %ld", refnum, name, notify, message, value1, value2);
JackClient* client = gClientTable[client_port];
assert(client);
client->ClientNotify(refnum, name, notify, false, message, value1, value2);
return KERN_SUCCESS;
}
/*
Copyright (C) 2004-2008 Grame
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "JackMachClientChannel.h"
#include "JackRPCEngine.h"
#include "JackTools.h"
#include "JackRPCClientServer.c"
#include "JackError.h"
#include "JackLibClient.h"
#include "JackMachThread.h"
#include "JackConstants.h"
namespace Jack
{
std::map<mach_port_t, JackClient*> gClientTable;
JackMachClientChannel::JackMachClientChannel():fPrivatePort(0),fThread(this)
{}
JackMachClientChannel::~JackMachClientChannel()
{}
// Server <===> client
int JackMachClientChannel::ServerCheck(const char* server_name)
{
jack_log("JackMachClientChannel::ServerCheck = %s", server_name);
char jack_server_entry_name[512];
snprintf(jack_server_entry_name, sizeof(jack_server_entry_name), "%s.%d_%s", jack_server_entry, JackTools::GetUID(), server_name);
// Connect to server
if (!fServerPort.ConnectPort(jack_server_entry_name)) {
jack_error("Cannot connect to server Mach port");
return -1;
} else {
return 0;
}
}
int JackMachClientChannel::Open(const char* server_name, const char* name, char* name_res, JackClient* client, jack_options_t options, jack_status_t* status)
{
jack_log("JackMachClientChannel::Open name = %s", name);
char jack_server_entry_name[512];
snprintf(jack_server_entry_name, sizeof(jack_server_entry_name), "%s.%d_%s", jack_server_entry, JackTools::GetUID(), server_name);
// Connect to server
if (!fServerPort.ConnectPort(jack_server_entry_name)) {
jack_error("Cannot connect to server Mach port");
return -1;
}
// Check name in server
int result = 0;
ClientCheck(name, name_res, JACK_PROTOCOL_VERSION, (int)options, (int*)status, &result);
if (result < 0) {
int status1 = *status;
if (status1 & JackVersionError)
jack_error("JACK protocol mismatch %d", JACK_PROTOCOL_VERSION);
else
jack_error("Client name = %s conflits with another running client", name);
return -1;
}
// Prepare local port using client name
char buf[JACK_CLIENT_NAME_SIZE + 1];
snprintf(buf, sizeof(buf) - 1, "%s:%s", jack_client_entry, name_res);
if (!fClientPort.AllocatePort(buf, 16)) {
jack_error("Cannot allocate client Mach port");
return -1;
}
gClientTable[fClientPort.GetPort()] = client;
return 0;
}
void JackMachClientChannel::Close()
{
jack_log("JackMachClientChannel::Close");
gClientTable.erase(fClientPort.GetPort());
fServerPort.DisconnectPort();
fClientPort.DestroyPort();
if (fPrivatePort != 0) {
kern_return_t res;
if ((res = mach_port_destroy(mach_task_self(), fPrivatePort)) != KERN_SUCCESS) {
jack_error("JackMachClientChannel::Close err = %s", mach_error_string(res));
}
}
}
int JackMachClientChannel::Start()
{
jack_log("JackMachClientChannel::Start");
/*
To be sure notification thread is started before ClientOpen is called.
*/
if (fThread.StartSync() != 0) {
jack_error("Cannot start Jack client listener");
return -1;
} else {
return 0;
}
}
void JackMachClientChannel::Stop()
{
jack_log("JackMachClientChannel::Stop");
fThread.Kill();
}
void JackMachClientChannel::ClientCheck(const char* name, char* name_res, int protocol, int options, int* status, int* result)
{
kern_return_t res = rpc_jack_client_check(fServerPort.GetPort(), (char*)name, name_res, protocol, options, status, result);
if (res != KERN_SUCCESS) {
*result = -1;
jack_error("JackMachClientChannel::ClientCheck err = %s", mach_error_string(res));
}
}
void JackMachClientChannel::ClientOpen(const char* name, int pid, int* shared_engine, int* shared_client, int* shared_graph, int* result)
{
kern_return_t res = rpc_jack_client_open(fServerPort.GetPort(), (char*)name, pid, &fPrivatePort, shared_engine, shared_client, shared_graph, result);
if (res != KERN_SUCCESS) {
*result = -1;
jack_error("JackMachClientChannel::ClientOpen err = %s", mach_error_string(res));
}
}
void JackMachClientChannel::ClientClose(int refnum, int* result)
{
kern_return_t res = rpc_jack_client_close(fPrivatePort, refnum, result);
if (res != KERN_SUCCESS) {
*result = -1;
jack_error("JackMachClientChannel::ClientClose err = %s", mach_error_string(res));
}
}
void JackMachClientChannel::ClientActivate(int refnum, int is_real_time, int* result)
{
kern_return_t res = rpc_jack_client_activate(fPrivatePort, refnum, is_real_time, result);
if (res != KERN_SUCCESS) {
*result = -1;
jack_error("JackMachClientChannel::ClientActivate err = %s", mach_error_string(res));
}
}
void JackMachClientChannel::ClientDeactivate(int refnum, int* result)
{
kern_return_t res = rpc_jack_client_deactivate(fPrivatePort, refnum, result);
if (res != KERN_SUCCESS) {
*result = -1;
jack_error("JackMachClientChannel::ClientDeactivate err = %s", mach_error_string(res));
}
}
void JackMachClientChannel::PortRegister(int refnum, const char* name, const char* type, unsigned int flags, unsigned int buffer_size, jack_port_id_t* port_index, int* result)
{
kern_return_t res = rpc_jack_port_register(fPrivatePort, refnum, (char*)name, (char*)type, flags, buffer_size, port_index, result);
if (res != KERN_SUCCESS) {
*result = -1;
jack_error("JackMachClientChannel::PortRegister err = %s", mach_error_string(res));
}
}
void JackMachClientChannel::PortUnRegister(int refnum, jack_port_id_t port_index, int* result)
{
kern_return_t res = rpc_jack_port_unregister(fPrivatePort, refnum, port_index, result);
if (res != KERN_SUCCESS) {
*result = -1;
jack_error("JackMachClientChannel::PortUnRegister err = %s", mach_error_string(res));
}
}
void JackMachClientChannel::PortConnect(int refnum, const char* src, const char* dst, int* result)
{
kern_return_t res = rpc_jack_port_connect_name(fPrivatePort, refnum, (char*)src, (char*)dst, result);
if (res != KERN_SUCCESS) {
jack_error("JackMachClientChannel::PortConnect err = %s", mach_error_string(res));
}
}
void JackMachClientChannel::PortDisconnect(int refnum, const char* src, const char* dst, int* result)
{
kern_return_t res = rpc_jack_port_disconnect_name(fPrivatePort, refnum, (char*)src, (char*)dst, result);
if (res != KERN_SUCCESS) {
*result = -1;
jack_error("JackMachClientChannel::PortDisconnect err = %s", mach_error_string(res));
}
}
void JackMachClientChannel::PortConnect(int refnum, jack_port_id_t src, jack_port_id_t dst, int* result)
{
kern_return_t res = rpc_jack_port_connect(fPrivatePort, refnum, src, dst, result);
if (res != KERN_SUCCESS) {
*result = -1;
jack_error("JackMachClientChannel::PortConnect err = %s", mach_error_string(res));
}
}
void JackMachClientChannel::PortDisconnect(int refnum, jack_port_id_t src, jack_port_id_t dst, int* result)
{
kern_return_t res = rpc_jack_port_disconnect(fPrivatePort, refnum, src, dst, result);
if (res != KERN_SUCCESS) {
*result = -1;
jack_error("JackMachClientChannel::PortDisconnect err = %s", mach_error_string(res));
}
}
void JackMachClientChannel::PortRename(int refnum, jack_port_id_t port, const char* name, int* result)
{
kern_return_t res = rpc_jack_port_rename(fPrivatePort, refnum, port, (char*)name, result);
if (res != KERN_SUCCESS) {
*result = -1;
jack_error("JackMachClientChannel::PortRename err = %s", mach_error_string(res));
}
}
void JackMachClientChannel::SetBufferSize(jack_nframes_t buffer_size, int* result)
{
kern_return_t res = rpc_jack_set_buffer_size(fPrivatePort, buffer_size, result);
if (res != KERN_SUCCESS) {
*result = -1;
jack_error("JackMachClientChannel::SetBufferSize err = %s", mach_error_string(res));
}
}
void JackMachClientChannel::SetFreewheel(int onoff, int* result)
{
kern_return_t res = rpc_jack_set_freewheel(fPrivatePort, onoff, result);
if (res != KERN_SUCCESS) {
*result = -1;
jack_error("JackMachClientChannel::SetFreewheel err = %s", mach_error_string(res));
}
}
void JackMachClientChannel::SessionNotify(int refnum, const char* target, jack_session_event_type_t type, const char *path, jack_session_command_t **result)
{
// dunno, how to generate this rpc stuff.
#if 0
kern_return_t res = rpc_jack_session_notify(fPrivatePort, target, type, path, result);
if (res != KERN_SUCCESS) {
*result = -1;
jack_error("JackMachClientChannel::SetFreewheel err = %s", mach_error_string(res));
}
#else
*result = NULL;
#endif
}
void JackMachClientChannel::ReleaseTimebase(int refnum, int* result)