diff --git a/raveloxmidi/configure.ac b/raveloxmidi/configure.ac index d8add12..f15b3d8 100755 --- a/raveloxmidi/configure.ac +++ b/raveloxmidi/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([raveloxmidi],[0.7.2]) +AC_INIT([raveloxmidi],[0.7.99]) AC_CANONICAL_HOST AC_CANONICAL_BUILD AC_CANONICAL_TARGET diff --git a/raveloxmidi/include/remote_connection.h b/raveloxmidi/include/remote_connection.h index 9afd5e4..6e90dc7 100644 --- a/raveloxmidi/include/remote_connection.h +++ b/raveloxmidi/include/remote_connection.h @@ -27,4 +27,5 @@ void remote_connect_teardown( void ); void remote_connect_sync_start( void ); void remote_connect_wait_for_thread( void ); +#define DEFAULT_CONTROL_PORT 5004 #endif diff --git a/raveloxmidi/src/net_socket.c b/raveloxmidi/src/net_socket.c index 2cc9c45..904d8e5 100644 --- a/raveloxmidi/src/net_socket.c +++ b/raveloxmidi/src/net_socket.c @@ -428,6 +428,8 @@ void net_socket_loop_init() logging_printf(LOGGING_DEBUG, "net_socket_loop_init: pipe0=%d pipe1=%d\n", pipe_fd[0], pipe_fd[1]); FD_SET( pipe_fd[1], &read_fds ); } + fcntl(pipe_fd[0], F_SETFL, O_NONBLOCK); + fcntl(pipe_fd[1], F_SETFL, O_NONBLOCK); } void net_socket_loop_teardown() diff --git a/raveloxmidi/src/raveloxmidi_config.c b/raveloxmidi/src/raveloxmidi_config.c index 9a162bb..6990385 100644 --- a/raveloxmidi/src/raveloxmidi_config.c +++ b/raveloxmidi/src/raveloxmidi_config.c @@ -55,7 +55,7 @@ static void config_set_defaults( void ) config_add_item("inbound_midi","/dev/sequencer"); config_add_item("file_mode", "0640"); config_add_item("discover.timeout","5"); - config_add_item("sync.interval","60"); + config_add_item("sync.interval","10"); #ifdef HAVE_ALSA config_add_item("alsa.input_buffer_size", "4096" ); #endif @@ -254,7 +254,10 @@ long config_long_get( char *key ) int config_is_set( char *key ) { - return ( kv_find_item( config_items, key ) != NULL ); + kv_item_t *item = NULL; + + item = kv_find_item( config_items, key ); + return ( ( item != NULL ) && ( item->value != NULL ) && ( strlen(item->value) > 0 ) ); } void config_add_item(char *key, char *value ) diff --git a/raveloxmidi/src/remote_connection.c b/raveloxmidi/src/remote_connection.c index 0336c69..eb56b5c 100644 --- a/raveloxmidi/src/remote_connection.c +++ b/raveloxmidi/src/remote_connection.c @@ -67,27 +67,97 @@ void remote_connect_init( void ) net_ctx_t *ctx; int use_ipv4, use_ipv6; uint32_t initiator = 0, ssrc = 0; + char *p1 = NULL; + char *p2 = NULL; + int remote_port_number = 0; - remote_service_name = config_string_get("remote.connect"); - if( (! remote_service_name) || ( strlen( remote_service_name ) <=0 ) ) + if( ! config_is_set( "remote.connect" ) ) { - logging_printf(LOGGING_WARN, "remote_connect_init: remote.connect option is present but not set\n"); + logging_printf(LOGGING_WARN, "remote_connect_init: Called with no remote.connect value\n"); return; } + remote_service_name = (char *) strdup( config_string_get("remote.connect") ); + logging_printf(LOGGING_DEBUG, "remote_connect_init: Looking for [%s]\n", remote_service_name); - use_ipv4 = is_yes( config_string_get("service.ipv4") ) ; - use_ipv6 = is_yes( config_string_get("service.ipv6") ) ; + p1 = remote_service_name; + p2 = p1 + strlen( remote_service_name ); - if( dns_discover_services( use_ipv4, use_ipv6 ) <= 0 ) + /* Work backwards to find a colon ':' */ + /* If a ']' character is found first, we'll assume this is going to be an direct connect address */ + + while( p2 > p1 ) { - logging_printf(LOGGING_WARN, "remote_connect_init: No services available\n"); - return; + if( *p2 == ']' ) break; + if( *p2 == ':' ) break; + p2--; + } + + + + /* If no colon ':' or ']' was found, we'll assume this is a service name to be located */ + if( p2 == p1 ) + { + use_ipv4 = is_yes( config_string_get("service.ipv4") ) ; + use_ipv6 = is_yes( config_string_get("service.ipv6") ) ; + + if( dns_discover_services( use_ipv4, use_ipv6 ) <= 0 ) + { + logging_printf(LOGGING_WARN, "remote_connect_init: No services available\n"); + free( remote_service_name ); + return; + } + + found_service = dns_discover_by_name( remote_service_name ); + goto make_remote_connection; + } else { + /* If there is a colon ':', split the string to determine the port number */ + if( *p2 == ':' ) + { + *p2='\0'; + p2++; + remote_port_number = atoi( p2 ); + p2 = remote_service_name + strlen( remote_service_name ) - 1; + } + + /* If there is a ']', work forwards from the start of the string to remove the '[' */ + if ( *p2 == ']' ) + { + *p2='\0'; + while( p1 < p2 ) + { + if( *p1 == '[' ) break; + p1++; + } + + } + if( p1 == p2 ) + { + p1 = remote_service_name; + } else { + *p1='\0'; + p1++; + } + + if( remote_port_number == 0 ) + { + logging_printf( LOGGING_ERROR, "remote_connect_init: No port number specified\n"); + free( remote_service_name ); + return; + } + + logging_printf( LOGGING_DEBUG, "remote_connect_init: connect_string=>%s<\n", config_string_get("remote.connect") ); + logging_printf( LOGGING_DEBUG, "remote_connect_init: connect_address=>%s<, connect_port=%d\n", p1, remote_port_number ); + + dns_discover_add( config_string_get("remote.connect"), p1, remote_port_number ); + found_service = dns_discover_by_name( config_string_get("remote.connect") ); } + - found_service = dns_discover_by_name( remote_service_name ); +make_remote_connection: + free( remote_service_name ); if( ! found_service ) {