diff --git a/raveloxmidi/configure.ac b/raveloxmidi/configure.ac index 3893a43..11d12bb 100755 --- a/raveloxmidi/configure.ac +++ b/raveloxmidi/configure.ac @@ -1,4 +1,4 @@ -m4_define([VERSION_NUMBER],[0.9.0-rc5]) +m4_define([VERSION_NUMBER],[0.9.0-rc6]) m4_define([BUILD_NUMBER],m4_esyscmd_s(pkgscripts/build_number)) m4_define([FULL_VERSION], [VERSION_NUMBER.BUILD_NUMBER]) AC_INIT([raveloxmidi],[FULL_VERSION]) diff --git a/raveloxmidi/include/midi_payload.h b/raveloxmidi/include/midi_payload.h index 0e552f0..1498d1c 100644 --- a/raveloxmidi/include/midi_payload.h +++ b/raveloxmidi/include/midi_payload.h @@ -64,6 +64,5 @@ void midi_payload_set_buffer( midi_payload_t *payload, unsigned char *buffer , s void midi_payload_header_dump( midi_payload_header_t *header ); void midi_payload_pack( midi_payload_t *payload, unsigned char **buffer, size_t *buffer_size); void midi_payload_unpack( midi_payload_t **payload, unsigned char *buffer, size_t buffer_size); -void midi_payload_to_commands( midi_payload_t *payload, midi_payload_data_t data_type, data_table_t **table ); void midi_command_to_payload( midi_command_t *command, midi_payload_t **payload ); #endif diff --git a/raveloxmidi/src/midi_payload.c b/raveloxmidi/src/midi_payload.c index 93e1675..45d6381 100644 --- a/raveloxmidi/src/midi_payload.c +++ b/raveloxmidi/src/midi_payload.c @@ -316,202 +316,6 @@ void midi_payload_unpack( midi_payload_t **payload, unsigned char *buffer, size_ return; } -void midi_payload_to_commands( midi_payload_t *payload, midi_payload_data_t data_type, data_table_t **table ) -{ - unsigned char *p; - size_t current_len; - uint64_t current_delta = 0; - unsigned char data_byte; - char *command_description; - enum midi_message_type_t message_type; - size_t index, sysex_len; - unsigned char *sysex_start_byte = NULL; - midi_command_t *command = NULL; - - - if( ! payload ) return; - - if( ! payload->header ) return; - if( ! payload->buffer ) return; - - *table = data_table_create("midi_commands", midi_command_destroy, midi_command_dump); - if( ! *table ) return; - - p = payload->buffer; - current_len = payload->header->len; - - logging_printf( LOGGING_DEBUG, "midi_payload_to_commands: payload->header->len=%zu\n", payload->header->len); - hex_dump( p, current_len ); - - do - { - logging_printf( LOGGING_DEBUG, "midi_payload_to_commands: current_len=%zu\n", current_len ); - current_delta = 0; - if( data_type == MIDI_PAYLOAD_RTP ) - { - /* If the Z flag == 0 then no delta time is present for the first midi command */ - if( ( payload->header->Z == 0 ) && ( data_table_item_count(*table)== 0 ) ) - { - /*Do nothing*/ - } else { - // Get the delta - do - { - data_byte = *p; - current_delta <<= 8; - current_delta += ( data_byte & 0x7f ); - p++; - current_len--; - } while ( ( data_byte & 0x80 ) && current_len > 0 ); - } - } - - logging_printf( LOGGING_DEBUG, "midi_payload_to_commands: next byte = 0x%02x\n", *p ); - - command = midi_command_create(); - command->delta = current_delta; - command->data_len = 0; - command->data = NULL; - - // Get the status byte. If bit 7 is not set, use the running status - if( current_len > 0 ) - { - data_byte = *p; - - if( data_byte & 0x80 ) - { - running_status = data_byte; - p++; - current_len--; - } - command->status = running_status; - } - - midi_command_map( command , &command_description, &message_type ); - midi_command_dump( command ); - - switch( message_type ) - { - case MIDI_NOTE_OFF: - case MIDI_NOTE_ON: - case MIDI_POLY_PRESSURE: - case MIDI_CONTROL_CHANGE: - case MIDI_PITCH_BEND: - case MIDI_SONG_POSITION: - if( current_len >= 2 ) - { - command->data = ( unsigned char * ) malloc( 2 ); - if( command->data ) - { - memcpy( command->data, p, 2 ); - command->data_len = 2; - } - current_len -= 2; - p+=2; - } - break; - case MIDI_PROGRAM_CHANGE: - case MIDI_CHANNEL_PRESSURE: - case MIDI_TIME_CODE_QF: - case MIDI_SONG_SELECT: - if( current_len >= 1 ) - { - command->data = ( unsigned char * ) malloc( 2 ); - if( command->data ) - { - memset( command->data, 0, 2 ); - memcpy( command->data, p, 1); - command->data_len = 1; - } - current_len -= 1; - p+=1; - } - break; - case MIDI_SYSEX: - case MIDI_END_SYSEX: - // Read until the end of the SYSEX block - // RFC6295 sec 3.2 indicates that the following may occur - // 0xF0-0xF0 == first block of multiple SysEx segments - // 0xF7-0xF0 == middle block - // 0xF7-0xF7 == end block - // 0xF7-0xF4 == cancel ( FIXME: Need to code for this ) - sysex_start_byte = p; - sysex_len = 0; - do { - data_byte = *p; - sysex_len++; - p++; - current_len--; - } while( ( current_len > 0 ) && ( (data_byte != 0xF7 ) && (data_byte != 0xF0) && (data_byte != 0xF4) ) ); - logging_printf( LOGGING_DEBUG, "SysEx end: 0x%02X\n", data_byte); - if( ( message_type == MIDI_SYSEX ) && ( data_byte == 0xF0 ) ) - { - logging_printf(LOGGING_DEBUG, "MIDI SYSEX first block\n"); - } - if( ( message_type == MIDI_END_SYSEX ) && ( data_byte == 0xF0 ) ) - { - logging_printf(LOGGING_DEBUG, "MIDI SYSEX middle block\n"); - } - if( ( message_type == MIDI_END_SYSEX ) && ( data_byte == 0xF7 ) ) - { - logging_printf(LOGGING_DEBUG, "MIDI SYSEX last block\n"); - } - if( ( message_type == MIDI_END_SYSEX ) && ( data_byte == 0xF4 ) ) // FIXME: Need to code for this - { - logging_printf(LOGGING_DEBUG, "MIDI SYSEX cancel block\n"); - } - if( sysex_len > 0 ) - { - command->data = (unsigned char *) malloc( sysex_len ); - if( command->data ) - { - memcpy( command->data, sysex_start_byte, sysex_len ); - command->data_len = sysex_len; - } - } - break; - case MIDI_TUNE_REQUEST: - case MIDI_TIMING_CLOCK: - case MIDI_START: - case MIDI_CONTINUE: - case MIDI_STOP: - case MIDI_ACTIVE_SENSING: - case MIDI_RESET: - case MIDI_NULL: - break; - } - - switch( message_type ) - { - case MIDI_NOTE_OFF: - case MIDI_NOTE_ON: - case MIDI_POLY_PRESSURE: - case MIDI_CONTROL_CHANGE: - case MIDI_PITCH_BEND: - case MIDI_PROGRAM_CHANGE: - case MIDI_CHANNEL_PRESSURE: - logging_printf( LOGGING_INFO, "\tChannel: %u\n", command->status & 0x0f ); - break; - case MIDI_SYSEX: - case MIDI_TIME_CODE_QF: - case MIDI_SONG_POSITION: - case MIDI_SONG_SELECT: - case MIDI_TUNE_REQUEST: - case MIDI_END_SYSEX: - case MIDI_TIMING_CLOCK: - case MIDI_START: - case MIDI_CONTINUE: - case MIDI_STOP: - case MIDI_ACTIVE_SENSING: - case MIDI_RESET: - case MIDI_NULL: - break; - } - - data_table_add_item( *table, command ); - } while( current_len > 0 ); -} - void midi_command_to_payload( midi_command_t *command, midi_payload_t **payload ) { size_t new_payload_size = 0; diff --git a/raveloxmidi/src/midi_state.c b/raveloxmidi/src/midi_state.c index 06975f8..46447e6 100644 --- a/raveloxmidi/src/midi_state.c +++ b/raveloxmidi/src/midi_state.c @@ -33,14 +33,6 @@ #include "logging.h" -// Sec 3.2 of RFC6295 -// As we note above, the first channel command in the MIDI list MUST -// include a status octet. However, the corresponding command in the -//original MIDI source data stream might not have a status octet (in -// this case, the source would be coding the command using running -// status) -static unsigned char running_status = 0; - void midi_state_lock( midi_state_t *state ) { if( ! state ) return; diff --git a/raveloxmidi/src/net_connection.c b/raveloxmidi/src/net_connection.c index 57b446e..46c126c 100644 --- a/raveloxmidi/src/net_connection.c +++ b/raveloxmidi/src/net_connection.c @@ -106,7 +106,6 @@ void net_ctx_dump( void *data ) void net_ctx_dump_all( void ) { - int i = 0; DEBUG_ONLY; logging_printf( LOGGING_DEBUG, "net_ctx_dump_all: start\n"); diff --git a/raveloxmidi/src/net_socket.c b/raveloxmidi/src/net_socket.c index a5e35c7..85f1cc5 100644 --- a/raveloxmidi/src/net_socket.c +++ b/raveloxmidi/src/net_socket.c @@ -253,7 +253,6 @@ static raveloxmidi_socket_t *net_socket_create_item( void ) raveloxmidi_socket_t *net_socket_add( int new_socket_fd ) { - raveloxmidi_socket_t **new_socket_list = NULL; raveloxmidi_socket_t *new_socket_item = NULL; if( new_socket_fd < 0 ) return NULL; @@ -324,7 +323,6 @@ int net_socket_read( int fd ) ssize_t recv_len = 0; unsigned from_len = 0; struct sockaddr_storage from_addr; - int output_enabled = 0; char ip_address[ INET6_ADDRSTRLEN ]; uint16_t from_port = 0; net_applemidi_command *command; @@ -491,12 +489,20 @@ int net_socket_read( int fd ) net_socket_send_unlock(); logging_printf(LOGGING_DEBUG, "net_socket_read: Shutdown request. Response written: %u\n", bytes_written); - logging_printf(LOGGING_NORMAL, "Shutdown request received on local socket\n"); + logging_printf(LOGGING_NORMAL, "net_socket_read: Shutdown request received on local socket\n"); net_socket_set_shutdown_lock(1); ret = write( shutdown_fd[0] , "X", 1 ); + if( ret != 0 ) + { + logging_printf( LOGGING_WARN, "net_socket_read: Unable to write to internal shutdown socket 0\n"); + } ret = write( shutdown_fd[1] , "X", 1 ); + if( ret != 0 ) + { + logging_printf( LOGGING_WARN, "net_socket_read: Unable to write to internal shutdown socket 1\n"); + } midi_state_advance( found_socket->state, 4); /* @@ -504,7 +510,6 @@ int net_socket_read( int fd ) */ } else if( ( fd == local_fd ) && ( midi_state_compare( found_socket->state, "LIST", 4) == 0 ) ) { - int ret = 0; char *buffer = NULL; size_t bytes_written = 0; @@ -711,7 +716,15 @@ void net_socket_loop_shutdown(int signal) logging_printf(LOGGING_INFO, "net_socket_loop_shutdown: shutdown signal received(%u)\n", signal); net_socket_set_shutdown_lock( 1 ); ret = write( shutdown_fd[0] , "X", 1 ); + if( ret != 0 ) + { + logging_printf( LOGGING_WARN, "net_socket_loop_shutdown: Unable to write to internal shutdown socket 0\n"); + } ret = write( shutdown_fd[1] , "X", 1 ); + if( ret != 0 ) + { + logging_printf( LOGGING_WARN, "net_socket_loop_shutdown: Unable to write to internal shutdown socket 1\n"); + } close( shutdown_fd[0] ); close( shutdown_fd[1] ); } diff --git a/raveloxmidi/src/raveloxmidi_alsa.c b/raveloxmidi/src/raveloxmidi_alsa.c index 9eca6af..23623ef 100644 --- a/raveloxmidi/src/raveloxmidi_alsa.c +++ b/raveloxmidi/src/raveloxmidi_alsa.c @@ -126,8 +126,6 @@ static void raveloxmidi_alsa_add_input( const char *device_name , size_t buffer_ void raveloxmidi_alsa_init( char *input_name , char *output_name , size_t buffer_size) { - int ret = 0; - outputs = data_table_create( "ALSA outputs", raveloxmidi_alsa_handle_destroy , raveloxmidi_alsa_dump_rawmidi); if(! outputs ) { @@ -230,8 +228,6 @@ void raveloxmidi_alsa_handle_destroy( void **data ) void raveloxmidi_alsa_teardown( void ) { - int i = 0; - logging_printf(LOGGING_DEBUG,"raveloxmidi_alsa_teardown: start\n"); data_table_destroy( &inputs ); @@ -310,7 +306,6 @@ int raveloxmidi_alsa_out_available( void ) { size_t unused = 0; size_t count = 0; - int ret = 0; unused = data_table_unused_count( outputs ); count = data_table_item_count( outputs ); @@ -322,7 +317,6 @@ int raveloxmidi_alsa_in_available( void ) { size_t unused = 0; size_t count = 0; - int ret = 0; unused = data_table_unused_count( inputs ); count = data_table_item_count( inputs ); @@ -398,7 +392,6 @@ int raveloxmidi_alsa_poll( int timeout ) { int err = 0; int ret = 0; - unsigned short int revents = 0; int i = 0; int shutdown_fd = 0; diff --git a/raveloxmidi/src/ring_buffer.c b/raveloxmidi/src/ring_buffer.c index 34f5578..b76847b 100644 --- a/raveloxmidi/src/ring_buffer.c +++ b/raveloxmidi/src/ring_buffer.c @@ -147,7 +147,6 @@ void ring_buffer_destroy( ring_buffer_t **ring ) size_t ring_buffer_write( ring_buffer_t *ring, char *data, size_t len ) { size_t return_val = 0; - size_t remain = 0; if( !ring ) return 0; if( !data ) return 0; @@ -321,7 +320,6 @@ char ring_buffer_read_byte( ring_buffer_t *ring, uint8_t *return_byte, int advan int ring_buffer_resize( ring_buffer_t *ring, size_t new_size ) { - int return_status = 0; char *new_data = NULL; char *old_data = NULL; size_t bytes_used = 0;