From 01791aac0b11e9f296cd31a7803e287203bd8355 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 21 Jun 2013 12:52:50 +0100 Subject: [PATCH] Fix tests. --- src/lib/job.cc | 6 +++++- src/lib/job.h | 2 +- src/lib/player.cc | 33 +++++++++++++++++++++++++++++++++ src/lib/ui_signaller.h | 5 ++++- test/test.cc | 3 +++ 5 files changed, 46 insertions(+), 3 deletions(-) diff --git a/src/lib/job.cc b/src/lib/job.cc index 4969c4099..080d1eaf6 100644 --- a/src/lib/job.cc +++ b/src/lib/job.cc @@ -27,6 +27,7 @@ #include "job.h" #include "util.h" #include "cross.h" +#include "ui_signaller.h" #include "i18n.h" @@ -170,8 +171,11 @@ Job::set_state (State s) boost::mutex::scoped_lock lm (_state_mutex); _state = s; - if (_state == FINISHED_OK || _state == FINISHED_ERROR) { + if (_state == FINISHED_OK || _state == FINISHED_ERROR || _state == FINISHED_CANCELLED) { _ran_for = elapsed_time (); + if (ui_signaller) { + ui_signaller->emit (boost::bind (boost::ref (Finished))); + } } } diff --git a/src/lib/job.h b/src/lib/job.h index 5a4775180..791a9101b 100644 --- a/src/lib/job.h +++ b/src/lib/job.h @@ -71,7 +71,7 @@ public: void descend (float); float overall_progress () const; - /** Emitted by the JobManagerView from the UI thread */ + /** Emitted from the UI thread when the job is finished */ boost::signals2::signal Finished; protected: diff --git a/src/lib/player.cc b/src/lib/player.cc index c05897c23..cd1c54d5b 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -42,6 +42,8 @@ using boost::shared_ptr; using boost::weak_ptr; using boost::dynamic_pointer_cast; +#define DEBUG_PLAYER 1 + struct Piece { Piece (shared_ptr c, shared_ptr d) @@ -52,6 +54,30 @@ struct Piece shared_ptr content; shared_ptr decoder; }; + + +#ifdef DEBUG_PLAYER +std::ostream& operator<<(std::ostream& s, Piece const & p) +{ + if (dynamic_pointer_cast (p.content)) { + if (dynamic_pointer_cast (p.decoder)) { + s << "\tsilence "; + } else { + s << "\tblack "; + } + } else if (dynamic_pointer_cast (p.content)) { + s << "\tffmpeg "; + } else if (dynamic_pointer_cast (p.content)) { + s << "\timagemagick"; + } else if (dynamic_pointer_cast (p.content)) { + s << "\tsndfile "; + } + + s << " at " << p.content->start() << " until " << p.content->end(); + + return s; +} +#endif Player::Player (shared_ptr f, shared_ptr p) : _film (f) @@ -332,6 +358,13 @@ Player::setup_pieces () } else if (audio_pos < video_pos) { add_silent_piece (audio_pos, video_pos - audio_pos); } + +#ifdef DEBUG_PLAYER + cout << "=== Player setup:\n"; + for (list >::iterator i = _pieces.begin(); i != _pieces.end(); ++i) { + cout << *(i->get()) << "\n"; + } +#endif } void diff --git a/src/lib/ui_signaller.h b/src/lib/ui_signaller.h index 428ab698f..73db8bff8 100644 --- a/src/lib/ui_signaller.h +++ b/src/lib/ui_signaller.h @@ -60,7 +60,10 @@ public: } /** This should wake the UI and make it call ui_idle() */ - virtual void wake_ui () = 0; + virtual void wake_ui () { + /* This is only a sensible implementation when there is no GUI... */ + ui_idle (); + } private: /** A io_service which is used as the conduit for messages */ diff --git a/test/test.cc b/test/test.cc index b33c06be4..29a7fad94 100644 --- a/test/test.cc +++ b/test/test.cc @@ -41,6 +41,7 @@ #include "ffmpeg_decoder.h" #include "sndfile_decoder.h" #include "dcp_content_type.h" +#include "ui_signaller.h" #define BOOST_TEST_DYN_LINK #define BOOST_TEST_MODULE dcpomatic_test #include @@ -67,6 +68,8 @@ struct TestConfig Config::instance()->set_default_dci_metadata (DCIMetadata ()); Config::instance()->set_default_container (0); Config::instance()->set_default_dcp_content_type (0); + + ui_signaller = new UISignaller (); } }; -- 2.30.2