return;
}
- if (_video_view->display_next_frame(true)) {
- _idle_get = false;
- } else {
+ if (_video_view->display_next_frame(true) == VideoView::AGAIN) {
/* get() could not complete quickly so we'll try again later */
signal_manager->when_idle (boost::bind(&FilmViewer::idle_handler, this));
+ } else {
+ _idle_get = false;
}
}
}
_playing = true;
- _video_view->start ();
+ /* Calling start() below may directly result in Stopped being emitted, and if that
+ * happens we want it to come after the Started signal, so do that first.
+ */
Started (position());
+ _video_view->start ();
}
bool
/* We're going to start playing again straight away
so wait for the seek to finish.
*/
- while (!_video_view->display_next_frame(false)) {}
+ while (_video_view->display_next_frame(false) == VideoView::AGAIN) {}
}
resume ();
store_current ();
}
-bool
+
+VideoView::NextFrameResult
GLVideoView::display_next_frame (bool non_blocking)
{
- bool const r = get_next_frame (non_blocking);
+ NextFrameResult const r = get_next_frame (non_blocking);
request_one_shot ();
return r;
}
+
void
GLVideoView::request_one_shot ()
{
void start ();
void stop ();
- bool display_next_frame (bool);
+ NextFrameResult display_next_frame (bool);
bool vsync_enabled () const {
return _vsync_enabled;
* false to ask the butler to block until it has video (unless it is suspended).
* @return true on success, false if we did nothing because it would have taken too long.
*/
-bool
+VideoView::NextFrameResult
SimpleVideoView::display_next_frame (bool non_blocking)
{
- bool r = get_next_frame (non_blocking);
- if (!r) {
- if (non_blocking) {
- /* No video available; return saying we failed */
- return false;
- } else {
- /* Player was suspended; come back later */
- signal_manager->when_idle (boost::bind(&SimpleVideoView::display_next_frame, this, false));
- return false;
- }
+ NextFrameResult const r = get_next_frame (non_blocking);
+ if (r != SUCCESS) {
+ return r;
}
update ();
error_dialog (get(), e.what());
}
- return true;
+ return SUCCESS;
}
void
void update ();
void start ();
- bool display_next_frame (bool non_blocking);
+ NextFrameResult display_next_frame (bool non_blocking);
private:
void set_image (boost::shared_ptr<const Image> image) {
/** Could be called from any thread.
* @param non_blocking true to return false quickly if no video is available quickly.
- * @return false if we gave up because it would take too long, otherwise true.
+ * @return FAIL if there's no frame, AGAIN if the method should be called again, or SUCCESS
+ * if there is a frame.
*/
-bool
+VideoView::NextFrameResult
VideoView::get_next_frame (bool non_blocking)
{
if (length() == dcpomatic::DCPTime()) {
- return true;
+ return FAIL;
}
shared_ptr<Butler> butler = _viewer->butler ();
if (!butler) {
- return false;
+ return FAIL;
}
add_get ();
if (e.code == Butler::Error::DIED) {
LOG_ERROR ("Butler died with %1", e.summary());
}
- if (!pv.first && e.code == Butler::Error::AGAIN) {
- return false;
+ if (!pv.first) {
+ return e.code == Butler::Error::AGAIN ? AGAIN : FAIL;
}
_player_video = pv;
} while (
++_errored;
}
- return true;
+ return SUCCESS;
}
dcpomatic::DCPTime
virtual void start ();
/** Called when playback stops */
virtual void stop () {}
+
+ enum NextFrameResult {
+ FAIL,
+ AGAIN,
+ SUCCESS
+ };
+
/** Get the next frame and display it; used after seek */
- virtual bool display_next_frame (bool) = 0;
+ virtual NextFrameResult display_next_frame (bool) = 0;
void clear ();
bool reset_metadata (boost::shared_ptr<const Film> film, dcp::Size player_video_container_size);
}
protected:
- bool get_next_frame (bool non_blocking);
+ NextFrameResult get_next_frame (bool non_blocking);
boost::optional<int> time_until_next_frame () const;
dcpomatic::DCPTime one_video_frame () const;