diff --git a/ChangeLog b/ChangeLog index 94ff036c..a081ce32 100644 --- a/ChangeLog +++ b/ChangeLog @@ -39,6 +39,7 @@ John Emmas 2012-02-01 Stephane Letz * Check server API callback from notification thread. + * Use a time-out in notification channel write function. 2012-01-29 Stephane Letz diff --git a/common/JackConstants.h b/common/JackConstants.h index 9aa32a38..ab16d972 100644 --- a/common/JackConstants.h +++ b/common/JackConstants.h @@ -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 diff --git a/common/JackNetManager.cpp b/common/JackNetManager.cpp index ff15d9c5..1fb5e48f 100644 --- a/common/JackNetManager.cpp +++ b/common/JackNetManager.cpp @@ -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(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() { diff --git a/common/JackNetManager.h b/common/JackNetManager.h index 7f7facff..c88a09ba 100644 --- a/common/JackNetManager.h +++ b/common/JackNetManager.h @@ -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: diff --git a/dbus/controller_iface_patchbay.c b/dbus/controller_iface_patchbay.c index 5acee604..b0de0892 100644 --- a/dbus/controller_iface_patchbay.c +++ b/dbus/controller_iface_patchbay.c @@ -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; } diff --git a/posix/JackSocketNotifyChannel.cpp b/posix/JackSocketNotifyChannel.cpp index 35737b0d..552d8a4e 100644 --- a/posix/JackSocketNotifyChannel.cpp +++ b/posix/JackSocketNotifyChannel.cpp @@ -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; diff --git a/windows/JackWinNamedPipe.cpp b/windows/JackWinNamedPipe.cpp index c2810f63..de12c112 100644 --- a/windows/JackWinNamedPipe.cpp +++ b/windows/JackWinNamedPipe.cpp @@ -161,6 +161,9 @@ void JackWinNamedPipeClient::SetWriteTimeOut(long sec) */ } +void JackWinNamedPipeClient::SetNonBlocking(bool onoff) +{} + JackWinAsyncNamedPipeClient::JackWinAsyncNamedPipeClient() : JackWinNamedPipeClient(), fPendingIO(false), fIOState(kIdle) { diff --git a/windows/JackWinNamedPipe.h b/windows/JackWinNamedPipe.h index 44ebd982..01e971a4 100644 --- a/windows/JackWinNamedPipe.h +++ b/windows/JackWinNamedPipe.h @@ -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 diff --git a/windows/JackWinNamedPipeNotifyChannel.cpp b/windows/JackWinNamedPipeNotifyChannel.cpp index 1c559d87..7010037e 100644 --- a/windows/JackWinNamedPipeNotifyChannel.cpp +++ b/windows/JackWinNamedPipeNotifyChannel.cpp @@ -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;