Browse Source

Fix NetJack timeouts - jack_thru is now a stereo client

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@2775 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/1.90
moret 17 years ago
parent
commit
c47c2dc6d7
8 changed files with 45 additions and 44 deletions
  1. +2
    -4
      common/JackNetInterface.cpp
  2. +1
    -2
      common/JackNetManager.cpp
  3. +1
    -2
      common/JackNetTool.cpp
  4. +3
    -2
      common/JackNetUnixSocket.cpp
  5. +1
    -1
      common/JackNetUnixSocket.h
  6. +34
    -31
      example-clients/thru_client.c
  7. +2
    -1
      windows/JackNetWinSocket.cpp
  8. +1
    -1
      windows/JackNetWinSocket.h

+ 2
- 4
common/JackNetInterface.cpp View File

@@ -149,7 +149,6 @@ namespace Jack
jack_log ( "JackNetSlaveInterface::GetNetMaster()" );
//utility
session_params_t params;
int us_timeout = 2000000;
int rx_bytes = 0;
unsigned char loop = 0;

@@ -165,7 +164,7 @@ namespace Jack
jack_error ( "Can't bind the socket : %s", StrError ( NET_ERROR_CODE ) );

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

//disable local loop
@@ -389,7 +388,6 @@ namespace Jack
jack_log ( "JackNetMasterInterface::Init, ID %u.", fParams.fID );

session_params_t params;
int usec_timeout = 1000000;
uint attempt = 0;
int rx_bytes = 0;
int rx_bufsize = 0;
@@ -402,7 +400,7 @@ namespace Jack
}

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

//connect


+ 1
- 2
common/JackNetManager.cpp View File

@@ -380,7 +380,6 @@ fail:
{
jack_log ( "JackNetMasterManager::Run" );
//utility variables
int usec_timeout = 2000000;
int attempt = 0;

//data
@@ -419,7 +418,7 @@ fail:
jack_error ( "Can't set local loop : %s", StrError ( NET_ERROR_CODE ) );

//set a timeout on the multicast receive (the thread can now be cancelled)
if ( fSocket.SetTimeOut ( usec_timeout ) == SOCKET_ERROR )
if ( fSocket.SetTimeOut ( 2000000 ) == SOCKET_ERROR )
jack_error ( "Can't set timeout : %s", StrError ( NET_ERROR_CODE ) );

jack_info ( "Waiting for a slave..." );


+ 1
- 2
common/JackNetTool.cpp View File

@@ -380,8 +380,7 @@ namespace Jack
//slow mode, just try recv during two subcycle audio packets
else
time = 4000000.f * ( static_cast<float> ( params->fFramesPerPacket ) / static_cast<float> ( params->fSampleRate ) );
int usec = ( int ) time;
return socket->SetTimeOut ( usec );
return socket->SetTimeOut ( static_cast<int> ( time ) );
}

// Packet *******************************************************************************************************


+ 3
- 2
common/JackNetUnixSocket.cpp View File

@@ -62,7 +62,7 @@ namespace Jack

JackNetUnixSocket::JackNetUnixSocket ( const JackNetUnixSocket& socket )
{
fSockfd = socket.fSockfd;
fSockfd = 0;
fPort = socket.fPort;
fSendAddr = socket.fSendAddr;
fRecvAddr = socket.fRecvAddr;
@@ -82,6 +82,7 @@ namespace Jack
fSendAddr = socket.fSendAddr;
fRecvAddr = socket.fRecvAddr;
}
return *this;
}

//socket***********************************************************************************************************
@@ -218,7 +219,7 @@ namespace Jack
}

