Commit 75a43e5f authored by Stephane Letz's avatar Stephane Letz
Browse files

Improve error reporting in NetJack2.

parent 905f6d7a
......@@ -422,7 +422,7 @@ struct JackNetExtMaster : public JackNetMasterInterface {
return res2;
} catch (JackNetException& e) {
jack_error("Lost connection");
jack_error(e.what());
return -1;
}
}
......@@ -458,7 +458,7 @@ struct JackNetExtMaster : public JackNetMasterInterface {
return 0;
} catch (JackNetException& e) {
jack_error("Lost connection");
jack_error(e.what());
return -1;
}
}
......
......@@ -431,7 +431,6 @@ namespace Jack
int rx_bytes;
if (((rx_bytes = fSocket.Recv(fRxBuffer, size, flags)) == SOCKET_ERROR) && fRunning) {
fSocket.PrintError();
FatalRecvError();
}
......@@ -823,14 +822,12 @@ namespace Jack
void JackNetSlaveInterface::FatalRecvError()
{
jack_error("Recv connection lost error = %s", StrError(NET_ERROR_CODE));
throw JackNetException();
throw JackNetException("Recv connection lost error");
}
void JackNetSlaveInterface::FatalSendError()
{
jack_error("Send connection lost error = %s", StrError(NET_ERROR_CODE));
throw JackNetException();
throw JackNetException("Send connection lost error");
}
int JackNetSlaveInterface::Recv(size_t size, int flags)
......@@ -839,7 +836,6 @@ namespace Jack
// handle errors
if (rx_bytes == SOCKET_ERROR) {
fSocket.PrintError();
FatalRecvError();
}
......
......@@ -498,6 +498,7 @@ namespace Jack
for (int i = 0; i < fNPorts; i++) {
fCeltMode[i] = celt_mode_create(params->fSampleRate, params->fPeriodSize, &error);
if (error != CELT_OK) {
jack_log("NetCeltAudioBuffer celt_mode_create err = %d", error);
goto error;
}
......@@ -505,12 +506,14 @@ namespace Jack
fCeltEncoder[i] = celt_encoder_create_custom(fCeltMode[i], 1, &error);
if (error != CELT_OK) {
jack_log("NetCeltAudioBuffer celt_encoder_create_custom err = %d", error);
goto error;
}
celt_encoder_ctl(fCeltEncoder[i], CELT_SET_COMPLEXITY(1));
fCeltDecoder[i] = celt_decoder_create_custom(fCeltMode[i], 1, &error);
if (error != CELT_OK) {
jack_log("NetCeltAudioBuffer celt_decoder_create_custom err = %d", error);
goto error;
}
celt_decoder_ctl(fCeltDecoder[i], CELT_SET_COMPLEXITY(1));
......@@ -519,12 +522,14 @@ namespace Jack
fCeltEncoder[i] = celt_encoder_create(fCeltMode[i], 1, &error);
if (error != CELT_OK) {
jack_log("NetCeltAudioBuffer celt_mode_create err = %d", error);
goto error;
}
celt_encoder_ctl(fCeltEncoder[i], CELT_SET_COMPLEXITY(1));
fCeltDecoder[i] = celt_decoder_create(fCeltMode[i], 1, &error);
if (error != CELT_OK) {
jack_log("NetCeltAudioBuffer celt_decoder_create err = %d", error);
goto error;
}
celt_decoder_ctl(fCeltDecoder[i], CELT_SET_COMPLEXITY(1));
......@@ -533,12 +538,14 @@ namespace Jack
fCeltEncoder[i] = celt_encoder_create(fCeltMode[i]);
if (error != CELT_OK) {
jack_log("NetCeltAudioBuffer celt_encoder_create err = %d", error);
goto error;
}
celt_encoder_ctl(fCeltEncoder[i], CELT_SET_COMPLEXITY(1));
fCeltDecoder[i] = celt_decoder_create(fCeltMode[i]);
if (error != CELT_OK) {
jack_log("NetCeltAudioBuffer celt_decoder_create err = %d", error);
goto error;
}
celt_decoder_ctl(fCeltDecoder[i], CELT_SET_COMPLEXITY(1));
......@@ -740,16 +747,19 @@ namespace Jack
/* Allocate en/decoders */
fOpusMode[i] = opus_custom_mode_create(params->fSampleRate, params->fPeriodSize, &error);
if (error != OPUS_OK) {
jack_log("NetOpusAudioBuffer opus_custom_mode_create err = %d", error);
goto error;
}
fOpusEncoder[i] = opus_custom_encoder_create(fOpusMode[i], 1, &error);
if (error != OPUS_OK) {
jack_log("NetOpusAudioBuffer opus_custom_encoder_create err = %d", error);
goto error;
}
fOpusDecoder[i] = opus_custom_decoder_create(fOpusMode[i], 1, &error);
if (error != OPUS_OK) {
jack_log("NetOpusAudioBuffer opus_custom_decoder_create err = %d", error);
goto error;
}
......@@ -1024,7 +1034,7 @@ namespace Jack
}
NextCycle();
}
}
//network<->buffer
int NetIntAudioBuffer::RenderFromNetwork(int cycle, int sub_cycle, uint32_t port_num)
......
......@@ -371,14 +371,19 @@ namespace Jack
return -1;
}
#endif
return sendto(fSockfd, buffer, nbytes, flags, reinterpret_cast<socket_address_t*>(&fSendAddr), sizeof(socket_address_t));
int res;
if ((res = sendto(fSockfd, buffer, nbytes, flags, reinterpret_cast<socket_address_t*>(&fSendAddr), sizeof(socket_address_t))) < 0) {
jack_error("SendTo fd = %ld err = %s", fSockfd, strerror(errno));
}
return res;
}
int JackNetUnixSocket::SendTo(const void* buffer, size_t nbytes, int flags, const char* ip)
{
int addr_conv = inet_aton(ip, &fSendAddr.sin_addr);
if (addr_conv < 1)
if (addr_conv < 1) {
return addr_conv;
}
#if defined(__sun__) || defined(sun)
if (WaitWrite() < 0) {
return -1;
......@@ -394,7 +399,11 @@ namespace Jack
return -1;
}
#endif
return send(fSockfd, buffer, nbytes, flags);
int res;
if ((res = send(fSockfd, buffer, nbytes, flags)) < 0) {
jack_error("Send fd = %ld err = %s", fSockfd, strerror(errno));
}
return res;
}
int JackNetUnixSocket::RecvFrom(void* buffer, size_t nbytes, int flags)
......@@ -405,7 +414,11 @@ namespace Jack
return -1;
}
#endif
return recvfrom(fSockfd, buffer, nbytes, flags, reinterpret_cast<socket_address_t*>(&fRecvAddr), &addr_len);
int res;
if ((res = recvfrom(fSockfd, buffer, nbytes, flags, reinterpret_cast<socket_address_t*>(&fRecvAddr), &addr_len)) < 0) {
jack_error("RecvFrom fd = %ld err = %s", fSockfd, strerror(errno));
}
return res;
}
int JackNetUnixSocket::Recv(void* buffer, size_t nbytes, int flags)
......@@ -415,7 +428,11 @@ namespace Jack
return -1;
}
#endif
return recv(fSockfd, buffer, nbytes, flags);
int res;
if ((res = recv(fSockfd, buffer, nbytes, flags)) < 0) {
jack_error("Recv fd = %ld err = %s", fSockfd, strerror(errno));
}
return res;
}
int JackNetUnixSocket::CatchHost(void* buffer, size_t nbytes, int flags)
......@@ -426,7 +443,11 @@ namespace Jack
return -1;
}
#endif
return recvfrom(fSockfd, buffer, nbytes, flags, reinterpret_cast<socket_address_t*>(&fSendAddr), &addr_len);
int res;
if ((res = recvfrom(fSockfd, buffer, nbytes, flags, reinterpret_cast<socket_address_t*>(&fSendAddr), &addr_len)) < 0) {
jack_error("CatchHost fd = %ld err = %s", fSockfd, strerror(errno));
}
return res;
}
net_error_t JackNetUnixSocket::GetError()
......
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