Remove all use of nframes_t.
[ardour.git] / libs / ardour / ardour / delivery.h
1 /*
2     Copyright (C) 2006 Paul Davis
3
4     This program is free software; you can redistribute it and/or modify it
5     under the terms of the GNU General Public License as published by the Free
6     Software Foundation; either version 2 of the License, or (at your option)
7     any later version.
8
9     This program is distributed in the hope that it will be useful, but WITHOUT
10     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12     for more details.
13
14     You should have received a copy of the GNU General Public License along
15     with this program; if not, write to the Free Software Foundation, Inc.,
16     675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18
19 #ifndef __ardour_delivery_h__
20 #define __ardour_delivery_h__
21
22 #include <string>
23
24 #include "ardour/types.h"
25 #include "ardour/chan_count.h"
26 #include "ardour/io_processor.h"
27
28 namespace ARDOUR {
29
30 class BufferSet;
31 class IO;
32 class MuteMaster;
33 class Panner;
34
35 class Delivery : public IOProcessor
36 {
37 public:
38         enum Role {
39                 /* main outputs - delivers out-of-place to port buffers, and cannot be removed */
40                 Main   = 0x1,
41                 /* send - delivers to port buffers, leaves input buffers untouched */
42                 Send   = 0x2,
43                 /* insert - delivers to port buffers and receives in-place from port buffers */
44                 Insert = 0x4,
45                 /* listen - internal send used only to deliver to control/monitor bus */
46                 Listen = 0x8,
47                 /* aux - internal send used to deliver to any bus, by user request */
48                 Aux    = 0x10
49         };
50
51         static bool role_requires_output_ports (Role r) { return r == Main || r == Send || r == Insert; }
52
53         /* Delivery to an existing output */
54
55         Delivery (Session& s, boost::shared_ptr<IO> io, boost::shared_ptr<MuteMaster> mm, const std::string& name, Role);
56
57         /* Delivery to a new output owned by this object */
58
59         Delivery (Session& s, boost::shared_ptr<MuteMaster> mm, const std::string& name, Role);
60         ~Delivery ();
61
62         bool set_name (const std::string& name);
63         std::string display_name() const;
64
65         Role role() const { return _role; }
66         bool can_support_io_configuration (const ChanCount& in, ChanCount& out) const;
67         bool configure_io (ChanCount in, ChanCount out);
68
69         void run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pframes_t nframes, bool);
70
71         /* supplemental method used with MIDI */
72
73         void flush_buffers (framecnt_t nframes, framepos_t time);
74         void no_outs_cuz_we_no_monitor(bool);
75         void cycle_start (pframes_t);
76         void increment_output_offset (framecnt_t);
77         void transport_stopped (framepos_t frame);
78
79         BufferSet& output_buffers() { return *_output_buffers; }
80
81         PBD::Signal0<void> MuteChange;
82
83         static PBD::Signal1<void, pframes_t> CycleStart;
84
85         XMLNode& state (bool full);
86         int set_state (const XMLNode&, int version);
87
88         /* Panning */
89
90         static int  disable_panners (void);
91         static int  reset_panners (void);
92
93         boost::shared_ptr<Panner> panner() const { return _panner; }
94
95         void reset_panner ();
96         void defer_pan_reset ();
97         void allow_pan_reset ();
98
99         uint32_t pans_required() const { return _configured_input.n_audio(); }
100         void start_pan_touch (uint32_t which, double when);
101         void end_pan_touch (uint32_t which, bool mark, double when);
102
103   protected:
104         Role        _role;
105         BufferSet*  _output_buffers;
106         gain_t      _current_gain;
107         framecnt_t  _output_offset;
108         bool        _no_outs_cuz_we_no_monitor;
109         boost::shared_ptr<MuteMaster> _mute_master;
110         bool         no_panner_reset;
111         boost::shared_ptr<Panner> _panner;
112
113         static bool panners_legal;
114         static PBD::Signal0<int>            PannersLegal;
115
116         int panners_became_legal ();
117         PBD::ScopedConnection panner_legal_c;
118         void output_changed (IOChange, void*);
119
120         gain_t target_gain ();
121 };
122
123
124 } // namespace ARDOUR
125
126 #endif // __ardour__h__
127