//timeout************************************************************************************************************
int JackNetUnixSocket::SetTimeOut ( int& us )
int JackNetUnixSocket::SetTimeOut ( int us )
{
//negative timeout, or exceding 10s, return
if ( ( us < 0 ) || ( us > 10000000 ) )


+ 1
- 1
common/JackNetUnixSocket.h View File

@@ -83,7 +83,7 @@ namespace Jack
int GetOption ( int level, int optname, void* optval, socklen_t* optlen );

//timeout
int SetTimeOut ( int& us );
int SetTimeOut ( int us );

//local loop
int SetLocalLoop();


+ 34
- 31
example-clients/thru_client.c View File

@@ -15,8 +15,8 @@
#endif
#include <jack/jack.h>

jack_port_t *input_port;
jack_port_t *output_port;
jack_port_t **input_ports;
jack_port_t **output_ports;
jack_client_t *client;

static void signal_handler ( int sig )
@@ -37,13 +37,14 @@ static void signal_handler ( int sig )
int
process ( jack_nframes_t nframes, void *arg )
{
int i;
jack_default_audio_sample_t *in, *out;
in = jack_port_get_buffer ( input_port, nframes );
out = jack_port_get_buffer ( output_port, nframes );
memcpy ( out, in, nframes * sizeof ( jack_default_audio_sample_t ) );
for ( i = 0; i < 2; i++ )
{
in = jack_port_get_buffer ( input_ports[i], nframes );
out = jack_port_get_buffer ( output_ports[i], nframes );
memcpy ( out, in, nframes * sizeof ( jack_default_audio_sample_t ) );
}
return 0;
}

@@ -54,12 +55,15 @@ process ( jack_nframes_t nframes, void *arg )
void
jack_shutdown ( void *arg )
{
free ( input_ports );
free ( output_ports );
exit ( 1 );
}

int
main ( int argc, char *argv[] )
{
int i;
const char **ports;
const char *client_name;
const char *server_name = NULL;
@@ -124,19 +128,22 @@ main ( int argc, char *argv[] )

jack_on_shutdown ( client, jack_shutdown, 0 );

/* create two ports */

input_port = jack_port_register ( client, "input",
JACK_DEFAULT_AUDIO_TYPE,
JackPortIsInput, 0 );
output_port = jack_port_register ( client, "output",
JACK_DEFAULT_AUDIO_TYPE,
JackPortIsOutput, 0 );
/* create two ports pairs*/
input_ports = ( jack_port_t** ) calloc ( 2, sizeof ( jack_port_t* ) );
output_ports = ( jack_port_t** ) calloc ( 2, sizeof ( jack_port_t* ) );

if ( ( input_port == NULL ) || ( output_port == NULL ) )
char port_name[16];
for ( i = 0; i < 2; i++ )
{
fprintf ( stderr, "no more JACK ports available\n" );
exit ( 1 );
sprintf ( port_name, "input_%d", i + 1 );
input_ports[i] = jack_port_register ( client, port_name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0 );
sprintf ( port_name, "output_%d", i + 1 );
output_ports[i] = jack_port_register ( client, port_name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0 );
if ( ( input_ports[i] == NULL ) || ( output_ports[i] == NULL ) )
{
fprintf ( stderr, "no more JACK ports available\n" );
exit ( 1 );
}
}

/* Tell the JACK server that we are ready to roll. Our
@@ -156,33 +163,29 @@ main ( int argc, char *argv[] )
* it.
*/

ports = jack_get_ports ( client, NULL, NULL,
JackPortIsPhysical|JackPortIsOutput );
ports = jack_get_ports ( client, NULL, NULL, JackPortIsPhysical|JackPortIsOutput );
if ( ports == NULL )
{
fprintf ( stderr, "no physical capture ports\n" );
exit ( 1 );
}

if ( jack_connect ( client, ports[0], jack_port_name ( input_port ) ) )
{
fprintf ( stderr, "cannot connect input ports\n" );
}
for ( i = 0; i < 2; i++ )
if ( jack_connect ( client, ports[i], jack_port_name ( input_ports[i] ) ) )
fprintf ( stderr, "cannot connect input ports\n" );

free ( ports );

ports = jack_get_ports ( client, NULL, NULL,
JackPortIsPhysical|JackPortIsInput );
ports = jack_get_ports ( client, NULL, NULL, JackPortIsPhysical|JackPortIsInput );
if ( ports == NULL )
{
fprintf ( stderr, "no physical playback ports\n" );
exit ( 1 );
}

if ( jack_connect ( client, jack_port_name ( output_port ), ports[0] ) )
{
fprintf ( stderr, "cannot connect output ports\n" );
}
for ( i = 0; i < 2; i++ )
if ( jack_connect ( client, jack_port_name ( output_ports[i] ), ports[i] ) )
fprintf ( stderr, "cannot connect input ports\n" );

free ( ports );



+ 2
- 1
windows/JackNetWinSocket.cpp View File

@@ -151,6 +151,7 @@ namespace Jack
fSendAddr = socket.fSendAddr;
fRecvAddr = socket.fRecvAddr;
}
return *this;
}

//socket***********************************************************************************************************
@@ -275,7 +276,7 @@ namespace Jack
}

//tiemout************************************************************************************************************
int JackNetWinSocket::SetTimeOut ( int& usec )
int JackNetWinSocket::SetTimeOut ( int usec )
{
//negative timeout, or exceeding 10s, return
if ( ( usec < 0 ) || ( usec > 10000000 ) )


+ 1
- 1
windows/JackNetWinSocket.h View File

@@ -83,7 +83,7 @@ namespace Jack
int GetOption ( int level, int optname, void* optval, SOCKLEN* optlen );

//timeout
int SetTimeOut ( int& usec );
int SetTimeOut ( int usec );

//local loop
int SetLocalLoop();


Loading…
Cancel
Save