Skip to content

Commit

Permalink
Resolved unused variable warnings on compilation
Browse files Browse the repository at this point in the history
Removed midi_payload_to_commands
  • Loading branch information
ravelox committed May 13, 2020
1 parent 016ca69 commit 26fb7e2
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 220 deletions.
2 changes: 1 addition & 1 deletion raveloxmidi/configure.ac
Original file line number Diff line number Diff line change
@@ -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])
Expand Down
1 change: 0 additions & 1 deletion raveloxmidi/include/midi_payload.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
196 changes: 0 additions & 196 deletions raveloxmidi/src/midi_payload.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 0 additions & 8 deletions raveloxmidi/src/midi_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion raveloxmidi/src/net_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
21 changes: 17 additions & 4 deletions raveloxmidi/src/net_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -491,20 +489,27 @@ 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);
/*
Connection list request
*/
} 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;

Expand Down Expand Up @@ -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] );
}
Expand Down
7 changes: 0 additions & 7 deletions raveloxmidi/src/raveloxmidi_alsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );
Expand All @@ -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 );
Expand Down Expand Up @@ -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;

Expand Down
2 changes: 0 additions & 2 deletions raveloxmidi/src/ring_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 26fb7e2

Please sign in to comment.