git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@2110 0c269be4-1314-0410-8aa9-9f06e86f4224tags/0.71
@@ -20,6 +20,10 @@ Fernando Lopez-Lezcano | |||||
Jackdmp changes log | Jackdmp changes log | ||||
--------------------------- | --------------------------- | ||||
2008-03-31 Stephane Letz <letz@grame.fr> | |||||
* New SetBlocking method for JackSocket. | |||||
2008-03-29 Stephane Letz <letz@grame.fr> | 2008-03-29 Stephane Letz <letz@grame.fr> | ||||
* Correct a missing parameter in the usage message of jack_midiseq. | * Correct a missing parameter in the usage message of jack_midiseq. | ||||
@@ -201,9 +201,9 @@ class JackServerNotifyChannelInterface | |||||
virtual void Close() | virtual void Close() | ||||
{} | {} | ||||
virtual void ClientNotify(int refnum, int notify, int value) | |||||
virtual void Notify(int refnum, int notify, int value) | |||||
{} | {} | ||||
}; | }; | ||||
@@ -134,7 +134,7 @@ void JackEngine::ProcessNext(jack_time_t callback_usecs) | |||||
{ | { | ||||
fLastSwitchUsecs = callback_usecs; | fLastSwitchUsecs = callback_usecs; | ||||
if (fGraphManager->RunNextGraph()) // True if the graph actually switched to a new state | if (fGraphManager->RunNextGraph()) // True if the graph actually switched to a new state | ||||
fChannel->ClientNotify(ALL_CLIENTS, kGraphOrderCallback, 0); | |||||
fChannel->Notify(ALL_CLIENTS, kGraphOrderCallback, 0); | |||||
fSignal->SignalAll(); // Signal for threads waiting for next cycle | fSignal->SignalAll(); // Signal for threads waiting for next cycle | ||||
} | } | ||||
@@ -191,12 +191,12 @@ void JackEngine::CheckXRun(jack_time_t callback_usecs) // REVOIR les conditions | |||||
if (status != NotTriggered && status != Finished) { | if (status != NotTriggered && status != Finished) { | ||||
jack_error("JackEngine::XRun: client = %s was not run: state = %ld", client->GetClientControl()->fName, status); | jack_error("JackEngine::XRun: client = %s was not run: state = %ld", client->GetClientControl()->fName, status); | ||||
fChannel->ClientNotify(ALL_CLIENTS, kXRunCallback, 0); // Notify all clients | |||||
fChannel->Notify(ALL_CLIENTS, kXRunCallback, 0); // Notify all clients | |||||
} | } | ||||
if (status == Finished && (long)(finished_date - callback_usecs) > 0) { | if (status == Finished && (long)(finished_date - callback_usecs) > 0) { | ||||
jack_error("JackEngine::XRun: client %s finished after current callback", client->GetClientControl()->fName); | jack_error("JackEngine::XRun: client %s finished after current callback", client->GetClientControl()->fName); | ||||
fChannel->ClientNotify(ALL_CLIENTS, kXRunCallback, 0); // Notify all clients | |||||
fChannel->Notify(ALL_CLIENTS, kXRunCallback, 0); // Notify all clients | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -272,7 +272,7 @@ void JackEngine::NotifyXRun(jack_time_t callback_usecs) | |||||
{ | { | ||||
// Use the audio thread => request thread communication channel | // Use the audio thread => request thread communication channel | ||||
fEngineControl->ResetFrameTime(callback_usecs); | fEngineControl->ResetFrameTime(callback_usecs); | ||||
fChannel->ClientNotify(ALL_CLIENTS, kXRunCallback, 0); | |||||
fChannel->Notify(ALL_CLIENTS, kXRunCallback, 0); | |||||
} | } | ||||
void JackEngine::NotifyXRun(int refnum) | void JackEngine::NotifyXRun(int refnum) | ||||
@@ -33,7 +33,7 @@ void JackClientSocket::SetReadTimeOut(long sec) | |||||
timout.tv_sec = sec; | timout.tv_sec = sec; | ||||
timout.tv_usec = 0; | timout.tv_usec = 0; | ||||
if (setsockopt(fSocket, SOL_SOCKET, SO_RCVTIMEO, (const char*)&timout, sizeof(timeval)) < 0) { | if (setsockopt(fSocket, SOL_SOCKET, SO_RCVTIMEO, (const char*)&timout, sizeof(timeval)) < 0) { | ||||
jack_log("setsockopt SO_RCVTIMEO fd = %ld err = %s", fSocket, strerror(errno)); | |||||
jack_error("SetReadTimeOut fd = %ld err = %s", fSocket, strerror(errno)); | |||||
} | } | ||||
} | } | ||||
@@ -43,7 +43,15 @@ void JackClientSocket::SetWriteTimeOut(long sec) | |||||
timout.tv_sec = sec ; | timout.tv_sec = sec ; | ||||
timout.tv_usec = 0; | timout.tv_usec = 0; | ||||
if (setsockopt(fSocket, SOL_SOCKET, SO_SNDTIMEO, (const char*)&timout, sizeof(timeval)) < 0) { | if (setsockopt(fSocket, SOL_SOCKET, SO_SNDTIMEO, (const char*)&timout, sizeof(timeval)) < 0) { | ||||
jack_log("setsockopt SO_SNDTIMEO fd = %ld err = %s", fSocket, strerror(errno)); | |||||
jack_error("SetWriteTimeOut fd = %ld err = %s", fSocket, strerror(errno)); | |||||
} | |||||
} | |||||
void JackClientSocket::SetBlocking(bool onoff) | |||||
{ | |||||
int flag = (onoff) ? 1 : 0; | |||||
if (ioctl(fSocket, FIONBIO, &flag) < 0) { | |||||
jack_error("SetBlocking fd = %ld err = %s", fSocket, strerror(errno)); | |||||
} | } | ||||
} | } | ||||
@@ -120,13 +128,11 @@ int JackClientSocket::Close() | |||||
int JackClientSocket::Read(void* data, int len) | int JackClientSocket::Read(void* data, int len) | ||||
{ | { | ||||
int len1; | |||||
if ((len1 = read(fSocket, data, len)) != len) { | |||||
if (read(fSocket, data, len) != len) { | |||||
jack_error("Cannot read socket fd = %d err = %s", fSocket, strerror(errno)); | jack_error("Cannot read socket fd = %d err = %s", fSocket, strerror(errno)); | ||||
if (errno == EWOULDBLOCK) { | if (errno == EWOULDBLOCK) { | ||||
jack_log("JackClientSocket::Read time out"); | |||||
return 0; | |||||
jack_error("JackClientSocket::Read time out"); | |||||
return 0; // For a non blocking socket, a read failure is not considered as an error | |||||
} else { | } else { | ||||
return -1; | return -1; | ||||
} | } | ||||
@@ -139,7 +145,12 @@ int JackClientSocket::Write(void* data, int len) | |||||
{ | { | ||||
if (write(fSocket, data, len) != len) { | if (write(fSocket, data, len) != len) { | ||||
jack_error("Cannot write socket fd = %ld err = %s", fSocket, strerror(errno)); | jack_error("Cannot write socket fd = %ld err = %s", fSocket, strerror(errno)); | ||||
return -1; | |||||
if (errno == EWOULDBLOCK) { | |||||
jack_log("JackClientSocket::Write time out"); | |||||
return 0; // For a non blocking socket, a write failure is not considered as an error | |||||
} else { | |||||
return -1; | |||||
} | |||||
} else { | } else { | ||||
return 0; | return 0; | ||||
} | } | ||||
@@ -25,6 +25,7 @@ Copyright (C) 2004-2008 Grame | |||||
#include <sys/un.h> | #include <sys/un.h> | ||||
#include <sys/types.h> | #include <sys/types.h> | ||||
#include <sys/socket.h> | #include <sys/socket.h> | ||||
#include <sys/ioctl.h> | |||||
#include <sys/time.h> | #include <sys/time.h> | ||||
#include <arpa/inet.h> | #include <arpa/inet.h> | ||||
#include <errno.h> | #include <errno.h> | ||||
@@ -67,6 +68,8 @@ class JackClientSocket : public JackChannelTransaction | |||||
} | } | ||||
void SetReadTimeOut(long sec); | void SetReadTimeOut(long sec); | ||||
void SetWriteTimeOut(long sec); | void SetWriteTimeOut(long sec); | ||||
void SetBlocking(bool onoff); | |||||
}; | }; | ||||
/*! | /*! | ||||
@@ -35,6 +35,7 @@ int JackSocketNotifyChannel::Open(const char* name) | |||||
jack_error("Cannot connect client socket"); | jack_error("Cannot connect client socket"); | ||||
return -1; | return -1; | ||||
} | } | ||||
// Use a time out for notifications | // Use a time out for notifications | ||||
fNotifySocket.SetReadTimeOut(SOCKET_TIME_OUT); | fNotifySocket.SetReadTimeOut(SOCKET_TIME_OUT); | ||||
return 0; | return 0; | ||||
@@ -31,6 +31,7 @@ int JackSocketServerNotifyChannel::Open(const char* server_name) | |||||
jack_error("Cannot connect to server socket"); | jack_error("Cannot connect to server socket"); | ||||
return -1; | return -1; | ||||
} else { | } else { | ||||
fRequestSocket.SetBlocking(true); | |||||
return 0; | return 0; | ||||
} | } | ||||
} | } | ||||
@@ -46,7 +47,7 @@ Can the write operation block? | |||||
A non blocking write operation shoud be used : check if write can succeed, and ignore the notification otherwise | A non blocking write operation shoud be used : check if write can succeed, and ignore the notification otherwise | ||||
(since its mainly used for XRun, ignoring a notification is OK, successive XRun will come...) | (since its mainly used for XRun, ignoring a notification is OK, successive XRun will come...) | ||||
*/ | */ | ||||
void JackSocketServerNotifyChannel::ClientNotify(int refnum, int notify, int value) | |||||
void JackSocketServerNotifyChannel::Notify(int refnum, int notify, int value) | |||||
{ | { | ||||
JackClientNotificationRequest req(refnum, notify, value); | JackClientNotificationRequest req(refnum, notify, value); | ||||
if (req.Write(&fRequestSocket) < 0) { | if (req.Write(&fRequestSocket) < 0) { | ||||
@@ -46,7 +46,7 @@ class JackSocketServerNotifyChannel : public JackServerNotifyChannelInterface | |||||
int Open(const char* server_name); | int Open(const char* server_name); | ||||
void Close(); | void Close(); | ||||
void ClientNotify(int refnum, int notify, int value); | |||||
void Notify(int refnum, int notify, int value); | |||||
}; | }; | ||||
} // end of namespace | } // end of namespace | ||||
@@ -44,7 +44,7 @@ void JackMachServerNotifyChannel::Close() | |||||
//fClientPort.DisconnectPort(); pas nŽcessaire car le JackMachServerChannel a dŽja disparu? | //fClientPort.DisconnectPort(); pas nŽcessaire car le JackMachServerChannel a dŽja disparu? | ||||
} | } | ||||
void JackMachServerNotifyChannel::ClientNotify(int refnum, int notify, int value) | |||||
void JackMachServerNotifyChannel::Notify(int refnum, int notify, int value) | |||||
{ | { | ||||
kern_return_t res = rpc_jack_client_rt_notify(fClientPort.GetPort(), refnum, notify, value, 0); | kern_return_t res = rpc_jack_client_rt_notify(fClientPort.GetPort(), refnum, notify, value, 0); | ||||
if (res != KERN_SUCCESS) { | if (res != KERN_SUCCESS) { | ||||
@@ -47,7 +47,7 @@ class JackMachServerNotifyChannel : public JackServerNotifyChannelInterface | |||||
int Open(const char* server_name); // Open the Server/Client connection | int Open(const char* server_name); // Open the Server/Client connection | ||||
void Close(); // Close the Server/Client connection | void Close(); // Close the Server/Client connection | ||||
void ClientNotify(int refnum, int notify, int value); | |||||
void Notify(int refnum, int notify, int value); | |||||
}; | }; | ||||
} // end of namespace | } // end of namespace | ||||
@@ -46,7 +46,7 @@ Can the write operation block? | |||||
A non blocking write operation shoud be used : check if write can succeed, and ignore the notification otherwise | A non blocking write operation shoud be used : check if write can succeed, and ignore the notification otherwise | ||||
(since its mainly used for XRun, ignoring a notification is OK, successive XRun will come...) | (since its mainly used for XRun, ignoring a notification is OK, successive XRun will come...) | ||||
*/ | */ | ||||
void JackWinNamedPipeServerNotifyChannel::ClientNotify(int refnum, int notify, int value) | |||||
void JackWinNamedPipeServerNotifyChannel::Notify(int refnum, int notify, int value) | |||||
{ | { | ||||
JackClientNotificationRequest req(refnum, notify, value); | JackClientNotificationRequest req(refnum, notify, value); | ||||
if (req.Write(&fRequestPipe) < 0) { | if (req.Write(&fRequestPipe) < 0) { | ||||
@@ -46,7 +46,7 @@ class JackWinNamedPipeServerNotifyChannel : public JackServerNotifyChannelInterf | |||||
int Open(const char* server_name); | int Open(const char* server_name); | ||||
void Close(); | void Close(); | ||||
void ClientNotify(int refnum, int notify, int value); | |||||
void Notify(int refnum, int notify, int value); | |||||
}; | }; | ||||
} // end of namespace | } // end of namespace | ||||