Commit 3b357096 authored by sletz's avatar sletz
Browse files

Windows in progress

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@1645 0c269be4-1314-0410-8aa9-9f06e86f4224
parent 7d7f7de1
......@@ -26,9 +26,9 @@ This program is free software; you can redistribute it and/or modify
namespace Jack
{
void JackWinEvent::BuildName(const char* name, char* res)
void JackWinEvent::BuildName(const char* name, const char* server_name, char* res)
{
sprintf(res, "jack_pipe.%s", name);
sprintf(res, "jack_pipe.%s_%s", server_name, name);
}
bool JackWinEvent::Signal()
......@@ -84,9 +84,9 @@ bool JackWinEvent::TimedWait(long usec)
}
// Client side : get the published semaphore from server
bool JackWinEvent::ConnectInput(const char* name)
bool JackWinEvent::ConnectInput(const char* server_name, const char* name)
{
BuildName(name, fName);
BuildName(name, server_name, fName);
JackLog("JackWinEvent::Connect %s\n", fName);
// Temporary...
......@@ -103,14 +103,14 @@ bool JackWinEvent::ConnectInput(const char* name)
}
}
bool JackWinEvent::Connect(const char* name)
bool JackWinEvent::Connect(const char* server_name, const char* name)
{
return ConnectInput(name);
return ConnectInput(server_name, name);
}
bool JackWinEvent::ConnectOutput(const char* name)
bool JackWinEvent::ConnectOutput(const char* server_name, const char* name)
{
return ConnectInput(name);
return ConnectInput(server_name, name);
}
bool JackWinEvent::Disconnect()
......@@ -125,9 +125,9 @@ bool JackWinEvent::Disconnect()
}
}
bool JackWinEvent::Allocate(const char* name, int value)
bool JackWinEvent::Allocate(const char* name, const char* server_name, int value)
{
BuildName(name, fName);
BuildName(name, server_name, fName);
JackLog("JackWinEvent::Allocate name = %s val = %ld\n", fName, value);
/* create an auto reset event */
......
......@@ -43,7 +43,7 @@ class JackWinEvent : public JackSynchro
protected:
void BuildName(const char* name, char* res);
void BuildName(const char* name, const char* server_name, char* res);
public:
......@@ -57,10 +57,10 @@ class JackWinEvent : public JackSynchro
bool Wait();
bool TimedWait(long usec);
bool Allocate(const char* name, int value);
bool Connect(const char* name);
bool ConnectInput(const char* name);
bool ConnectOutput(const char* name);
bool Allocate(const char* name, const char* server_name, int value);
bool Connect(const char* name, const char* server_name);
bool ConnectInput(const char* name, const char* server_name);
bool ConnectOutput(const char* name, const char* server_name);
bool Disconnect();
void Destroy();
};
......
......@@ -52,7 +52,7 @@ int JackWinNamedPipe::Write(void* data, int len)
int JackWinNamedPipeClient::Connect(const char* dir, int which)
{
sprintf(fName, "\\\\.\\pipe\\%s_jack_%d", dir, which);
sprintf(fName, "\\\\.\\pipe\\%s_jack_%d", dir, which);
JackLog("Connect: fName %s\n", fName);
fNamedPipe = CreateFile(fName, // pipe name
......@@ -74,7 +74,7 @@ int JackWinNamedPipeClient::Connect(const char* dir, int which)
int JackWinNamedPipeClient::Connect(const char* dir, const char* name, int which)
{
sprintf(fName, "\\\\.\\pipe\\%s_jack_%s", dir, name);
sprintf(fName, "\\\\.\\pipe\\%s_jack_%s_%d", dir, name, which);
JackLog("Connect: fName %s\n", fName);
fNamedPipe = CreateFile(fName, // pipe name
......@@ -221,8 +221,8 @@ int JackWinAsyncNamedPipeClient::Write(void* data, int len)
int JackWinNamedPipeServer::Bind(const char* dir, int which)
{
sprintf(fName, "\\\\.\\pipe\\%s_jack_%d", dir, which);
JackLog("Bind: fName %s\n", fName);
sprintf(fName, "\\\\.\\pipe\\%s_jack_%d", dir, which);
JackLog("Bind: fName %s\n", fName);
if ((fNamedPipe = CreateNamedPipe(fName,
PIPE_ACCESS_DUPLEX, // read/write access
......@@ -243,8 +243,8 @@ int JackWinNamedPipeServer::Bind(const char* dir, int which)
int JackWinNamedPipeServer::Bind(const char* dir, const char* name, int which)
{
sprintf(fName, "\\\\.\\pipe\\%s_jack_%s", dir, name);
JackLog("Bind: fName %s\n", fName);
sprintf(fName, "\\\\.\\pipe\\%s_jack_%s_%d", dir, name, which);
JackLog("Bind: fName %s\n", fName);
if ((fNamedPipe = CreateNamedPipe(fName,
PIPE_ACCESS_DUPLEX, // read/write access
......@@ -283,7 +283,8 @@ JackWinNamedPipeClient* JackWinNamedPipeServer::AcceptClient()
if (ConnectNamedPipe(fNamedPipe, NULL)) {
JackWinNamedPipeClient* client = new JackWinNamedPipeClient(fNamedPipe);
// Init the pipe to the default value
fNamedPipe = INVALID_HANDLE_VALUE;
fNamedPipe = INVALID_HANDLE_VALUE;
return client;
} else {
switch (GetLastError()) {
......@@ -338,7 +339,7 @@ int JackWinAsyncNamedPipeServer::Bind(const char* dir, int which)
int JackWinAsyncNamedPipeServer::Bind(const char* dir, const char* name, int which)
{
sprintf(fName, "\\\\.\\pipe\\%s_jack_%s", dir, name);
sprintf(fName, "\\\\.\\pipe\\%s_jack_%s_%d", dir, name, which);
JackLog("Bind: fName %s\n", fName);
if ((fNamedPipe = CreateNamedPipe(fName,
......
......@@ -41,7 +41,7 @@ int JackWinNamedPipeClientChannel::ServerCheck(const char* server_name)
JackLog("JackWinNamedPipeClientChannel::ServerCheck = %s\n", server_name);
// Connect to server
if (fRequestPipe.Connect(jack_server_dir, 0) < 0) {
if (fRequestPipe.Connect(jack_server_dir, server_name, 0) < 0) {
jack_error("Cannot connect to server pipe");
return -1;
} else {
......@@ -62,7 +62,7 @@ int JackWinNamedPipeClientChannel::Open(const char* server_name, const char* nam
}
*/
if (fRequestPipe.Connect(jack_server_dir, 0) < 0) {
if (fRequestPipe.Connect(jack_server_dir, server_name, 0) < 0) {
jack_error("Cannot connect to server pipe");
goto error;
}
......
......@@ -54,7 +54,7 @@ JackClientPipeThread::~JackClientPipeThread()
delete fThread;
}
int JackClientPipeThread::Open(const char* server_name, JackServer* server) // Open the Server/Client connection
int JackClientPipeThread::Open(JackServer* server) // Open the Server/Client connection
{
fServer = server;
......@@ -368,14 +368,14 @@ JackWinNamedPipeServerChannel::~JackWinNamedPipeServerChannel()
delete fThread;
}
int JackWinNamedPipeServerChannel::Open(JackServer* server)
int JackWinNamedPipeServerChannel::Open(const char* server_name, JackServer* server)
{
JackLog("JackWinNamedPipeServerChannel::Open \n");
fServer = server;
// Needed for internal connection from JackWinNamedPipeServerNotifyChannel object
if (fRequestListenPipe.Bind(jack_server_dir, 0) < 0) {
if (fRequestListenPipe.Bind(jack_server_dir, server_name, 0) < 0) {
jack_error("JackWinNamedPipeServerChannel::Open : cannot create result listen pipe");
return false;
}
......
......@@ -50,7 +50,7 @@ class JackClientPipeThread : public JackRunnableInterface
JackClientPipeThread(JackWinNamedPipeClient* pipe);
virtual ~JackClientPipeThread();
int Open(const char* server_name, JackServer* server); // Open the Server/Client connection
int Open(JackServer* server); // Open the Server/Client connection
void Close(); // Close the Server/Client connection
int HandleRequest();
......@@ -87,7 +87,7 @@ class JackWinNamedPipeServerChannel : public JackServerChannelInterface, public
JackWinNamedPipeServerChannel();
virtual ~JackWinNamedPipeServerChannel();
int Open(JackServer* server); // Open the Server/Client connection
int Open(const char* server_name, JackServer* server); // Open the Server/Client connection
void Close(); // Close the Server/Client connection
// JackRunnableInterface interface
......
......@@ -27,7 +27,7 @@ namespace Jack
int JackWinNamedPipeServerNotifyChannel::Open(const char* server_name)
{
if (fRequestPipe.Connect(jack_server_dir, 0) < 0) {
if (fRequestPipe.Connect(jack_server_dir, server_name, 0) < 0) {
jack_error("Cannot connect to server pipe");
return -1;
} else {
......
......@@ -33,7 +33,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
using namespace Jack;
static JackServer* fServer;
static char *server_name = "jackdmp_default";
static char *server_name = "default";
static int realtime_priority = 10;
static int do_mlock = 1;
static unsigned int port_max = 128;
......@@ -89,10 +89,10 @@ static void usage (FILE *file)
" to display options for each driver\n\n");
}
static int JackStart(jack_driver_desc_t* driver_desc, JSList* driver_params, int sync, int time_out_ms, int rt, int priority, int loopback, int verbose)
static int JackStart(jack_driver_desc_t* driver_desc, JSList* driver_params, int sync, int time_out_ms, int rt, int priority, int loopback, int verbose, const char* server_name)
{
printf("Jackdmp: sync = %ld timeout = %ld rt = %ld priority = %ld verbose = %ld \n", sync, time_out_ms, rt, priority, verbose);
fServer = new JackServer(sync, temporary, time_out_ms, rt, priority, loopback, verbose);
fServer = new JackServer(sync, temporary, time_out_ms, rt, priority, loopback, verbose, server_name);
int res = fServer->Open(driver_desc, driver_params);
return (res < 0) ? res : fServer->Start();
}
......@@ -450,7 +450,7 @@ int main(int argc, char* argv[])
if (!realtime && client_timeout == 0)
client_timeout = 500; /* 0.5 sec; usable when non realtime. */
int res = JackStart(driver_desc, driver_params, sync, client_timeout, realtime, realtime_priority, loopback, xverbose);
int res = JackStart(driver_desc, driver_params, sync, client_timeout, realtime, realtime_priority, loopback, xverbose, server_name);
if (res < 0) {
printf("Cannot start server... exit\n");
JackDelete();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment