13
0

Fix const violation warnings in tempo.cc.

This commit is contained in:
David Robillard 2014-11-21 02:49:41 -05:00
parent 24f7eccc86
commit 01493b14cf
2 changed files with 38 additions and 4 deletions

View File

@ -359,7 +359,9 @@ class LIBARDOUR_API TempoMap : public PBD::StatefulDestructible
framecnt_t bbt_duration_at_unlocked (const Timecode::BBT_Time& when, const Timecode::BBT_Time& bbt, int dir);
const MeterSection& first_meter() const;
MeterSection& first_meter();
const TempoSection& first_tempo() const;
TempoSection& first_tempo();
void do_insert (MetricSection* section);
};

View File

@ -475,7 +475,7 @@ TempoMap::do_insert (MetricSection* section)
void
TempoMap::replace_tempo (const TempoSection& ts, const Tempo& tempo, const BBT_Time& where)
{
const TempoSection& first (first_tempo());
TempoSection& first (first_tempo());
if (ts.start() != first.start()) {
remove_tempo (ts, false);
@ -484,7 +484,7 @@ TempoMap::replace_tempo (const TempoSection& ts, const Tempo& tempo, const BBT_T
{
Glib::Threads::RWLock::WriterLock lm (lock);
/* cannot move the first tempo section */
*((Tempo*)&first) = tempo;
*static_cast<Tempo*>(&first) = tempo;
recompute_map (false);
}
}
@ -545,7 +545,7 @@ TempoMap::add_tempo (const Tempo& tempo, BBT_Time where)
void
TempoMap::replace_meter (const MeterSection& ms, const Meter& meter, const BBT_Time& where)
{
const MeterSection& first (first_meter());
MeterSection& first (first_meter());
if (ms.start() != first.start()) {
remove_meter (ms, false);
@ -554,7 +554,7 @@ TempoMap::replace_meter (const MeterSection& ms, const Meter& meter, const BBT_T
{
Glib::Threads::RWLock::WriterLock lm (lock);
/* cannot move the first meter section */
*((Meter*)&first) = meter;
*static_cast<Meter*>(&first) = meter;
recompute_map (true);
}
}
@ -681,6 +681,22 @@ TempoMap::first_meter () const
return *m;
}
MeterSection&
TempoMap::first_meter ()
{
MeterSection *m = 0;
for (Metrics::iterator i = metrics.begin(); i != metrics.end(); ++i) {
if ((m = dynamic_cast<MeterSection *> (*i)) != 0) {
return *m;
}
}
fatal << _("programming error: no tempo section in tempo map!") << endmsg;
abort(); /*NOTREACHED*/
return *m;
}
const TempoSection&
TempoMap::first_tempo () const
{
@ -697,6 +713,22 @@ TempoMap::first_tempo () const
return *t;
}
TempoSection&
TempoMap::first_tempo ()
{
TempoSection *t = 0;
for (Metrics::const_iterator i = metrics.begin(); i != metrics.end(); ++i) {
if ((t = dynamic_cast<TempoSection *> (*i)) != 0) {
return *t;
}
}
fatal << _("programming error: no tempo section in tempo map!") << endmsg;
abort(); /*NOTREACHED*/
return *t;
}
void
TempoMap::require_map_to (framepos_t pos)
{