Mixer: Share (reuse) buffers between all chains.

This commit is contained in:
Jonathan Moore Liles 2009-12-25 22:16:24 -06:00
parent 20530efd3d
commit 0d20f9da81
2 changed files with 28 additions and 2 deletions

View File

@ -73,6 +73,13 @@
#include <dsp.h>
std::vector <Module::Port> Chain::port;
std::list <Chain*> Chain::chain;
Chain::Chain ( int X, int Y, int W, int H, const char *L ) :
Fl_Group( X, Y, W, H, L)
{
@ -118,6 +125,13 @@ Chain::Chain ( int X, int Y, int W, int H, const char *L ) :
}
end();
chain.push_back( this );
}
Chain::~Chain ( )
{
chain.remove( this );
}
/* Fill this chain with JACK I/O, Gain, and Meter modules. */
@ -213,7 +227,7 @@ Chain::configure_ports ( void )
DMESSAGE( "required_buffers = %i", req_buffers );
if ( port.size() != req_buffers )
if ( port.size() < req_buffers )
{
for ( unsigned int i = port.size(); i--; )
delete[] (sample_t*)port[i].buffer();
@ -230,6 +244,15 @@ Chain::configure_ports ( void )
build_process_queue();
/* let the other chains know we mess with their buffers */
for ( std::list<Chain*>::iterator i = chain.begin();
i != chain.end();
++i )
{
if ( *i != this )
(*i)->build_process_queue();
}
engine->unlock();
parent()->redraw();

View File

@ -56,9 +56,11 @@ class Chain : public Fl_Group {
void build_process_queue ( void );
void add_to_process_queue ( Module *m );
static std::vector <Module::Port> port;
static std::list <Chain*> chain;
public:
std::vector <Module::Port> port;
const char *name ( void ) const { return _name; }
void name ( const char *name );
@ -67,6 +69,7 @@ public:
int required_buffers ( void );
Chain ( int X, int Y, int W, int H, const char *L = 0 );
virtual ~Chain ( );
bool can_support_input_channels ( int n );