From 0d20f9da8175fdceb890085dd0c5d16e3dc698a8 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Fri, 25 Dec 2009 22:16:24 -0600 Subject: [PATCH] Mixer: Share (reuse) buffers between all chains. --- Mixer/Chain.C | 25 ++++++++++++++++++++++++- Mixer/Chain.H | 5 ++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/Mixer/Chain.C b/Mixer/Chain.C index 6216f8a..d93def3 100644 --- a/Mixer/Chain.C +++ b/Mixer/Chain.C @@ -73,6 +73,13 @@ #include + + +std::vector Chain::port; +std::list 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::iterator i = chain.begin(); + i != chain.end(); + ++i ) + { + if ( *i != this ) + (*i)->build_process_queue(); + } + engine->unlock(); parent()->redraw(); diff --git a/Mixer/Chain.H b/Mixer/Chain.H index 3713bd2..61cac36 100644 --- a/Mixer/Chain.H +++ b/Mixer/Chain.H @@ -56,9 +56,11 @@ class Chain : public Fl_Group { void build_process_queue ( void ); void add_to_process_queue ( Module *m ); + static std::vector port; + static std::list chain; + public: - std::vector 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 );