when calling Session::engine_halted() after a user-driven engine stop, make sure...
[ardour.git] / libs / ardour / readonly_control.cc
1 /*
2  * Copyright (C) 2017 Robin Gareus <robin@gareus.org>
3  * Copyright (C) 2000, 2007 Paul Davis
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18  */
19
20 #include "pbd/destructible.h"
21
22 #include "ardour/plugin.h"
23 #include "ardour/readonly_control.h"
24
25 using namespace ARDOUR;
26
27 ReadOnlyControl::ReadOnlyControl (boost::shared_ptr<Plugin> p, const ParameterDescriptor& desc, uint32_t pnum)
28                 : _plugin (boost::weak_ptr<Plugin> (p))
29                 , _desc (desc)
30                 , _parameter_num (pnum)
31 { }
32
33 double
34 ReadOnlyControl::get_parameter () const
35 {
36         boost::shared_ptr<Plugin> p = _plugin.lock();
37         if (p) {
38                 return p->get_parameter (_parameter_num);
39         }
40         return 0;
41 }
42
43 std::string
44 ReadOnlyControl::describe_parameter ()
45 {
46         boost::shared_ptr<Plugin> p = _plugin.lock();
47         if (p) {
48                 return p->describe_parameter (Evoral::Parameter (ARDOUR::PluginAutomation, 0, _parameter_num));
49         }
50         return "";
51 }