X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Flib%2Fdecoder.cc;h=52e8c04e6984f26d389d74ec61189fa80f749a69;hp=0f2bc4358008e62123e8e042a8247c142e317c71;hb=HEAD;hpb=0e8a1ab7c41756115f44229053e1e7024530fb32 diff --git a/src/lib/decoder.cc b/src/lib/decoder.cc index 0f2bc4358..5d1915128 100644 --- a/src/lib/decoder.cc +++ b/src/lib/decoder.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2018 Carl Hetherington + Copyright (C) 2012-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "decoder.h" #include "video_decoder.h" #include "audio_decoder.h" @@ -25,24 +26,27 @@ #include #include + using std::cout; using boost::optional; -using boost::shared_ptr; -using boost::weak_ptr; +using std::shared_ptr; +using std::weak_ptr; using namespace dcpomatic; + Decoder::Decoder (weak_ptr film) - : _film (film) + : WeakConstFilm (film) { } + /** @return Earliest time of content that the next pass() will emit */ ContentTime Decoder::position () const { optional pos; - shared_ptr f = film(); + auto f = film(); if (video && !video->ignore() && (!pos || video->position(f).get_value_or(ContentTime()) < *pos)) { pos = video->position(f); @@ -60,7 +64,7 @@ Decoder::position () const which can cause bugs like #1581. */ if (!pos) { - BOOST_FOREACH (shared_ptr i, text) { + for (auto i: text) { if (!i->ignore() && (!pos || i->position(f) < *pos)) { pos = i->position(f); } @@ -70,6 +74,7 @@ Decoder::position () const return pos.get_value_or(ContentTime()); } + void Decoder::seek (ContentTime, bool) { @@ -79,25 +84,18 @@ Decoder::seek (ContentTime, bool) if (audio) { audio->seek (); } - BOOST_FOREACH (shared_ptr i, text) { + for (auto i: text) { i->seek (); } } + shared_ptr Decoder::only_text () const { DCPOMATIC_ASSERT (text.size() < 2); - if (text.empty ()) { - return shared_ptr (); + if (text.empty()) { + return {}; } - return text.front (); -} - -shared_ptr -Decoder::film () const -{ - shared_ptr f = _film.lock (); - DCPOMATIC_ASSERT (f); - return f; + return text.front(); }