#include "job.h"
#include "util.h"
#include "cross.h"
+#include "ui_signaller.h"
#include "i18n.h"
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)));
+ }
}
}
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<void()> Finished;
protected:
using boost::weak_ptr;
using boost::dynamic_pointer_cast;
+#define DEBUG_PLAYER 1
+
struct Piece
{
Piece (shared_ptr<Content> c, shared_ptr<Decoder> d)
shared_ptr<Content> content;
shared_ptr<Decoder> decoder;
};
+
+
+#ifdef DEBUG_PLAYER
+std::ostream& operator<<(std::ostream& s, Piece const & p)
+{
+ if (dynamic_pointer_cast<NullContent> (p.content)) {
+ if (dynamic_pointer_cast<SilenceDecoder> (p.decoder)) {
+ s << "\tsilence ";
+ } else {
+ s << "\tblack ";
+ }
+ } else if (dynamic_pointer_cast<FFmpegContent> (p.content)) {
+ s << "\tffmpeg ";
+ } else if (dynamic_pointer_cast<ImageMagickContent> (p.content)) {
+ s << "\timagemagick";
+ } else if (dynamic_pointer_cast<SndfileContent> (p.content)) {
+ s << "\tsndfile ";
+ }
+
+ s << " at " << p.content->start() << " until " << p.content->end();
+
+ return s;
+}
+#endif
Player::Player (shared_ptr<const Film> f, shared_ptr<const Playlist> p)
: _film (f)
} else if (audio_pos < video_pos) {
add_silent_piece (audio_pos, video_pos - audio_pos);
}
+
+#ifdef DEBUG_PLAYER
+ cout << "=== Player setup:\n";
+ for (list<shared_ptr<Piece> >::iterator i = _pieces.begin(); i != _pieces.end(); ++i) {
+ cout << *(i->get()) << "\n";
+ }
+#endif
}
void
}
/** 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 */
#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 <boost/test/unit_test.hpp>
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 ();
}
};