Enforce JACK client name length restrictions.

pull/3/head
Jonathan Moore Liles 2010-01-31 13:34:18 -06:00
parent 16778d0039
commit 8d9557f88c
5 changed files with 19 additions and 4 deletions

View File

@ -398,6 +398,12 @@ Chain::can_configure_outputs ( Module *m, int n ) const
return true;
}
int
Chain::maximum_name_length ( void )
{
return JACK::Client::maximum_name_length() - strlen( APP_NAME "/" );
}
/* rename chain... we have to let our modules know our name has
* changed so they can take the appropriate action (in particular the
* JACK module). */
@ -407,7 +413,6 @@ Chain::name ( const char *name )
char ename[512];
snprintf( ename, sizeof(ename), "%s/%s", APP_NAME, name );
if ( ! _engine )
{
_engine = new Engine( &Chain::process, this );

View File

@ -116,6 +116,8 @@ public:
void log_children ( void );
static int maximum_name_length ( void );
Engine *engine ( void ) const { return _engine; }
LOG_CREATE_FUNC( Chain );

View File

@ -64,5 +64,4 @@ public:
int dropped ( void ) const { return _buffers_dropped; }
void buffer_size_callback ( void ( *buffer_size_callback ) ( nframes_t, void * ), void *user_data );
};

View File

@ -238,11 +238,19 @@ void Mixer_Strip::cb_handle(Fl_Widget* o, void* v) {
((Mixer_Strip*)(v))->cb_handle(o);
}
void
Mixer_Strip::name ( const char *name ) {
char *s = strdup( name );
if ( strlen( s ) > Chain::maximum_name_length() )
{
s[Chain::maximum_name_length() - 1] = '\0';
fl_alert( "Name \"%s\" is too long, truncating to \"%s\"", name, s );
}
name_field->value( s );
label( s );
if ( _chain )

View File

@ -98,5 +98,6 @@ namespace JACK
bool zombified ( void ) const { return _zombified; }
float cpu_load ( void ) const { return jack_cpu_load( _client ); }
static int maximum_name_length ( void ) { return jack_client_name_size(); }
};
}