summaryrefslogtreecommitdiff
path: root/src/lib/dcpomatic_time.h
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-03-07 10:57:33 +0000
committerCarl Hetherington <cth@carlh.net>2014-03-07 10:57:33 +0000
commit08d62727f7f1c813cbc7041027fe4a52518623da (patch)
tree756e38e4ad5ee2bdb51690e8a6fb149909c53712 /src/lib/dcpomatic_time.h
parent09806bc8d6a48fc79d923ec1cdf6f90176bf8b6a (diff)
operator bool on Time is a really bad idea; removed it and fixed lots of bugs.
Diffstat (limited to 'src/lib/dcpomatic_time.h')
-rw-r--r--src/lib/dcpomatic_time.h23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/lib/dcpomatic_time.h b/src/lib/dcpomatic_time.h
index 05b4e1a5d..b19a94ad7 100644
--- a/src/lib/dcpomatic_time.h
+++ b/src/lib/dcpomatic_time.h
@@ -21,6 +21,7 @@
#define DCPOMATIC_TIME_H
#include <cmath>
+#include <ostream>
#include <stdint.h>
#include "frame_rate_change.h"
@@ -55,10 +56,6 @@ public:
return rint (_t * r / HZ);
}
- operator bool () const {
- return _t != 0;
- }
-
protected:
friend class dcptime_round_up_test;
@@ -109,6 +106,10 @@ public:
return *this;
}
+ ContentTime operator- () const {
+ return ContentTime (-_t);
+ }
+
ContentTime operator- (ContentTime const & o) const {
return ContentTime (_t - o._t);
}
@@ -118,6 +119,17 @@ public:
return *this;
}
+ /** Round up to the nearest sampling interval
+ * at some sampling rate.
+ * @param r Sampling rate.
+ */
+ ContentTime round_up (int r) {
+ int64_t const n = HZ / r;
+ int64_t const a = _t + n - 1;
+ return ContentTime (a - (a % n));
+ }
+
+
static ContentTime from_seconds (double s) {
return ContentTime (s * HZ);
}
@@ -128,6 +140,8 @@ public:
}
};
+std::ostream& operator<< (std::ostream& s, ContentTime t);
+
class DCPTime : public Time
{
public:
@@ -210,5 +224,6 @@ public:
};
DCPTime min (DCPTime a, DCPTime b);
+std::ostream& operator<< (std::ostream& s, DCPTime t);
#endif