}
draw (inter_position, inter_size);
- while (time_until_next_frame() < 5) {
+ while (true) {
+ optional<int> n = time_until_next_frame();
+ if (!n || *n > 5) {
+ break;
+ }
get_next_frame (true);
add_dropped ();
}
boost::this_thread::interruption_point ();
- dcpomatic_sleep_milliseconds (time_until_next_frame());
+ dcpomatic_sleep_milliseconds (time_until_next_frame().get_value_or(0));
}
/* XXX: leaks _context, but that seems preferable to deleting it here
}
LOG_DEBUG_PLAYER("%1 -> %2; delay %3", next.seconds(), _viewer->time().seconds(), max((next.seconds() - _viewer->time().seconds()) * 1000, 1.0));
- _timer.Start (time_until_next_frame(), wxTIMER_ONE_SHOT);
+ _timer.Start (time_until_next_frame().get_value_or(0), wxTIMER_ONE_SHOT);
if (_viewer->butler()) {
_viewer->butler()->rethrow ();
#include "wx_util.h"
#include "film_viewer.h"
#include "lib/butler.h"
+#include <boost/optional.hpp>
using boost::shared_ptr;
+using boost::optional;
VideoView::VideoView (FilmViewer* viewer)
: _viewer (viewer)
return dcpomatic::DCPTime::from_frames (1, video_frame_rate());
}
-/** @return Time in ms until the next frame is due */
-int
+/** @return Time in ms until the next frame is due, or empty if nothing is due */
+optional<int>
VideoView::time_until_next_frame () const
{
if (length() == dcpomatic::DCPTime()) {
/* There's no content, so this doesn't matter */
- return 0;
+ return optional<int>();
}
dcpomatic::DCPTime const next = position() + one_video_frame();
protected:
bool get_next_frame (bool non_blocking);
- int time_until_next_frame () const;
+ boost::optional<int> time_until_next_frame () const;
dcpomatic::DCPTime one_video_frame () const;
int video_frame_rate () const {