Browse Source

Use a time-out in notification channel write function.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4761 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/1.9.9.5
sletz 13 years ago
parent
commit
32bc4fa557
9 changed files with 36 additions and 7 deletions
  1. +1
    -0
      ChangeLog
  2. +1
    -1
      common/JackConstants.h
  3. +19
    -0
      common/JackNetManager.cpp
  4. +2
    -0
      common/JackNetManager.h
  5. +1
    -1
      dbus/controller_iface_patchbay.c
  6. +4
    -3
      posix/JackSocketNotifyChannel.cpp
  7. +3
    -0
      windows/JackWinNamedPipe.cpp
  8. +2
    -0
      windows/JackWinNamedPipe.h
  9. +3
    -2
      windows/JackWinNamedPipeNotifyChannel.cpp

+ 1
- 0
ChangeLog View File

@@ -39,6 +39,7 @@ John Emmas
2012-02-01 Stephane Letz <letz@grame.fr>

* Check server API callback from notification thread.
* Use a time-out in notification channel write function.

2012-01-29 Stephane Letz <letz@grame.fr>



+ 1
- 1
common/JackConstants.h View File

@@ -71,7 +71,7 @@

#define JACK_PROTOCOL_VERSION 8

#define SOCKET_TIME_OUT 5 // in sec
#define SOCKET_TIME_OUT 2 // in sec
#define DRIVER_OPEN_TIMEOUT 5 // in sec
#define FREEWHEEL_DRIVER_TIMEOUT 10 // in sec
#define DRIVER_TIMEOUT_FACTOR 10


+ 19
- 0
common/JackNetManager.cpp View File

@@ -134,6 +134,12 @@ namespace Jack
if (jack_set_buffer_size_callback(fClient, SetBufferSize, this) < 0) {
goto fail;
}
/*
if (jack_set_port_connect_callback(fClient, SetConnectCallback, this) < 0) {
goto fail;
}
*/

if (AllocPorts() != 0) {
jack_error("Can't allocate JACK ports");
@@ -387,6 +393,19 @@ namespace Jack
return 0;
}
}
void JackNetMaster::SetConnectCallback(jack_port_id_t a, jack_port_id_t b, int connect, void* arg)
{
static_cast<JackNetMaster*>(arg)->ConnectCallback(a, b, connect);
}
void JackNetMaster::ConnectCallback(jack_port_id_t a, jack_port_id_t b, int connect)
{
jack_info("JackNetMaster::ConnectCallback a = %d b = %d connect = %d", a, b, connect);
if (connect) {
jack_connect(fClient, jack_port_name(jack_port_by_id(fClient, a)), "system:playback_1");
}
}

int JackNetMaster::Process()
{


+ 2
- 0
common/JackNetManager.h View File

@@ -43,6 +43,7 @@ namespace Jack
static int SetProcess(jack_nframes_t nframes, void* arg);
static int SetBufferSize(jack_nframes_t nframes, void* arg);
static void SetTimebaseCallback(jack_transport_state_t state, jack_nframes_t nframes, jack_position_t* pos, int new_pos, void* arg);
static void SetConnectCallback(jack_port_id_t a, jack_port_id_t b, int connect, void* arg);

//jack client
jack_client_t* fClient;
@@ -74,6 +75,7 @@ namespace Jack
int Process();
void TimebaseCallback(jack_position_t* pos);
void ConnectPorts();
void ConnectCallback(jack_port_id_t a, jack_port_id_t b, int connect);

public:



+ 1
- 1
dbus/controller_iface_patchbay.c View File

@@ -782,7 +782,7 @@ jack_controller_patchbay_disconnect(
ret = jack_disconnect(controller_ptr->client, port1_name, port2_name);
if (ret != 0)
{
jack_dbus_error(dbus_call_ptr, JACK_DBUS_ERROR_GENERIC, "jack_connect() failed with %d", ret);
jack_dbus_error(dbus_call_ptr, JACK_DBUS_ERROR_GENERIC, "jack_disconnect() failed with %d", ret);
return false;
}



+ 4
- 3
posix/JackSocketNotifyChannel.cpp View File

@@ -37,6 +37,7 @@ int JackSocketNotifyChannel::Open(const char* name)
}
// Use a time out for notifications
fNotifySocket.SetWriteTimeOut(SOCKET_TIME_OUT);
fNotifySocket.SetReadTimeOut(SOCKET_TIME_OUT);
return 0;
}
@@ -55,7 +56,7 @@ void JackSocketNotifyChannel::ClientNotify(int refnum, const char* name, int not
// Send notification
if (event.Write(&fNotifySocket) < 0) {
jack_error("Could not write notification");
fNotifySocket.Close();
//fNotifySocket.Close();
*result = -1;
return;
}
@@ -64,8 +65,8 @@ void JackSocketNotifyChannel::ClientNotify(int refnum, const char* name, int not
if (sync) {
// Get result : use a time out
if (res.Read(&fNotifySocket) < 0) {
jack_error("Could not read result");
fNotifySocket.Close();
jack_error("Could not read notification result");
//fNotifySocket.Close();
*result = -1;
} else {
*result = res.fResult;


+ 3
- 0
windows/JackWinNamedPipe.cpp View File

@@ -161,6 +161,9 @@ void JackWinNamedPipeClient::SetWriteTimeOut(long sec)
*/
}

void JackWinNamedPipeClient::SetNonBlocking(bool onoff)
{}

JackWinAsyncNamedPipeClient::JackWinAsyncNamedPipeClient()
: JackWinNamedPipeClient(), fPendingIO(false), fIOState(kIdle)
{


+ 2
- 0
windows/JackWinNamedPipe.h View File

@@ -111,6 +111,8 @@ class JackWinNamedPipeClient : public JackWinNamedPipeAux, public detail::JackCl

virtual void SetReadTimeOut(long sec);
virtual void SetWriteTimeOut(long sec);
virtual void SetNonBlocking(bool onoff);
};

class JackWinAsyncNamedPipeClient : public JackWinNamedPipeClient


+ 3
- 2
windows/JackWinNamedPipeNotifyChannel.cpp View File

@@ -37,6 +37,7 @@ int JackWinNamedPipeNotifyChannel::Open(const char* name)
return -1;
}
// TODO : use a time out for notifications
fNotifyPipe.SetWriteTimeOut(SOCKET_TIME_OUT);
fNotifyPipe.SetReadTimeOut(SOCKET_TIME_OUT);
return 0;
}
@@ -55,7 +56,7 @@ void JackWinNamedPipeNotifyChannel::ClientNotify(int refnum, const char* name, i
// Send notification
if (event.Write(&fNotifyPipe) < 0) {
jack_error("Could not write notification");
fNotifyPipe.Close();
//fNotifyPipe.Close();
*result = -1;
return;
}
@@ -65,7 +66,7 @@ void JackWinNamedPipeNotifyChannel::ClientNotify(int refnum, const char* name, i
// Get result : use a time out
if (res.Read(&fNotifyPipe) < 0) {
jack_error("Could not read result");
fNotifyPipe.Close();
//fNotifyPipe.Close();
*result = -1;
} else {
*result = res.fResult;


Loading…
Cancel
Save