Mixer: Don't die if a plugin specified in the project can't be loaded. Requires storing plugin I/O config in project file.

This commit is contained in:
Jonathan Moore Liles 2013-03-15 17:47:38 -07:00
parent 42072343d3
commit d86cda8977
2 changed files with 62 additions and 25 deletions

View File

@ -84,6 +84,10 @@ Plugin_Module::get ( Log_Entry &e ) const
// snprintf( s, sizeof( s ), "ladspa:%lu", _idata->descriptor->UniqueID );
e.add( ":plugin_id", _idata->descriptor->UniqueID );
/* these help us display the module on systems which are missing this plugin */
e.add( ":plugin_ins", _plugin_ins );
e.add( ":plugin_outs", _plugin_outs );
Module::get( e );
}
@ -100,6 +104,14 @@ Plugin_Module::set ( Log_Entry &e )
{
load( (unsigned long) atoll ( v ) );
}
else if ( ! strcmp( s, ":plugin_ins" ) )
{
_plugin_ins = atoi( v );
}
else if ( ! strcmp( s, ":plugin_outs" ) )
{
_plugin_outs = atoi( v );
}
}
Module::set( e );
@ -175,9 +187,7 @@ Plugin_Module::init ( void )
_crosswire = false;
align( (Fl_Align)FL_ALIGN_CENTER | FL_ALIGN_INSIDE );
color( (Fl_Color)fl_color_average( FL_BLUE, FL_GREEN, 0.5f ) );
// color( FL_FOREGROUND_COLOR );
/* color( fl_color_average( FL_CYAN, FL_WHITE, 0.40 ) ); */
// color( (Fl_Color)fl_color_average( FL_MAGENTA, FL_WHITE, 0.5f ) );
int tw, th, tx, ty;
@ -257,6 +267,8 @@ Plugin_Module::configure_inputs( int n )
}
}
if ( loaded() )
{
bool b = bypass();
if ( !b )
@ -269,6 +281,7 @@ Plugin_Module::configure_inputs( int n )
if ( !b )
activate();
}
return true;
}
@ -420,10 +433,18 @@ Plugin_Module::load ( unsigned long id )
_idata->descriptor = ladspainfo->GetDescriptorByID( id );
label( _idata->descriptor->Name );
_plugin_ins = _plugin_outs = 0;
if ( ! _idata->descriptor )
{
/* unknown plugin ID */
WARNING( "Unknown plugin ID: %lu", id );
label( "----" );
return false;
}
label( _idata->descriptor->Name );
if ( _idata->descriptor )
{
if ( LADSPA_IS_INPLACE_BROKEN( _idata->descriptor->Properties ) )
@ -656,6 +677,12 @@ Plugin_Module::set_input_buffer ( int n, void *buf )
_idata->descriptor->connect_port( h, i, (LADSPA_Data*)buf );
}
bool
Plugin_Module::loaded ( void ) const
{
return _idata->descriptor;
}
void
Plugin_Module::set_output_buffer ( int n, void *buf )
{
@ -679,6 +706,9 @@ Plugin_Module::set_output_buffer ( int n, void *buf )
void
Plugin_Module::activate ( void )
{
if ( !loaded() )
return;
DMESSAGE( "Activating plugin \"%s\"", label() );
if ( !bypass() )
@ -700,6 +730,9 @@ Plugin_Module::activate ( void )
void
Plugin_Module::deactivate( void )
{
if ( !loaded() )
return;
DMESSAGE( "Deactivating plugin \"%s\"", label() );
if ( chain() )
@ -720,6 +753,8 @@ Plugin_Module::handle_port_connection_change ( void )
{
// DMESSAGE( "Connecting audio ports" );
if ( loaded() )
{
if ( _crosswire )
{
for ( int i = 0; i < plugin_ins(); ++i )
@ -733,6 +768,7 @@ Plugin_Module::handle_port_connection_change ( void )
for ( unsigned int i = 0; i < audio_output.size(); ++i )
set_output_buffer( i, audio_output[i].buffer() );
}
}

View File

@ -85,6 +85,7 @@ private:
void connect_ports ( void );
bool loaded ( void ) const;
public: