Enforce JACK client name length restrictions.

This commit is contained in:
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; 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 /* rename chain... we have to let our modules know our name has
* changed so they can take the appropriate action (in particular the * changed so they can take the appropriate action (in particular the
* JACK module). */ * JACK module). */
@ -407,7 +413,6 @@ Chain::name ( const char *name )
char ename[512]; char ename[512];
snprintf( ename, sizeof(ename), "%s/%s", APP_NAME, name ); snprintf( ename, sizeof(ename), "%s/%s", APP_NAME, name );
if ( ! _engine ) if ( ! _engine )
{ {
_engine = new Engine( &Chain::process, this ); _engine = new Engine( &Chain::process, this );

View File

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

View File

@ -64,5 +64,4 @@ public:
int dropped ( void ) const { return _buffers_dropped; } int dropped ( void ) const { return _buffers_dropped; }
void buffer_size_callback ( void ( *buffer_size_callback ) ( nframes_t, void * ), void *user_data ); 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); ((Mixer_Strip*)(v))->cb_handle(o);
} }
void void
Mixer_Strip::name ( const char *name ) { Mixer_Strip::name ( const char *name ) {
char *s = strdup( 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 ); name_field->value( s );
label( s ); label( s );
if ( _chain ) if ( _chain )

View File

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