Initial work on removing storage of subtitle times.
[dcpomatic.git] / src / lib / audio_decoder.cc
index 5a33716f4fe775622e2864a7ce97192c281ed84a..3e4584a3f5a04552523344fa54ba8f1c3b0593cc 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2017 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -33,9 +33,10 @@ using std::map;
 using boost::shared_ptr;
 using boost::optional;
 
-AudioDecoder::AudioDecoder (Decoder* parent, shared_ptr<AudioContent> content, shared_ptr<Log> log)
+AudioDecoder::AudioDecoder (Decoder* parent, shared_ptr<const AudioContent> content, shared_ptr<Log> log)
        : DecoderPart (parent, log)
 {
+       /* Set up _positions so that we have one for each stream */
        BOOST_FOREACH (AudioStreamPtr i, content->streams ()) {
                _positions[i] = 0;
        }
@@ -49,6 +50,11 @@ AudioDecoder::emit (AudioStreamPtr stream, shared_ptr<const AudioBuffers> data,
        }
 
        if (_positions[stream] == 0) {
+               /* This is the first data we have received since initialisation or seek.  Set
+                  the position based on the ContentTime that was given.  After this first time
+                  we just count samples, as it seems that ContentTimes are unreliable from
+                  FFmpegDecoder (not quite continuous; perhaps due to some rounding error).
+               */
                _positions[stream] = time.frames_round (stream->frame_rate ());
        }