diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-01-15 21:23:33 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-01-15 21:23:33 +0000 |
| commit | 8353a009aae1a604251c0160193c39741c2fa27c (patch) | |
| tree | 558d2b1951f2b4f05f0ab93b46d10afd0ebee929 /src/lib/decoder.cc | |
| parent | d0bca7d33b8101cd87f78d5a76b2512dea3988f8 (diff) | |
| parent | 4e5d5c7dcc6470b8dc918d03a00e30c07df60efe (diff) | |
Merge 1.0-seek and subtitle-content.
Diffstat (limited to 'src/lib/decoder.cc')
| -rw-r--r-- | src/lib/decoder.cc | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/lib/decoder.cc b/src/lib/decoder.cc index 3f4cda6eb..53a0c31e1 100644 --- a/src/lib/decoder.cc +++ b/src/lib/decoder.cc @@ -23,9 +23,11 @@ #include "film.h" #include "decoder.h" +#include "decoded.h" #include "i18n.h" +using std::cout; using boost::shared_ptr; /** @param f Film. @@ -33,6 +35,45 @@ using boost::shared_ptr; */ Decoder::Decoder (shared_ptr<const Film> f) : _film (f) + , _done (false) { } + +struct DecodedSorter +{ + bool operator() (shared_ptr<Decoded> a, shared_ptr<Decoded> b) + { + return a->dcp_time < b->dcp_time; + } +}; + +shared_ptr<Decoded> +Decoder::peek () +{ + while (!_done && _pending.empty ()) { + _done = pass (); + } + + if (_done && _pending.empty ()) { + return shared_ptr<Decoded> (); + } + + _pending.sort (DecodedSorter ()); + return _pending.front (); +} + +void +Decoder::consume () +{ + if (!_pending.empty ()) { + _pending.pop_front (); + } +} + +void +Decoder::seek (ContentTime, bool) +{ + _pending.clear (); + _done = false; +} |
