Browse Source

Correct JackNetAdapter RT thread handling, cleanup.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@2845 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/1.90
sletz 17 years ago
parent
commit
495e1cb78b
5 changed files with 24 additions and 23 deletions
  1. +7
    -7
      common/JackNetAdapter.cpp
  2. +0
    -4
      common/JackNetDriver.cpp
  3. +11
    -8
      common/JackNetInterface.cpp
  4. +6
    -0
      common/JackNetInterface.h
  5. +0
    -4
      common/JackNetManager.cpp

+ 7
- 7
common/JackNetAdapter.cpp View File

@@ -14,7 +14,6 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

*/

#include "JackNetAdapter.h"
@@ -22,9 +21,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "JackServer.h"
#include "JackEngineControl.h"

#define DEFAULT_MULTICAST_IP "225.3.19.154"
#define DEFAULT_PORT 19000

namespace Jack
{
JackNetAdapter::JackNetAdapter ( jack_client_t* jack_client, jack_nframes_t buffer_size, jack_nframes_t sample_rate, const JSList* params )
@@ -150,7 +146,6 @@ namespace Jack
return -1;
}

fThread.AcquireRealTime ( JackServer::fInstance->GetEngineControl()->fPriority - 1 );
return 0;
}

@@ -221,10 +216,15 @@ namespace Jack
//set audio adapter parameters
SetAdaptedBufferSize ( fParams.fPeriodSize );
SetAdaptedSampleRate ( fParams.fSampleRate );

if (fThread.AcquireRealTime ( JackServer::fInstance->GetEngineControl()->fPriority - 1 ) < 0) {
jack_error("AcquireRealTime error");
} else {
set_threaded_log_function();
}
//init done, display parameters
SessionParamsDisplay ( &fParams );

return true;
}



+ 0
- 4
common/JackNetDriver.cpp View File

@@ -15,7 +15,6 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

*/

#include "JackNetDriver.h"
@@ -26,9 +25,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "JackThreadedDriver.h"
#include "JackWaitThreadedDriver.h"

#define DEFAULT_MULTICAST_IP "225.3.19.154"
#define DEFAULT_PORT 19000

using namespace std;

namespace Jack


+ 11
- 8
common/JackNetInterface.cpp View File

@@ -15,15 +15,11 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

*/

#include "JackNetInterface.h"
#include "JackException.h"

#define DEFAULT_MULTICAST_IP "225.3.19.154"
#define DEFAULT_PORT 19000

using namespace std;

namespace Jack
@@ -196,7 +192,7 @@ namespace Jack
}

//timeout on receive (for init)
if ( fSocket.SetTimeOut ( 1000000 ) < 0 )
if ( fSocket.SetTimeOut ( MASTER_INIT_TIMEOUT ) < 0 )
jack_error ( "Can't set timeout : %s", StrError ( NET_ERROR_CODE ) );

//connect
@@ -222,8 +218,8 @@ namespace Jack
return false;
}
}
while ( ( GetPacketType ( &params ) != START_MASTER ) && ( ++attempt < 5 ) );
if ( attempt == 5 )
while ( ( GetPacketType ( &params ) != START_MASTER ) && ( ++attempt < SLAVE_SETUP_RETRY ) );
if ( attempt == SLAVE_SETUP_RETRY )
{
jack_error ( "Slave doesn't respond, exiting." );
return false;
@@ -415,6 +411,7 @@ namespace Jack
else
rx_bytes = Recv ( rx_head->fPacketSize, 0 );
break;
case 'n' :
//normal use of the network :
// - extra latency is set to one cycle, what is the time needed to receive streams using full network bandwidth
@@ -425,6 +422,7 @@ namespace Jack
else
rx_bytes = Recv ( rx_head->fPacketSize, 0 );
break;
case 'f' :
//fast mode suppose the network bandwith is larger than required for the transmission (only a few channels for example)
// - packets can be quickly received, quickly is here relative to the cycle duration
@@ -435,6 +433,7 @@ namespace Jack
jack_error ( "'%s' can't run in fast network mode, data received too late (%d cycle(s) offset)", fParams.fName, cycle_offset );
break;
}
fRxHeader.fIsLastPckt = rx_head->fIsLastPckt;
return rx_bytes;
}
@@ -473,6 +472,7 @@ namespace Jack
fNetMidiPlaybackBuffer->RenderToJackPorts();
jumpcnt = 0;
break;
case 'a': //audio
Recv ( rx_head->fPacketSize, 0 );
if ( !IsNextPacket() )
@@ -483,6 +483,7 @@ namespace Jack
fNetAudioPlaybackBuffer->RenderToJackPorts ( rx_head->fSubCycle );
jumpcnt = 0;
break;
case 's': //sync
if ( rx_head->fCycle == fTxHeader.fCycle )
return 0;
@@ -548,7 +549,7 @@ namespace Jack
jack_error ( "Can't bind the socket : %s", StrError ( NET_ERROR_CODE ) );

//timeout on receive
if ( fSocket.SetTimeOut ( 2000000 ) == SOCKET_ERROR )
if ( fSocket.SetTimeOut ( SLAVE_INIT_TIMEOUT ) == SOCKET_ERROR )
jack_error ( "Can't set timeout : %s", StrError ( NET_ERROR_CODE ) );

//disable local loop
@@ -708,6 +709,7 @@ namespace Jack
if ( ++recvd_midi_pckt == rx_head->fNMidiPckt )
fNetMidiCaptureBuffer->RenderToJackPorts();
break;
case 'a': //audio
rx_bytes = Recv ( rx_head->fPacketSize, 0 );
if ( !IsNextPacket() )
@@ -717,6 +719,7 @@ namespace Jack
fRxHeader.fIsLastPckt = rx_head->fIsLastPckt;
fNetAudioCaptureBuffer->RenderToJackPorts ( rx_head->fSubCycle );
break;
case 's': //sync
jack_info ( "NetSlave : overloaded, skipping receive." );
return 0;


+ 6
- 0
common/JackNetInterface.h View File

@@ -162,4 +162,10 @@ namespace Jack
};
}

#define DEFAULT_MULTICAST_IP "225.3.19.154"
#define DEFAULT_PORT 19000
#define SLAVE_SETUP_RETRY 5
#define MASTER_INIT_TIMEOUT 1000000 // in usec
#define SLAVE_INIT_TIMEOUT 2000000 // in usec

#endif

+ 0
- 4
common/JackNetManager.cpp View File

@@ -14,7 +14,6 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

*/

#if defined(HAVE_CONFIG_H)
@@ -23,9 +22,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

#include "JackNetManager.h"

#define DEFAULT_MULTICAST_IP "225.3.19.154"
#define DEFAULT_PORT 19000

using namespace std;

namespace Jack


Loading…
Cancel
Save