summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-07-13 13:02:29 +0100
committerCarl Hetherington <cth@carlh.net>2013-07-13 13:02:29 +0100
commit7f8f5f09cc5ded87c82d7b48ba54183527358b43 (patch)
tree73fb29a27a440d44b2928220d523f4f3decb72a6 /src
parent211efebbb2fe71556b7519aae47cc0f0eb14f7e9 (diff)
Make viewer cope with multiple video frames being emitted on a single pass.
Diffstat (limited to 'src')
-rw-r--r--src/wx/film_viewer.cc33
-rw-r--r--src/wx/film_viewer.h4
2 files changed, 26 insertions, 11 deletions
diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc
index d27386d3d..819949f1e 100644
--- a/src/wx/film_viewer.cc
+++ b/src/wx/film_viewer.cc
@@ -47,6 +47,7 @@ using std::min;
using std::max;
using std::cout;
using std::list;
+using std::make_pair;
using boost::shared_ptr;
using boost::dynamic_pointer_cast;
using boost::weak_ptr;
@@ -119,6 +120,7 @@ FilmViewer::set_film (shared_ptr<Film> f)
_film = f;
_frame.reset ();
+ _queue.clear ();
if (!_film) {
return;
@@ -126,7 +128,7 @@ FilmViewer::set_film (shared_ptr<Film> f)
_player = f->player ();
_player->disable_audio ();
- _player->Video.connect (boost::bind (&FilmViewer::process_video, this, _1, _2, _3));
+ _player->Video.connect (boost::bind (&FilmViewer::process_video, this, _1, _3));
_player->Changed.connect (boost::bind (&FilmViewer::player_changed, this));
calculate_sizes ();
@@ -264,10 +266,15 @@ FilmViewer::check_play_state ()
}
void
-FilmViewer::process_video (shared_ptr<const Image> image, bool, Time t)
+FilmViewer::process_video (shared_ptr<const Image> image, Time t)
{
+ if (_got_frame) {
+ /* This is an additional frame emitted by a single pass. Store it. */
+ _queue.push_front (make_pair (image, t));
+ return;
+ }
+
_frame = image;
-
_got_frame = true;
double const fps = _film->dcp_video_frame_rate ();
@@ -296,13 +303,19 @@ FilmViewer::fetch_next_frame ()
return;
}
- try {
- _got_frame = false;
- while (!_got_frame && !_player->pass ()) {}
- } catch (DecodeError& e) {
- _play_button->SetValue (false);
- check_play_state ();
- error_dialog (this, wxString::Format (_("Could not decode video for view (%s)"), std_to_wx(e.what()).data()));
+ _got_frame = false;
+
+ if (!_queue.empty ()) {
+ process_video (_queue.back().first, _queue.back().second);
+ _queue.pop_back ();
+ } else {
+ try {
+ while (!_got_frame && !_player->pass ()) {}
+ } catch (DecodeError& e) {
+ _play_button->SetValue (false);
+ check_play_state ();
+ error_dialog (this, wxString::Format (_("Could not decode video for view (%s)"), std_to_wx(e.what()).data()));
+ }
}
_panel->Refresh ();
diff --git a/src/wx/film_viewer.h b/src/wx/film_viewer.h
index 7587911e8..28fc4971d 100644
--- a/src/wx/film_viewer.h
+++ b/src/wx/film_viewer.h
@@ -58,7 +58,7 @@ private:
void slider_moved (wxScrollEvent &);
void play_clicked (wxCommandEvent &);
void timer (wxTimerEvent &);
- void process_video (boost::shared_ptr<const Image>, bool, Time);
+ void process_video (boost::shared_ptr<const Image>, Time);
void calculate_sizes ();
void check_play_state ();
void fetch_current_frame_again ();
@@ -88,4 +88,6 @@ private:
libdcp::Size _out_size;
/** Size of the panel that we have available */
libdcp::Size _panel_size;
+
+ std::list<std::pair<boost::shared_ptr<const Image>, Time> > _queue;
};