Commit 84c256f7 authored by sletz's avatar sletz
Browse files

NetJack2 code : better error checkout, method renaming.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3565 0c269be4-1314-0410-8aa9-9f06e86f4224
parent e8b7a090
......@@ -27,7 +27,8 @@ Paul Davis
2009-06-19 Stephane Letz <letz@grame.fr>
* Correct JackTransportEngine::MakeAllLocating, sync callback has to be called in this case also.
* Correct JackTransportEngine::MakeAllLocating, sync callback has to be called in this case also.
* NetJack2 code : better error checkout, method renaming.
2009-06-17 Stephane Letz <letz@grame.fr>
......
......@@ -204,8 +204,7 @@ namespace Jack
int rx_bytes = 0;
//socket
if ( fSocket.NewSocket() == SOCKET_ERROR )
{
if ( fSocket.NewSocket() == SOCKET_ERROR ) {
jack_error ( "Can't create socket : %s", StrError ( NET_ERROR_CODE ) );
return false;
}
......@@ -215,8 +214,7 @@ namespace Jack
jack_error ( "Can't set timeout : %s", StrError ( NET_ERROR_CODE ) );
//connect
if ( fSocket.Connect() == SOCKET_ERROR )
{
if ( fSocket.Connect() == SOCKET_ERROR ) {
jack_error ( "Can't connect : %s", StrError ( NET_ERROR_CODE ) );
return false;
}
......@@ -245,22 +243,19 @@ namespace Jack
SessionParamsNToH(&net_params, &host_params);
}
while ( ( GetPacketType ( &host_params ) != START_MASTER ) && ( ++attempt < SLAVE_SETUP_RETRY ) );
if ( attempt == SLAVE_SETUP_RETRY )
{
if ( attempt == SLAVE_SETUP_RETRY ) {
jack_error ( "Slave doesn't respond, exiting." );
return false;
}
//set the new timeout for the socket
if ( SetRxTimeout() == SOCKET_ERROR )
{
if ( SetRxTimeout() == SOCKET_ERROR ) {
jack_error ( "Can't set rx timeout : %s", StrError ( NET_ERROR_CODE ) );
return false;
}
//set the new rx buffer size
if ( SetNetBufferSize() == SOCKET_ERROR )
{
if ( SetNetBufferSize() == SOCKET_ERROR ) {
jack_error ( "Can't set net buffer sizes : %s", StrError ( NET_ERROR_CODE ) );
return false;
}
......@@ -619,7 +614,7 @@ namespace Jack
//first, get a master, do it until a valid connection is running
do
{
status = GetNetMaster();
status = SendAvailableToMaster();
if ( status == NET_SOCKET_ERROR )
return false;
}
......@@ -651,7 +646,7 @@ namespace Jack
do
{
//get a master
status = GetNetMaster();
status = SendAvailableToMaster();
if (status == NET_SOCKET_ERROR)
return false;
}
......@@ -678,26 +673,27 @@ namespace Jack
return true;
}
net_status_t JackNetSlaveInterface::GetNetMaster()
net_status_t JackNetSlaveInterface::SendAvailableToMaster()
{
jack_log ( "JackNetSlaveInterface::GetNetMaster()" );
jack_log ( "JackNetSlaveInterface::SendAvailableToMaster()" );
//utility
session_params_t host_params;
int rx_bytes = 0;
//socket
if ( fSocket.NewSocket() == SOCKET_ERROR )
{
if ( fSocket.NewSocket() == SOCKET_ERROR ) {
jack_error ( "Fatal error : network unreachable - %s", StrError ( NET_ERROR_CODE ) );
return NET_SOCKET_ERROR;
}
//bind the socket
if ( fSocket.Bind() == SOCKET_ERROR )
if ( fSocket.Bind() == SOCKET_ERROR ) {
jack_error ( "Can't bind the socket : %s", StrError ( NET_ERROR_CODE ) );
return NET_SOCKET_ERROR;
}
//timeout on receive
if ( fSocket.SetTimeOut ( SLAVE_INIT_TIMEOUT ) == SOCKET_ERROR )
if ( fSocket.SetTimeOut ( SLAVE_INIT_TIMEOUT ) == SOCKET_ERROR )
jack_error ( "Can't set timeout : %s", StrError ( NET_ERROR_CODE ) );
//disable local loop
......@@ -730,12 +726,13 @@ namespace Jack
fParams = host_params;
//set the new buffer sizes
if ( SetNetBufferSize() == SOCKET_ERROR )
if ( SetNetBufferSize() == SOCKET_ERROR ) {
jack_error ( "Can't set net buffer sizes : %s", StrError ( NET_ERROR_CODE ) );
return NET_SOCKET_ERROR;
}
//connect the socket
if ( fSocket.Connect() == SOCKET_ERROR )
{
if ( fSocket.Connect() == SOCKET_ERROR ) {
jack_error ( "Error in connect : %s", StrError ( NET_ERROR_CODE ) );
return NET_CONNECT_ERROR;
}
......
......@@ -151,7 +151,7 @@ namespace Jack
bool InitConnection();
bool InitRendering();
net_status_t GetNetMaster();
net_status_t SendAvailableToMaster();
net_status_t SendStartToMaster();
void SetParams();
......
......@@ -618,7 +618,7 @@ namespace Jack
switch ( GetPacketType ( &host_params ) )
{
case SLAVE_AVAILABLE:
if ( ( net_master = MasterInit ( host_params ) ) )
if ( ( net_master = InitMaster ( host_params ) ) )
SessionParamsDisplay ( &net_master->fParams );
else
jack_error ( "Can't init new net master..." );
......@@ -636,9 +636,9 @@ namespace Jack
while ( fRunning );
}
JackNetMaster* JackNetMasterManager::MasterInit ( session_params_t& params )
JackNetMaster* JackNetMasterManager::InitMaster ( session_params_t& params )
{
jack_log ( "JackNetMasterManager::MasterInit, Slave : %s", params.fName );
jack_log ( "JackNetMasterManager::InitMaster, Slave : %s", params.fName );
//check MASTER <<==> SLAVE network protocol coherency
if (params.fProtocolVersion != MASTER_PROTOCOL) {
......
......@@ -105,7 +105,7 @@ namespace Jack
bool fAutoConnect;
void Run();
JackNetMaster* MasterInit ( session_params_t& params );
JackNetMaster* InitMaster ( session_params_t& params );
master_list_it_t FindMaster ( uint32_t client_id );
int KillMaster ( session_params_t* params );
void SetSlaveName ( session_params_t& params );
......
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