X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fdecoder.cc;h=114e2ebb4c509b5c52fa975a66ba1907021a1882;hb=f5bc071ddac2355da1d116404cc37f4485e97699;hp=18c5acd3551b3442eea6e8882d16f08f658f48b2;hpb=c94f29d333e1b81aabbc396920250844460d46f6;p=dcpomatic.git diff --git a/src/lib/decoder.cc b/src/lib/decoder.cc index 18c5acd35..114e2ebb4 100644 --- a/src/lib/decoder.cc +++ b/src/lib/decoder.cc @@ -1,67 +1,37 @@ /* - Copyright (C) 2012 Carl Hetherington + Copyright (C) 2012-2015 Carl Hetherington - This program is free software; you can redistribute it and/or modify + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - This program is distributed in the hope that it will be useful, + DCP-o-matic is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with DCP-o-matic. If not, see . */ -/** @file src/decoder.cc - * @brief Parent class for decoders of content. - */ - -#include "film.h" #include "decoder.h" +#include "decoder_part.h" +#include -#include "i18n.h" - -using boost::shared_ptr; - -/** @param f Film. - * @param o Decode options. - */ -Decoder::Decoder (shared_ptr f) - : _film (f) -{ - -} - -shared_ptr -Decoder::peek () -{ - while (_pending.empty () && !pass ()) {} - - if (_pending.empty ()) { - return shared_ptr (); - } +using std::cout; +using boost::optional; - return _pending.front (); -} - -shared_ptr -Decoder::get () +void +Decoder::maybe_seek (optional position, ContentTime time, bool accurate) { - shared_ptr d = peek (); - if (d) { - _pending.pop_front (); + if (position && (time >= position.get() && time < (position.get() + ContentTime::from_seconds(1)))) { + /* No need to seek: caller should just pass() */ + return; } - return d; -} - -void -Decoder::seek (ContentTime, bool) -{ - _pending.clear (); + seek (time, accurate); }