Don't busy-wait when there's nothing to play.
[dcpomatic.git] / src / wx / simple_video_view.cc
index 63dc102001b06344e64d78a2162b2cd7621f5f43..e349b865cf03185531318a20eae95a7bda40bf29 100644 (file)
@@ -134,9 +134,9 @@ SimpleVideoView::paint ()
 }
 
 void
-SimpleVideoView::update ()
+SimpleVideoView::refresh_panel ()
 {
-       _state_timer.set ("update-view");
+       _state_timer.set ("refresh-panel");
        _panel->Refresh ();
        _panel->Update ();
        _state_timer.unset ();
@@ -159,7 +159,7 @@ SimpleVideoView::timer ()
        }
 
        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 ();
@@ -193,7 +193,7 @@ SimpleVideoView::display_next_frame (bool non_blocking)
                }
        }
 
-       display_player_video ();
+       update ();
 
        try {
                _viewer->butler()->rethrow ();
@@ -205,11 +205,11 @@ SimpleVideoView::display_next_frame (bool non_blocking)
 }
 
 void
-SimpleVideoView::display_player_video ()
+SimpleVideoView::update ()
 {
        if (!player_video().first) {
                set_image (shared_ptr<Image>());
-               update ();
+               refresh_panel ();
                return;
        }
 
@@ -252,7 +252,5 @@ SimpleVideoView::display_player_video ()
        _inter_position = player_video().first->inter_position ();
        _inter_size = player_video().first->inter_size ();
 
-       update ();
-
-       _viewer->closed_captions_dialog()->update (_viewer->time());
+       refresh_panel ();
 }