mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-09 07:05:43 +01:00
VCA: fix numbering scheme to allow contiguous numbers after removing the last VCA; remove unnecessary remote_control_id() method
This commit is contained in:
parent
d98e47cf54
commit
d09b466f05
2 changed files with 27 additions and 18 deletions
|
|
@ -23,6 +23,8 @@
|
|||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/enable_shared_from_this.hpp>
|
||||
|
||||
#include <glibmm/threads.h>
|
||||
|
||||
#include "pbd/controllable.h"
|
||||
#include "pbd/statefuldestructible.h"
|
||||
|
||||
|
|
@ -54,7 +56,6 @@ class LIBARDOUR_API VCA : public Stripable,
|
|||
~VCA();
|
||||
|
||||
uint32_t number () const { return _number; }
|
||||
uint32_t remote_control_id() const;
|
||||
|
||||
int init ();
|
||||
XMLNode& get_state();
|
||||
|
|
@ -93,7 +94,7 @@ class LIBARDOUR_API VCA : public Stripable,
|
|||
MonitorState monitoring_state() const;
|
||||
|
||||
static std::string default_name_template ();
|
||||
static int next_vca_number ();
|
||||
static uint32_t next_vca_number ();
|
||||
static std::string xml_node_name;
|
||||
|
||||
/* used by Session to save/restore the atomic counter */
|
||||
|
|
@ -142,7 +143,7 @@ class LIBARDOUR_API VCA : public Stripable,
|
|||
boost::shared_ptr<MonitorProcessor> monitor_control() const { return boost::shared_ptr<MonitorProcessor>(); }
|
||||
|
||||
private:
|
||||
uint32_t _number;
|
||||
uint32_t _number;
|
||||
|
||||
boost::shared_ptr<GainControl> _gain_control;
|
||||
boost::shared_ptr<SoloControl> _solo_control;
|
||||
|
|
@ -151,7 +152,8 @@ class LIBARDOUR_API VCA : public Stripable,
|
|||
// boost::shared_ptr<AutomationControl> _record_safe_control;
|
||||
boost::shared_ptr<MonitorControl> _monitor_control;
|
||||
|
||||
static gint next_number;
|
||||
static uint32_t next_number;
|
||||
static Glib::Threads::Mutex number_lock;
|
||||
|
||||
void solo_target_going_away (boost::weak_ptr<Route>);
|
||||
void mute_target_going_away (boost::weak_ptr<Route>);
|
||||
|
|
|
|||
|
|
@ -34,7 +34,8 @@ using namespace ARDOUR;
|
|||
using namespace PBD;
|
||||
using std::string;
|
||||
|
||||
gint VCA::next_number = 1;
|
||||
Glib::Threads::Mutex VCA::number_lock;
|
||||
uint32_t VCA::next_number = 1;
|
||||
string VCA::xml_node_name (X_("VCA"));
|
||||
|
||||
string
|
||||
|
|
@ -43,25 +44,28 @@ VCA::default_name_template ()
|
|||
return _("VCA %n");
|
||||
}
|
||||
|
||||
int
|
||||
uint32_t
|
||||
VCA::next_vca_number ()
|
||||
{
|
||||
/* recall that atomic_int_add() returns the value before the add. We
|
||||
* start at one, then next one will be two etc.
|
||||
*/
|
||||
return g_atomic_int_add (&next_number, 1);
|
||||
/* we could use atomic inc here, but elsewhere we need more complete
|
||||
mutex semantics, so we have to do it here also.
|
||||
*/
|
||||
Glib::Threads::Mutex::Lock lm (number_lock);
|
||||
return next_number++;
|
||||
}
|
||||
|
||||
void
|
||||
VCA::set_next_vca_number (uint32_t n)
|
||||
{
|
||||
g_atomic_int_set (&next_number, n);
|
||||
Glib::Threads::Mutex::Lock lm (number_lock);
|
||||
next_number = n;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
VCA::get_next_vca_number ()
|
||||
{
|
||||
return g_atomic_int_get (&next_number);
|
||||
Glib::Threads::Mutex::Lock lm (number_lock);
|
||||
return next_number;
|
||||
}
|
||||
|
||||
VCA::VCA (Session& s, uint32_t num, const string& name)
|
||||
|
|
@ -91,12 +95,15 @@ VCA::init ()
|
|||
VCA::~VCA ()
|
||||
{
|
||||
DEBUG_TRACE (DEBUG::Destruction, string_compose ("delete VCA %1\n", number()));
|
||||
}
|
||||
|
||||
uint32_t
|
||||
VCA::remote_control_id () const
|
||||
{
|
||||
return 9999999 + _number;
|
||||
{
|
||||
Glib::Threads::Mutex::Lock lm (number_lock);
|
||||
if (_number == next_number - 1) {
|
||||
/* this was the "last" VCA added, so rewind the next number so
|
||||
* that future VCAs get numbered as intended
|
||||
*/
|
||||
next_number--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
XMLNode&
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue