Browse Source

jackpatch: use actual jack client and port length for our arrays, not a hardcoded guess

tags/v1.6.0
Nils 3 years ago
parent
commit
ac34cc9ca2
1 changed files with 13 additions and 10 deletions
  1. +13
    -10
      src/jackpatch.c

+ 13
- 10
src/jackpatch.c View File

@@ -61,6 +61,8 @@ int nsm_is_active;


char *project_file; char *project_file;


int REAL_JACK_PORT_NAME_SIZE; //defined after jack client activated

#undef VERSION #undef VERSION
#define APP_TITLE "JACKPatch" #define APP_TITLE "JACKPatch"
#define VERSION "0.2" #define VERSION "0.2"
@@ -326,11 +328,11 @@ connect_path ( struct patch_record *pr )
{ {
int r = 0; int r = 0;


char srcport[512];
char dstport[512];
char srcport[REAL_JACK_PORT_NAME_SIZE];
char dstport[REAL_JACK_PORT_NAME_SIZE];


snprintf( srcport, 512, "%s:%s", pr->src.client, pr->src.port );
snprintf( dstport, 512, "%s:%s", pr->dst.client, pr->dst.port );
snprintf( srcport, REAL_JACK_PORT_NAME_SIZE, "%s:%s", pr->src.client, pr->src.port );
snprintf( dstport, REAL_JACK_PORT_NAME_SIZE, "%s:%s", pr->dst.client, pr->dst.port );


if ( pr->active ) if ( pr->active )
{ {
@@ -383,8 +385,8 @@ do_for_matching_patches ( const char *portname, void (*func)( struct patch_recor
{ {
struct patch_record *pr; struct patch_record *pr;


char client[512];
char port[512];
char client[REAL_JACK_PORT_NAME_SIZE]; //the length is too much. The value is client+port+1. But is guaranteed to be enouigh.
char port[REAL_JACK_PORT_NAME_SIZE];


sscanf( portname, "%[^:]:%[^\n]", client, port ); sscanf( portname, "%[^:]:%[^\n]", client, port );


@@ -446,9 +448,7 @@ void remove_known_port ( const char *port )
* Called for every new port, which includes restored-from-file ports on startup. * Called for every new port, which includes restored-from-file ports on startup.
* It will try to activate a restored connection for every single port, thus doing an attempt * It will try to activate a restored connection for every single port, thus doing an attempt
* twice: Once for the source-port and then for the destination-port. * twice: Once for the source-port and then for the destination-port.
* This can lead to false-negative error messages. See connect_path.
*
* */
*/
void void
handle_new_port ( const char *portname ) handle_new_port ( const char *portname )
{ {
@@ -483,6 +483,9 @@ static int stringsort ( const void *a, const void *b )
return strcmp(* (char * const *) a, * (char * const *) b); return strcmp(* (char * const *) a, * (char * const *) b);
} }


/**
* Save all current connections to a file.
*/
void void
snapshot ( const char *file ) snapshot ( const char *file )
{ {
@@ -572,7 +575,6 @@ die ( void )
{ {
if ( client_active ) if ( client_active )
jack_deactivate( client ); jack_deactivate( client );

printf( "[jackpatch] Closing jack client\n" ); printf( "[jackpatch] Closing jack client\n" );


jack_client_close( client ); jack_client_close( client );
@@ -646,6 +648,7 @@ maybe_activate_jack_client ( void )
{ {
jack_activate( client ); jack_activate( client );
client_active = 1; client_active = 1;
REAL_JACK_PORT_NAME_SIZE = jack_port_name_size(); //global
} }
} }




Loading…
Cancel
Save