diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-12-24 02:52:35 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-12-24 02:52:35 +0000 |
| commit | 64dc289b343641fc37db51fcd6b3069078cb5edf (patch) | |
| tree | ecdee5041e771892b34a7acd13cc8a79381b8142 /src/lib | |
| parent | dc87445987c00b85a44b6372e43894067fae44b3 (diff) | |
Some fixes to playback of drop-frame content.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/decoder.cc | 21 | ||||
| -rw-r--r-- | src/lib/decoder.h | 2 | ||||
| -rw-r--r-- | src/lib/player.cc | 10 |
3 files changed, 20 insertions, 13 deletions
diff --git a/src/lib/decoder.cc b/src/lib/decoder.cc index 18c5acd35..7f4973737 100644 --- a/src/lib/decoder.cc +++ b/src/lib/decoder.cc @@ -23,6 +23,7 @@ #include "film.h" #include "decoder.h" +#include "decoded.h" #include "i18n.h" @@ -37,10 +38,19 @@ Decoder::Decoder (shared_ptr<const Film> f) } +class DecodedSorter +{ +public: + bool operator() (shared_ptr<Decoded> a, shared_ptr<Decoded> b) + { + return a->dcp_time < b->dcp_time; + } +}; + shared_ptr<Decoded> Decoder::peek () { - while (_pending.empty () && !pass ()) {} + while (_pending.empty() && !pass ()) {} if (_pending.empty ()) { return shared_ptr<Decoded> (); @@ -49,15 +59,12 @@ Decoder::peek () return _pending.front (); } -shared_ptr<Decoded> -Decoder::get () +void +Decoder::consume () { - shared_ptr<Decoded> d = peek (); - if (d) { + if (!_pending.empty ()) { _pending.pop_front (); } - - return d; } void diff --git a/src/lib/decoder.h b/src/lib/decoder.h index 654cacad4..1c6aff359 100644 --- a/src/lib/decoder.h +++ b/src/lib/decoder.h @@ -49,7 +49,7 @@ public: virtual void seek (ContentTime time, bool accurate); boost::shared_ptr<Decoded> peek (); - boost::shared_ptr<Decoded> get (); + void consume (); protected: diff --git a/src/lib/player.cc b/src/lib/player.cc index 0f2cc0365..3e282136f 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -147,7 +147,7 @@ Player::pass () if (_just_did_inaccurate_seek) { /* Just emit; no subtlety */ emit_video (earliest_piece, dv); - earliest_piece->decoder->get (); + earliest_piece->decoder->consume (); } else if (earliest_time > (_video_position + half_frame)) { /* See if we're inside some video content */ @@ -167,14 +167,14 @@ Player::pass () } else { if ( - dv->dcp_time >= _video_position && + abs (dv->dcp_time - _video_position) < half_frame && !earliest_piece->content->trimmed (dv->dcp_time - earliest_piece->content->position ()) ) { emit_video (earliest_piece, dv); } - earliest_piece->decoder->get (); + earliest_piece->decoder->consume (); } } else if (da && _audio) { @@ -182,13 +182,13 @@ Player::pass () emit_silence (earliest_time - _audio_position); } else { emit_audio (earliest_piece, da); - earliest_piece->decoder->get (); + earliest_piece->decoder->consume (); } } else if (ds && _video) { _in_subtitle.piece = earliest_piece; _in_subtitle.subtitle = ds; update_subtitle (); - earliest_piece->decoder->get (); + earliest_piece->decoder->consume (); } _just_did_inaccurate_seek = false; |
