diff --git a/Mixer/Chain.C b/Mixer/Chain.C index 1dd35e4..ab0cb27 100644 --- a/Mixer/Chain.C +++ b/Mixer/Chain.C @@ -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 ); diff --git a/Mixer/Chain.H b/Mixer/Chain.H index 1522add..80917d3 100644 --- a/Mixer/Chain.H +++ b/Mixer/Chain.H @@ -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 ); diff --git a/Mixer/Engine/Engine.H b/Mixer/Engine/Engine.H index afdb7bc..a30317c 100644 --- a/Mixer/Engine/Engine.H +++ b/Mixer/Engine/Engine.H @@ -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 ); - }; diff --git a/Mixer/Mixer_Strip.C b/Mixer/Mixer_Strip.C index 51576d2..e1903f5 100644 --- a/Mixer/Mixer_Strip.C +++ b/Mixer/Mixer_Strip.C @@ -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 ) diff --git a/nonlib/JACK/Client.H b/nonlib/JACK/Client.H index fc4f28a..06edb64 100644 --- a/nonlib/JACK/Client.H +++ b/nonlib/JACK/Client.H @@ -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(); } }; }