}
-/** @param blocking true if we should block until video is available. If blocking is false
+/** @param behaviour BLOCKING if we should block until video is available. If behaviour is NON_BLOCKING
* and no video is immediately available the method will return a 0 PlayerVideo and the error AGAIN.
* @param e if non-0 this is filled with an error code (if an error occurs) or is untouched if no error occurs.
*/
pair<shared_ptr<PlayerVideo>, DCPTime>
-Butler::get_video (bool blocking, Error* e)
+Butler::get_video (Behaviour behaviour, Error* e)
{
boost::mutex::scoped_lock lm (_mutex);
}
};
- if (_video.empty() && (_finished || _died || (_suspended && !blocking))) {
+ if (_video.empty() && (_finished || _died || (_suspended && behaviour == Behaviour::NON_BLOCKING))) {
setup_error (e, Error::Code::AGAIN);
return make_pair(shared_ptr<PlayerVideo>(), DCPTime());
}
std::string summary () const;
};
- std::pair<std::shared_ptr<PlayerVideo>, dcpomatic::DCPTime> get_video (bool blocking, Error* e = 0);
+ enum class Behaviour {
+ BLOCKING,
+ NON_BLOCKING
+ };
+
+ std::pair<std::shared_ptr<PlayerVideo>, dcpomatic::DCPTime> get_video (Behaviour behaviour, Error* e = nullptr);
boost::optional<dcpomatic::DCPTime> get_audio (float* out, Frame frames);
boost::optional<TextRingBuffers::Data> get_closed_caption ();
for (int j = 0; j < gets_per_frame; ++j) {
Butler::Error e;
- auto v = _butler->get_video (true, &e);
+ auto v = _butler->get_video (Butler::Behaviour::BLOCKING, &e);
_butler->rethrow ();
if (v.first) {
auto fe = encoder->get (v.first->eyes());
do {
Butler::Error e;
- auto pv = butler->get_video (!non_blocking, &e);
+ auto pv = butler->get_video (non_blocking ? Butler::Behaviour::NON_BLOCKING : Butler::Behaviour::BLOCKING, &e);
if (e.code == Butler::Error::Code::DIED) {
LOG_ERROR ("Butler died with %1", e.summary());
}
Butler butler (film, make_shared<Player>(film, Image::Alignment::COMPACT), map, 6, bind(&PlayerVideo::force, _1, AV_PIX_FMT_RGB24), VideoRange::FULL, Image::Alignment::COMPACT, false, false);
- BOOST_CHECK (butler.get_video(true, 0).second == DCPTime());
- BOOST_CHECK (butler.get_video(true, 0).second == DCPTime::from_frames(1, 24));
- BOOST_CHECK (butler.get_video(true, 0).second == DCPTime::from_frames(2, 24));
+ BOOST_CHECK (butler.get_video(Butler::Behaviour::BLOCKING, 0).second == DCPTime());
+ BOOST_CHECK (butler.get_video(Butler::Behaviour::BLOCKING, 0).second == DCPTime::from_frames(1, 24));
+ BOOST_CHECK (butler.get_video(Butler::Behaviour::BLOCKING, 0).second == DCPTime::from_frames(2, 24));
/* XXX: check the frame contents */
float buffer[256 * 6];
auto audio_buffer = new float[2000 * 6];
while (true) {
- auto p = butler->get_video (true, 0);
+ auto p = butler->get_video (Butler::Behaviour::BLOCKING, 0);
if (!p.first) {
break;
}
for (int i = 0; i < 10; ++i) {
auto t = DCPTime::from_frames (i, 24);
butler->seek (t, true);
- auto video = butler->get_video(true, 0);
+ auto video = butler->get_video(Butler::Behaviour::BLOCKING, 0);
BOOST_CHECK_EQUAL(video.second.get(), t.get());
write_image(video.first->image(bind(PlayerVideo::force, _1, AV_PIX_FMT_RGB24), VideoRange::FULL, true), String::compose("build/test/player_seek_test_%1.png", i));
/* This 14.08 is empirically chosen (hopefully) to accept changes in rendering between the reference and a test machine
for (int i = 0; i < 10; ++i) {
auto t = DCPTime::from_seconds(5) + DCPTime::from_frames (i, 24);
butler->seek (t, true);
- auto video = butler->get_video(true, 0);
+ auto video = butler->get_video(Butler::Behaviour::BLOCKING, 0);
BOOST_CHECK_EQUAL(video.second.get(), t.get());
write_image(
video.first->image(bind(PlayerVideo::force, _1, AV_PIX_FMT_RGB24), VideoRange::FULL, true), String::compose("build/test/player_seek_test2_%1.png", i)