#include <sigc++/bind.h>
-#include <pbd/lockmonitor.h>
+#include <glibmm/thread.h>
#include <pbd/xml++.h>
#include <ardour/tempo.h>
#include <ardour/utils.h>
using namespace std;
using namespace ARDOUR;
+using namespace PBD;
/* _default tempo is 4/4 qtr=120 */
throw failed_constructor();
}
- if (sscanf (prop->value().c_str(), "%lu|%lu|%lu",
+ if (sscanf (prop->value().c_str(), "%" PRIu32 "|%" PRIu32 "|%" PRIu32,
&start.bars,
&start.beats,
&start.ticks) < 3) {
throw failed_constructor();
}
- if (sscanf (prop->value().c_str(), "%lu|%lu|%lu",
+ if (sscanf (prop->value().c_str(), "%" PRIu32 "|%" PRIu32 "|%" PRIu32,
&start.bars,
&start.beats,
&start.ticks) < 3) {
return 1;
}
- LockMonitor lm (lock, __LINE__, __FILE__);
+ Glib::Mutex::Lock lm (lock);
MetricSectionSorter cmp;
BBT_Time corrected (when);
bool removed = false;
{
- LockMonitor lm (lock, __LINE__, __FILE__);
+ Glib::Mutex::Lock lm (lock);
Metrics::iterator i;
for (i = metrics->begin(); i != metrics->end(); ++i) {
bool removed = false;
{
- LockMonitor lm (lock, __LINE__, __FILE__);
+ Glib::Mutex::Lock lm (lock);
Metrics::iterator i;
for (i = metrics->begin(); i != metrics->end(); ++i) {
TempoMap::add_tempo (const Tempo& tempo, BBT_Time where)
{
{
- LockMonitor lm (lock, __LINE__, __FILE__);
+ Glib::Mutex::Lock lm (lock);
/* new tempos always start on a beat */
bool replaced = false;
{
- LockMonitor lm (lock, __LINE__, __FILE__);
+ Glib::Mutex::Lock lm (lock);
Metrics::iterator i;
for (i = metrics->begin(); i != metrics->end(); ++i) {
TempoMap::add_meter (const Meter& meter, BBT_Time where)
{
{
- LockMonitor lm (lock, __LINE__, __FILE__);
+ Glib::Mutex::Lock lm (lock);
/* a new meter always starts a new bar on the first beat. so
round the start time appropriately. remember that
bool replaced = false;
{
- LockMonitor lm (lock, __LINE__, __FILE__);
+ Glib::Mutex::Lock lm (lock);
Metrics::iterator i;
for (i = metrics->begin(); i != metrics->end(); ++i) {
void
TempoMap::bbt_time (jack_nframes_t frame, BBT_Time& bbt) const
{
- LockMonitor lm (lock, __LINE__, __FILE__);
+ Glib::Mutex::Lock lm (lock);
bbt_time_unlocked (frame, bbt);
}
bbt_time(pos,when);
{
- LockMonitor lm (lock, __LINE__, __FILE__);
+ Glib::Mutex::Lock lm (lock);
frames = bbt_duration_at_unlocked (when, bbt,dir);
}
jack_nframes_t
-
TempoMap::round_to_bar (jack_nframes_t fr, int dir)
{
- LockMonitor lm (lock, __LINE__, __FILE__);
+ Glib::Mutex::Lock lm (lock);
return round_to_type (fr, dir, Bar);
}
jack_nframes_t
-
TempoMap::round_to_beat (jack_nframes_t fr, int dir)
{
- LockMonitor lm (lock, __LINE__, __FILE__);
+ Glib::Mutex::Lock lm (lock);
return round_to_type (fr, dir, Beat);
}
TempoMap::round_to_beat_subdivision (jack_nframes_t fr, int sub_num)
{
- LockMonitor lm (lock, __LINE__, __FILE__);
+ Glib::Mutex::Lock lm (lock);
TempoMap::BBTPointList::iterator i;
TempoMap::BBTPointList *more_zoomed_bbt_points;
jack_nframes_t frame_one_beats_worth;
XMLNode&
TempoMap::get_state ()
{
- LockMonitor lm (lock, __LINE__, __FILE__);
+ Glib::Mutex::Lock lm (lock);
Metrics::const_iterator i;
XMLNode *root = new XMLNode ("TempoMap");
TempoMap::set_state (const XMLNode& node)
{
{
- LockMonitor lm (lock, __LINE__, __FILE__);
+ Glib::Mutex::Lock lm (lock);
XMLNodeList nlist;
XMLNodeConstIterator niter;
in_set_state = false;
}
+
+ /* This state needs to be saved. This string will never be a part of the
+ object's history though, because the allow_save flag is false during
+ session load. This state will eventually be tagged "initial state",
+ by a call to StateManager::allow_save from Session::set_state.
+ If this state is not saved, there is no way to reach it through undo actions.
+ */
+ save_state(_("load XML data"));
+
send_state_changed (Change (0));
return 0;
Change
TempoMap::restore_state (StateManager::State& state)
{
- LockMonitor lm (lock, __LINE__, __FILE__);
+ Glib::Mutex::Lock lm (lock);
TempoMapState* tmstate = dynamic_cast<TempoMapState*> (&state);
- metrics = tmstate->metrics;
+ /* We can't just set the metrics pointer to the address of the metrics list
+ stored in the state, cause this would ruin this state for restoring in
+ the future. If they have the same address, they are the same list.
+ Thus we need to copy all the elements from the state metrics list to the
+ current metrics list.
+ */
+ metrics->clear();
+ for (Metrics::iterator i = tmstate->metrics->begin(); i != tmstate->metrics->end(); ++i) {
+ TempoSection *ts;
+ MeterSection *ms;
+
+ if ((ts = dynamic_cast<TempoSection*>(*i)) != 0) {
+ metrics->push_back (new TempoSection (*ts));
+ } else if ((ms = dynamic_cast<MeterSection*>(*i)) != 0) {
+ metrics->push_back (new MeterSection (*ms));
+ }
+ }
+
last_bbt_valid = false;
return Change (0);