projects
/
dcpomatic.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix a couple more crashes with incorrect KDMs (#1000).
[dcpomatic.git]
/
src
/
lib
/
decoder.cc
diff --git
a/src/lib/decoder.cc
b/src/lib/decoder.cc
index 988b8fe9b2f9fc73a6261064e673396365f71bdf..502273de1e49f5a551110674a5d8284572dbe180 100644
(file)
--- a/
src/lib/decoder.cc
+++ b/
src/lib/decoder.cc
@@
-1,5
+1,5
@@
/*
/*
- Copyright (C) 2012-201
5
Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-201
6
Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
This file is part of DCP-o-matic.
@@
-19,24
+19,46
@@
*/
#include "decoder.h"
*/
#include "decoder.h"
+#include "video_decoder.h"
+#include "audio_decoder.h"
+#include "subtitle_decoder.h"
+#include <boost/optional.hpp>
#include <iostream>
using std::cout;
using boost::optional;
#include <iostream>
using std::cout;
using boost::optional;
-void
-Decoder::maybe_seek (optional<ContentTime>& position, ContentTime time, bool accurate)
+/** @return Earliest time of content that the next pass() will emit */
+ContentTime
+Decoder::position () const
{
{
- if (!position) {
- /* A seek has just happened */
- return;
+ optional<ContentTime> pos;
+
+ if (video && !video->ignore() && (!pos || video->position() < *pos)) {
+ pos = video->position();
+ }
+
+ if (audio && !audio->ignore() && (!pos || audio->position() < *pos)) {
+ pos = audio->position();
}
}
- if (time >= *position && time < (*position + ContentTime::from_seconds(1))) {
- /* No need to seek: caller should just pass() */
- return;
+ if (subtitle && !subtitle->ignore() && (!pos || subtitle->position() < *pos)) {
+ pos = subtitle->position();
}
}
- position.reset ();
- seek (time, accurate);
+ return pos.get_value_or(ContentTime());
+}
+
+void
+Decoder::seek (ContentTime, bool)
+{
+ if (video) {
+ video->seek ();
+ }
+ if (audio) {
+ audio->seek ();
+ }
+ if (subtitle) {
+ subtitle->seek ();
+ }
}
}