#include <algorithm>
#include <stdexcept>
+#include <cmath>
#include <unistd.h>
-#include <cmath>
-
#include <glibmm/thread.h>
#include "pbd/xml++.h"
#include "evoral/types.hpp"
#include "ardour/debug.h"
#include "ardour/tempo.h"
-#include "ardour/utils.h"
#include "i18n.h"
#include <locale.h>
}
framecnt_t
-TempoMap::bbt_duration_at_unlocked (const BBT_Time& when, const BBT_Time& bbt, int dir)
+TempoMap::bbt_duration_at_unlocked (const BBT_Time& when, const BBT_Time& bbt, int /*dir*/)
{
if (bbt.bars == 0 && bbt.beats == 0 && bbt.ticks == 0) {
return 0;
{
Glib::RWLock::ReaderLock lm (lock);
Metrics::const_iterator next_tempo;
- const TempoSection* tempo;
+ const TempoSection* tempo = 0;
/* Find the starting tempo metric */
return pos;
}
-/** Subtract some (fractional) beats to a frame position, and return the result in frames */
+/** Subtract some (fractional) beats from a frame position, and return the result in frames */
framepos_t
TempoMap::framepos_minus_beats (framepos_t pos, Evoral::MusicalTime beats) const
{
while (distance) {
/* End of this section */
- framepos_t const end = ((next_tempo == metrics.end()) ? max_framepos : (*next_tempo)->frame ());
-
- /* Distance to the end in frames */
- framecnt_t const distance_to_end = end - pos;
+ framepos_t end;
+ /* Distance to `end' in frames */
+ framepos_t distance_to_end;
+
+ if (next_tempo == metrics.end ()) {
+ /* We can't do (end - pos) if end is max_framepos, as it will overflow if pos is -ve */
+ end = max_framepos;
+ distance_to_end = max_framepos;
+ } else {
+ end = (*next_tempo)->frame ();
+ distance_to_end = end - pos;
+ }
/* Amount to subtract this time */
double const sub = min (distance, distance_to_end);