Commit 18c15616 authored by sletz's avatar sletz
Browse files

NetJack2: improve error reporting.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4498 0c269be4-1314-0410-8aa9-9f06e86f4224
parent 0ce0e640
......@@ -35,6 +35,10 @@ Chris Caudle
Jackdmp changes log
---------------------------
2011-07-22 Stephane Letz <letz@grame.fr>
* NetJack2: improve error reporting.
2011-07-16 Stephane Letz <letz@grame.fr>
* Error in JackActivationCount::Signal now uses jack_log instead of jack_error.
......
......@@ -1993,7 +1993,7 @@ LIB_EXPORT int jack_set_session_callback(jack_client_t* ext_client, JackSessionC
}
}
LIB_EXPORT jack_session_command_t *jack_session_notify(jack_client_t* ext_client, const char* target, jack_session_event_type_t ev_type, const char* path)
LIB_EXPORT jack_session_command_t* jack_session_notify(jack_client_t* ext_client, const char* target, jack_session_event_type_t ev_type, const char* path)
{
#ifdef __CLIENTDEBUG__
JackGlobals::CheckContext("jack_session_notify");
......@@ -2039,7 +2039,7 @@ LIB_EXPORT void jack_session_event_free(jack_session_event_t* ev)
}
}
LIB_EXPORT char *jack_get_uuid_for_client_name(jack_client_t* ext_client, const char* client_name)
LIB_EXPORT char* jack_get_uuid_for_client_name(jack_client_t* ext_client, const char* client_name)
{
#ifdef __CLIENTDEBUG__
JackGlobals::CheckContext("jack_get_uuid_for_client_name");
......@@ -2054,7 +2054,7 @@ LIB_EXPORT char *jack_get_uuid_for_client_name(jack_client_t* ext_client, const
}
}
LIB_EXPORT char *jack_get_client_name_by_uuid(jack_client_t* ext_client, const char* client_uuid)
LIB_EXPORT char* jack_get_client_name_by_uuid(jack_client_t* ext_client, const char* client_uuid)
{
#ifdef __CLIENTDEBUG__
JackGlobals::CheckContext("jack_get_client_name_by_uuid");
......
......@@ -554,8 +554,13 @@ namespace Jack
fNetTimeMon->Add(((float)(GetMicroSeconds() - fRcvSyncUst) / (float)fEngineControl->fPeriodUsecs) * 100.f);
#endif
//audio, midi or sync if driver is late
if (DataRecv() == SOCKET_ERROR)
int res = DataRecv();
if (res == SOCKET_ERROR) {
return SOCKET_ERROR;
} else if (res == NET_PACKET_ERROR) {
jack_time_t cur_time = GetMicroSeconds();
NotifyXRun(cur_time, float(cur_time - fBeginDateUst)); // Better this value than nothing...
}
//take the time at the beginning of the cycle
JackDriver::CycleTakeBeginTime();
......
......@@ -581,7 +581,7 @@ namespace Jack
fRxHeader.fSubCycle = rx_head->fSubCycle;
fRxHeader.fIsLastPckt = rx_head->fIsLastPckt;
fRxHeader.fActivePorts = rx_head->fActivePorts;
fNetAudioPlaybackBuffer->RenderFromNetwork(rx_head->fCycle, rx_head->fSubCycle, rx_bytes - HEADER_SIZE, fRxHeader.fActivePorts);
rx_bytes = fNetAudioPlaybackBuffer->RenderFromNetwork(rx_head->fCycle, rx_head->fSubCycle, rx_bytes - HEADER_SIZE, fRxHeader.fActivePorts);
// Last audio packet is received, so finish rendering...
if (fRxHeader.fIsLastPckt)
fNetAudioPlaybackBuffer->RenderToJackPorts();
......@@ -591,7 +591,7 @@ namespace Jack
jack_info("NetMaster : overloaded, skipping receive from '%s'", fParams.fName);
// TODO : finish midi and audio rendering ?
fNetAudioPlaybackBuffer->RenderToJackPorts();
return 0;
return NET_PACKET_ERROR;
}
}
}
......@@ -978,7 +978,7 @@ namespace Jack
fRxHeader.fSubCycle = rx_head->fSubCycle;
fRxHeader.fIsLastPckt = rx_head->fIsLastPckt;
fRxHeader.fActivePorts = rx_head->fActivePorts;
fNetAudioCaptureBuffer->RenderFromNetwork(rx_head->fCycle, rx_head->fSubCycle, rx_bytes - HEADER_SIZE, fRxHeader.fActivePorts);
rx_bytes = fNetAudioCaptureBuffer->RenderFromNetwork(rx_head->fCycle, rx_head->fSubCycle, rx_bytes - HEADER_SIZE, fRxHeader.fActivePorts);
// Last audio packet is received, so finish rendering...
if (fRxHeader.fIsLastPckt)
fNetAudioCaptureBuffer->RenderToJackPorts();
......@@ -988,13 +988,13 @@ namespace Jack
jack_info("NetSlave : overloaded, skipping receive");
// TODO : finish midi and audio rendering ?
fNetAudioCaptureBuffer->RenderToJackPorts();
return 0;
return NET_PACKET_ERROR;
}
}
}
fRxHeader.fCycle = rx_head->fCycle;
return 0;
return rx_bytes;
}
int JackNetSlaveInterface::SyncSend()
......
......@@ -19,6 +19,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "JackNetManager.h"
#include "JackArgParser.h"
#include "JackTime.h"
#include "JackServerGlobals.h"
#include "JackLockedEngine.h"
using namespace std;
......@@ -407,7 +409,11 @@ namespace Jack
//process-----------------------------------------------------------------------------
int JackNetMaster::SetProcess(jack_nframes_t nframes, void* arg)
{
return static_cast<JackNetMaster*> ( arg )->Process();
try {
return static_cast<JackNetMaster*>(arg)->Process();
} catch (JackNetException& e) {
return 0;
}
}
int JackNetMaster::Process()
......@@ -441,8 +447,8 @@ namespace Jack
}
#else
fNetAudioCaptureBuffer->SetBuffer(audio_port_index,
static_cast<sample_t*>(jack_port_get_buffer(fAudioCapturePorts[audio_port_index],
fParams.fPeriodSize)));
static_cast<sample_t*>(jack_port_get_buffer(fAudioCapturePorts[audio_port_index],
fParams.fPeriodSize)));
#endif
// TODO
}
......@@ -523,8 +529,12 @@ namespace Jack
//receive data
res = DataRecv();
if ((res == 0) || (res == SOCKET_ERROR))
if ((res == 0) || (res == SOCKET_ERROR)) {
return res;
} else if (res == NET_PACKET_ERROR) {
// Well not a real XRun, but...
JackServerGlobals::fInstance->GetEngine()->NotifyXRun(GetMicroSeconds(), 0);
}
/*
switch (DataRecv()) {
......
......@@ -230,9 +230,9 @@ namespace Jack
}
//network<->buffer
void NetFloatAudioBuffer::RenderFromNetwork(int cycle, int sub_cycle, size_t copy_size, uint32_t port_num)
int NetFloatAudioBuffer::RenderFromNetwork(int cycle, int sub_cycle, size_t copy_size, uint32_t port_num)
{
fPortBuffer.RenderFromNetwork(fNetBuffer, cycle, sub_cycle, copy_size, port_num);
return fPortBuffer.RenderFromNetwork(fNetBuffer, cycle, sub_cycle, copy_size, port_num);
}
int NetFloatAudioBuffer::RenderToNetwork(int sub_cycle, uint32_t& port_num)
......@@ -445,8 +445,10 @@ namespace Jack
}
//network<->buffer
void NetCeltAudioBuffer::RenderFromNetwork(int cycle, int sub_cycle, size_t copy_size, uint32_t port_num)
int NetCeltAudioBuffer::RenderFromNetwork(int cycle, int sub_cycle, size_t copy_size, uint32_t port_num)
{
int res = 0;
if (sub_cycle == fNumPackets - 1) {
for (int port_index = 0; port_index < fNPorts; port_index++)
memcpy(fCompressedBuffer[port_index] + sub_cycle * fSubPeriodBytesSize, fNetBuffer + port_index * fLastSubPeriodBytesSize, fLastSubPeriodBytesSize);
......@@ -455,10 +457,13 @@ namespace Jack
memcpy(fCompressedBuffer[port_index] + sub_cycle * fSubPeriodBytesSize, fNetBuffer + port_index * fSubPeriodBytesSize, fSubPeriodBytesSize);
}
if (sub_cycle != fLastSubCycle + 1)
if (sub_cycle != fLastSubCycle + 1) {
jack_error("Packet(s) missing from... %d %d", fLastSubCycle, sub_cycle);
res = 1;
}
fLastSubCycle = sub_cycle;
return res;
}
int NetCeltAudioBuffer::RenderToNetwork(int sub_cycle, uint32_t& port_num)
......@@ -575,8 +580,10 @@ namespace Jack
}
//network<->buffer
void NetIntAudioBuffer::RenderFromNetwork(int cycle, int sub_cycle, size_t copy_size, uint32_t port_num)
int NetIntAudioBuffer::RenderFromNetwork(int cycle, int sub_cycle, size_t copy_size, uint32_t port_num)
{
int res = 0;
if (sub_cycle == fNumPackets - 1) {
for (int port_index = 0; port_index < fNPorts; port_index++)
memcpy(fIntBuffer[port_index] + sub_cycle * fSubPeriodSize, fNetBuffer + port_index * fLastSubPeriodBytesSize, fLastSubPeriodBytesSize);
......@@ -585,10 +592,13 @@ namespace Jack
memcpy(fIntBuffer[port_index] + sub_cycle * fSubPeriodSize, fNetBuffer + port_index * fSubPeriodBytesSize, fSubPeriodBytesSize);
}
if (sub_cycle != fLastSubCycle + 1)
if (sub_cycle != fLastSubCycle + 1) {
jack_error("Packet(s) missing from... %d %d", fLastSubCycle, sub_cycle);
res = -1;
}
fLastSubCycle = sub_cycle;
return res;
}
int NetIntAudioBuffer::RenderToNetwork(int sub_cycle, uint32_t& port_num)
......
......@@ -42,6 +42,8 @@ using namespace std;
#define MASTER_PROTOCOL 4
#define SLAVE_PROTOCOL 4
#define NET_PACKET_ERROR -2
#define OPTIMIZED_PROTOCOL
namespace Jack
......@@ -288,7 +290,7 @@ namespace Jack
virtual void RenderToJackPorts() = 0;
//network<->buffer
virtual void RenderFromNetwork(int cycle, int sub_cycle, size_t copy_size, uint32_t port_num) = 0;
virtual int RenderFromNetwork(int cycle, int sub_cycle, size_t copy_size, uint32_t port_num) = 0;
virtual void ActivePortsFromNetwork(char* net_buffer, uint32_t port_num) {}
virtual int RenderToNetwork(int sub_cycle, uint32_t& port_num) = 0;
......@@ -424,8 +426,10 @@ namespace Jack
{}
//network<->buffer
virtual void RenderFromNetwork(char* net_buffer, int cycle, int sub_cycle, size_t copy_size, uint32_t port_num)
virtual int RenderFromNetwork(char* net_buffer, int cycle, int sub_cycle, size_t copy_size, uint32_t port_num)
{
int res = 0;
for (int port_index = 0; port_index < fNPorts; port_index++) {
float* src = (float*)(net_buffer + port_index * fSubPeriodBytesSize);
float* dst = (float*)(fPortBuffer[port_index] + sub_cycle * fSubPeriodSize);
......@@ -435,8 +439,11 @@ namespace Jack
}
if (sub_cycle != fLastSubCycle + 1) {
jack_error("Packet(s) missing from... %d %d", fLastSubCycle, sub_cycle);
res = -1;
}
fLastSubCycle = sub_cycle;
return res;
}
virtual int RenderToNetwork(char* net_buffer, int sub_cycle, uint32_t& port_num)
......@@ -465,15 +472,20 @@ namespace Jack
}
//network<->buffer
virtual void RenderFromNetwork(char* net_buffer, int cycle, int sub_cycle, size_t copy_size, uint32_t port_num)
virtual int RenderFromNetwork(char* net_buffer, int cycle, int sub_cycle, size_t copy_size, uint32_t port_num)
{
int res = 0;
for (int port_index = 0; port_index < fNPorts; port_index++) {
memcpy(fPortBuffer[port_index] + sub_cycle * fSubPeriodSize, net_buffer + port_index * fSubPeriodBytesSize, fSubPeriodBytesSize);
}
if (sub_cycle != fLastSubCycle + 1) {
jack_error("Packet(s) missing from... %d %d", fLastSubCycle, sub_cycle);
res = -1;
}
fLastSubCycle = sub_cycle;
return res;
}
virtual int RenderToNetwork(char* net_buffer, int sub_cycle, uint32_t& port_num)
......@@ -535,8 +547,10 @@ namespace Jack
#else
//network<->buffer
virtual void RenderFromNetwork(char* net_buffer, int cycle, int sub_cycle, size_t copy_size, uint32_t port_num)
virtual int RenderFromNetwork(char* net_buffer, int cycle, int sub_cycle, size_t copy_size, uint32_t port_num)
{
int res = 0;
// Cleanup all JACK ports at the beginning of the cycle
if (sub_cycle == 0) {
for (int port_index = 0; port_index < fNPorts; port_index++) {
......@@ -567,8 +581,11 @@ namespace Jack
if (sub_cycle != fLastSubCycle + 1) {
jack_error("Packet(s) missing from... %d %d", fLastSubCycle, sub_cycle);
res = -1;
}
fLastSubCycle = sub_cycle;
return res;
}
}
......@@ -664,7 +681,7 @@ namespace Jack
sample_t* GetBuffer(int index);
//network<->buffer
void RenderFromNetwork(int cycle, int sub_cycle, size_t copy_size, uint32_t port_num);
int RenderFromNetwork(int cycle, int sub_cycle, size_t copy_size, uint32_t port_num);
void ActivePortsFromNetwork(char* net_buffer, uint32_t port_num);
int RenderToNetwork(int sub_cycle, uint32_t& ort_num);
......@@ -721,7 +738,7 @@ namespace Jack
void RenderToJackPorts();
//network<->buffer
void RenderFromNetwork(int cycle, int sub_cycle, size_t copy_size, uint32_t port_num);
int RenderFromNetwork(int cycle, int sub_cycle, size_t copy_size, uint32_t port_num);
int RenderToNetwork(int sub_cycle, uint32_t& port_num);
};
......@@ -770,7 +787,7 @@ namespace Jack
void RenderToJackPorts();
//network<->buffer
void RenderFromNetwork(int cycle, int sub_cycle, size_t copy_size, uint32_t port_num);
int RenderFromNetwork(int cycle, int sub_cycle, size_t copy_size, uint32_t port_num);
int RenderToNetwork(int sub_cycle, uint32_t& port_num);
};
......
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