Another try at sorting out the thorny question of timing.
[dcpomatic.git] / src / wx / film_viewer.cc
index 3385aa2b39d805de3da2eac23b04f8a14b4d9f09..8ef64d509c9534907e6f22f47f8e9e4dd2537d80 100644 (file)
@@ -43,6 +43,7 @@
 
 using std::string;
 using std::pair;
+using std::min;
 using std::max;
 using std::cout;
 using std::list;
@@ -128,6 +129,7 @@ FilmViewer::film_changed (Film::Property p)
        case Film::WITH_SUBTITLES:
        case Film::SUBTITLE_OFFSET:
        case Film::SUBTITLE_SCALE:
+               update_from_decoder ();
                raw_to_display ();
                _panel->Refresh ();
                _panel->Update ();
@@ -160,10 +162,6 @@ FilmViewer::set_film (shared_ptr<Film> f)
 
        _player = f->player ();
        _player->disable_audio ();
-       /* Don't disable subtitles here as we may need them, and it's nice to be able to turn them
-          on and off without needing obtain a new Player.
-       */
-       
        _player->Video.connect (bind (&FilmViewer::process_video, this, _1, _2, _3));
        
        _film->Changed.connect (boost::bind (&FilmViewer::film_changed, this, _1));
@@ -183,7 +181,7 @@ FilmViewer::update_from_decoder ()
                return;
        }
 
-       _player->seek (_player->position() - _film->video_frames_to_time (1));
+       _player->seek (_player->video_position() - _film->video_frames_to_time (1));
        get_frame ();
        _panel->Refresh ();
        _panel->Update ();
@@ -199,7 +197,7 @@ FilmViewer::timer (wxTimerEvent &)
        get_frame ();
 
        if (_film->length()) {
-               int const new_slider_position = 4096 * _player->position() / _film->length();
+               int const new_slider_position = 4096 * _player->video_position() / _film->length();
                if (new_slider_position != _slider->GetValue()) {
                        _slider->SetValue (new_slider_position);
                }
@@ -312,11 +310,11 @@ FilmViewer::calculate_sizes ()
        }
 
        /* Catch silly values */
-       if (_out_size.width < 64) {
-               _out_size.width = 64;
-       }
+       _out_size.width = max (64, _out_size.width);
+       _out_size.height = max (64, _out_size.height);
 
        _player->set_video_container_size (_out_size);
+       update_from_decoder ();
 }
 
 void
@@ -422,7 +420,7 @@ FilmViewer::film_content_changed (weak_ptr<Content>, int p)
                /* Force an update to our frame */
                wxScrollEvent ev;
                slider_moved (ev);
-       } else if (p == VideoContentProperty::VIDEO_CROP) {
+       } else if (p == VideoContentProperty::VIDEO_CROP || p == VideoContentProperty::VIDEO_RATIO) {
                update_from_decoder ();
        }               
 }
@@ -447,7 +445,6 @@ FilmViewer::forward_clicked (wxCommandEvent &)
                return;
        }
 
-       _player->seek_forward ();
        get_frame ();
        _panel->Refresh ();
        _panel->Update ();