Commit 32bc4fa5 authored by sletz's avatar sletz
Browse files

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
parent bf1f5e20
......@@ -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>
......
......@@ -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
......
......@@ -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()
{
......
......@@ -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:
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -161,6 +161,9 @@ void JackWinNamedPipeClient::SetWriteTimeOut(long sec)
*/
}
void JackWinNamedPipeClient::SetNonBlocking(bool onoff)
{}
JackWinAsyncNamedPipeClient::JackWinAsyncNamedPipeClient()
: JackWinNamedPipeClient(), fPendingIO(false), fIOState(kIdle)
{
......
......@@ -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
......
......@@ -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;
......
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