#include "film.h"
#include "decoder.h"
+#include "decoded.h"
#include "i18n.h"
}
+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> ();
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
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 */
} 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) {
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;
wait_for_jobs ();
FFmpegDecoder decoder (film, content, true, false);
- shared_ptr<Decoded> a = decoder.get ();
+ shared_ptr<Decoded> a = decoder.peek ();
cout << a->content_time << "\n";
decoder.seek (0, true);
- shared_ptr<Decoded> b = decoder.get ();
+ shared_ptr<Decoded> b = decoder.peek ();
cout << b->content_time << "\n";
/* a will be after no seek, and b after a seek to zero, which should