Give Processor::run a new parameter to say whether or not the run method must leave
[ardour.git] / libs / ardour / ardour / processor.h
1 /*
2     Copyright (C) 2000 Paul Davis
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef __ardour_processor_h__
21 #define __ardour_processor_h__
22
23 #include <vector>
24 #include <string>
25 #include <exception>
26
27 #include "pbd/statefuldestructible.h"
28
29 #include <sigc++/signal.h>
30
31 #include "ardour/ardour.h"
32 #include "ardour/automatable_controls.h"
33 #include "ardour/buffer_set.h"
34 #include "ardour/latent.h"
35 #include "ardour/session_object.h"
36 #include "ardour/types.h"
37
38 class XMLNode;
39
40 namespace ARDOUR {
41
42 class Session;
43 class Route;
44
45 /* A mixer strip element - plugin, send, meter, etc.
46  */
47 class Processor : public SessionObject, public AutomatableControls, public Latent
48 {
49   public:
50         static const std::string state_node_name;
51
52         Processor(Session&, const std::string& name);
53         Processor(Session&, const XMLNode& node);
54
55         virtual ~Processor() { }
56
57         virtual std::string display_name() const { return SessionObject::name(); }
58
59         virtual bool display_to_user() const { return _display_to_user; }
60         virtual void set_display_to_user (bool);
61
62         bool active () const { return _pending_active; }
63
64         bool get_next_ab_is_active () const { return _next_ab_is_active; }
65         void set_next_ab_is_active (bool yn) { _next_ab_is_active = yn; }
66
67         virtual nframes_t signal_latency() const { return 0; }
68
69         virtual void transport_stopped (sframes_t /*frame*/) {}
70
71         virtual void set_block_size (nframes_t /*nframes*/) {}
72
73         /** @param result_required true if, on return from this method, bufs is required to contain valid data;
74          *  if false, the method need not bother writing to bufs if it doesn't want to.
75          */  
76         virtual void run (BufferSet& /*bufs*/, sframes_t /*start_frame*/, sframes_t /*end_frame*/, nframes_t /*nframes*/, bool /*result_required*/) {}
77         virtual void silence (nframes_t /*nframes*/) {}
78
79         virtual void activate ()   { _pending_active = true; ActiveChanged(); }
80         virtual void deactivate () { _pending_active = false; ActiveChanged(); }
81
82         virtual bool configure_io (ChanCount in, ChanCount out);
83
84         /* Derived classes should override these, or processor appears as an in-place pass-through */
85
86         virtual bool can_support_io_configuration (const ChanCount& in, ChanCount& out) const = 0;
87         virtual ChanCount input_streams () const { return _configured_input; }
88         virtual ChanCount output_streams() const { return _configured_output; }
89
90         /* note: derived classes should implement state(), NOT get_state(), to allow
91            us to merge C++ inheritance and XML lack-of-inheritance reasonably
92            smoothly.
93          */
94
95         virtual XMLNode& state (bool full);
96         XMLNode& get_state (void);
97         int set_state (const XMLNode&, int version);
98         
99         void *get_gui () const { return _gui; }
100         void  set_gui (void *p) { _gui = p; }
101
102         static sigc::signal<void,Processor*> ProcessorCreated;
103
104         sigc::signal<void>                     ActiveChanged;
105         sigc::signal<void,ChanCount,ChanCount> ConfigurationChanged;
106
107 protected:
108         int       _pending_active;
109         bool      _active;
110         bool      _next_ab_is_active;
111         bool      _configured;
112         ChanCount _configured_input;
113         ChanCount _configured_output;
114         void*     _gui;  /* generic, we don't know or care what this is */
115         bool        _display_to_user;
116
117 private:
118         int set_state_2X (const XMLNode&, int version);
119 };
120
121 } // namespace ARDOUR
122
123 #endif /* __ardour_processor_h__ */