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> 2012-02-01 Stephane Letz <letz@grame.fr>


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


2012-01-29 Stephane Letz <letz@grame.fr> 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 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 DRIVER_OPEN_TIMEOUT 5 // in sec
#define FREEWHEEL_DRIVER_TIMEOUT 10 // in sec #define FREEWHEEL_DRIVER_TIMEOUT 10 // in sec
#define DRIVER_TIMEOUT_FACTOR 10 #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) { if (jack_set_buffer_size_callback(fClient, SetBufferSize, this) < 0) {
goto fail; goto fail;
} }
/*
if (jack_set_port_connect_callback(fClient, SetConnectCallback, this) < 0) {
goto fail;
}
*/


if (AllocPorts() != 0) { if (AllocPorts() != 0) {
jack_error("Can't allocate JACK ports"); jack_error("Can't allocate JACK ports");
@@ -387,6 +393,19 @@ namespace Jack
return 0; 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() 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 SetProcess(jack_nframes_t nframes, void* arg);
static int SetBufferSize(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 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
jack_client_t* fClient; jack_client_t* fClient;
@@ -74,6 +75,7 @@ namespace Jack
int Process(); int Process();
void TimebaseCallback(jack_position_t* pos); void TimebaseCallback(jack_position_t* pos);
void ConnectPorts(); void ConnectPorts();
void ConnectCallback(jack_port_id_t a, jack_port_id_t b, int connect);


public: 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); ret = jack_disconnect(controller_ptr->client, port1_name, port2_name);
if (ret != 0) 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; 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 // Use a time out for notifications
fNotifySocket.SetWriteTimeOut(SOCKET_TIME_OUT);
fNotifySocket.SetReadTimeOut(SOCKET_TIME_OUT); fNotifySocket.SetReadTimeOut(SOCKET_TIME_OUT);
return 0; return 0;
} }
@@ -55,7 +56,7 @@ void JackSocketNotifyChannel::ClientNotify(int refnum, const char* name, int not
// Send notification // Send notification
if (event.Write(&fNotifySocket) < 0) { if (event.Write(&fNotifySocket) < 0) {
jack_error("Could not write notification"); jack_error("Could not write notification");
fNotifySocket.Close();
//fNotifySocket.Close();
*result = -1; *result = -1;
return; return;
} }
@@ -64,8 +65,8 @@ void JackSocketNotifyChannel::ClientNotify(int refnum, const char* name, int not
if (sync) { if (sync) {
// Get result : use a time out // Get result : use a time out
if (res.Read(&fNotifySocket) < 0) { if (res.Read(&fNotifySocket) < 0) {
jack_error("Could not read result");
fNotifySocket.Close();
jack_error("Could not read notification result");
//fNotifySocket.Close();
*result = -1; *result = -1;
} else { } else {
*result = res.fResult; *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() JackWinAsyncNamedPipeClient::JackWinAsyncNamedPipeClient()
: JackWinNamedPipeClient(), fPendingIO(false), fIOState(kIdle) : 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 SetReadTimeOut(long sec);
virtual void SetWriteTimeOut(long sec); virtual void SetWriteTimeOut(long sec);
virtual void SetNonBlocking(bool onoff);
}; };


class JackWinAsyncNamedPipeClient : public JackWinNamedPipeClient class JackWinAsyncNamedPipeClient : public JackWinNamedPipeClient


+ 3
- 2
windows/JackWinNamedPipeNotifyChannel.cpp View File

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


Loading…
Cancel
Save