Make DecoderPart::_position an optional.
authorCarl Hetherington <cth@carlh.net>
Sun, 10 Nov 2019 21:51:55 +0000 (22:51 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 11 Nov 2019 13:15:44 +0000 (14:15 +0100)
src/lib/audio_decoder.cc
src/lib/audio_decoder.h
src/lib/decoder.cc
src/lib/decoder_part.h
src/lib/ffmpeg_decoder.cc
src/lib/text_decoder.h
src/lib/video_decoder.cc
src/lib/video_decoder.h

index e0fb20b7eec172dbff61ff1e68bae2f8196d4310..a5e86f22b8e352d529fa39e69149ad10cca9fec4 100644 (file)
@@ -111,7 +111,7 @@ AudioDecoder::stream_position (shared_ptr<const Film> film, AudioStreamPtr strea
        return ContentTime::from_frames (i->second, _content->resampled_frame_rate(film));
 }
 
-ContentTime
+boost::optional<ContentTime>
 AudioDecoder::position (shared_ptr<const Film> film) const
 {
        optional<ContentTime> p;
@@ -122,7 +122,7 @@ AudioDecoder::position (shared_ptr<const Film> film) const
                }
        }
 
-       return p.get_value_or(ContentTime());
+       return p;
 }
 
 void
index 32d71c0671b849d57c5a4bfa921110fca57526d0..d81a1c7c804eaef70e0444bc19c06c86c16ebcb1 100644 (file)
@@ -47,7 +47,7 @@ class AudioDecoder : public boost::enable_shared_from_this<AudioDecoder>, public
 public:
        AudioDecoder (Decoder* parent, boost::shared_ptr<const AudioContent> content, bool fast);
 
-       dcpomatic::ContentTime position (boost::shared_ptr<const Film> film) const;
+       boost::optional<dcpomatic::ContentTime> position (boost::shared_ptr<const Film> film) const;
        void emit (boost::shared_ptr<const Film> film, AudioStreamPtr stream, boost::shared_ptr<const AudioBuffers>, dcpomatic::ContentTime);
        void seek ();
        void flush ();
index 3cadcca47198c1c79c801585b425e04971146bca..0f2bc4358008e62123e8e042a8247c142e317c71 100644 (file)
@@ -44,11 +44,11 @@ Decoder::position () const
        optional<ContentTime> pos;
        shared_ptr<const Film> f = film();
 
-       if (video && !video->ignore() && (!pos || video->position(f) < *pos)) {
+       if (video && !video->ignore() && (!pos || video->position(f).get_value_or(ContentTime()) < *pos)) {
                pos = video->position(f);
        }
 
-       if (audio && !audio->ignore() && (!pos || audio->position(f) < *pos)) {
+       if (audio && !audio->ignore() && (!pos || audio->position(f).get_value_or(ContentTime()) < *pos)) {
                pos = audio->position(f);
        }
 
index 53d1a1b0827349fecc2b37dece5498be3786b837..c8e13445a96c42761e3a3fb1f5f65b6c0de3738b 100644 (file)
@@ -34,7 +34,7 @@ public:
        DecoderPart (Decoder* parent);
        virtual ~DecoderPart () {}
 
-       virtual dcpomatic::ContentTime position (boost::shared_ptr<const Film> film) const = 0;
+       virtual boost::optional<dcpomatic::ContentTime> position (boost::shared_ptr<const Film> film) const = 0;
        virtual void seek () = 0;
 
        void set_ignore (bool i) {
index 62d4d2655f59c84af57f96c8c3d25e747794a352..04aa022b20be7b46dd837294ff58c4118d37e17e 100644 (file)
@@ -126,7 +126,7 @@ FFmpegDecoder::flush ()
        if (video) {
                double const vfr = _ffmpeg_content->video_frame_rate().get();
                Frame const f = full_length.frames_round (vfr);
-               Frame v = video->position(film()).frames_round(vfr) + 1;
+               Frame v = video->position(film()).get_value_or(ContentTime()).frames_round(vfr) + 1;
                while (v < f) {
                        video->emit (film(), shared_ptr<const ImageProxy> (new RawImageProxy (_black_image)), v);
                        ++v;
index 02afeeb94251132984f24b7ae215e0734433b224..fba9b59472b74047db2d45761321582a833faf7e 100644 (file)
@@ -44,7 +44,7 @@ public:
                dcpomatic::ContentTime first
                );
 
-       dcpomatic::ContentTime position (boost::shared_ptr<const Film>) const {
+       boost::optional<dcpomatic::ContentTime> position (boost::shared_ptr<const Film>) const {
                return _position;
        }
 
@@ -68,7 +68,7 @@ public:
 
 private:
        boost::shared_ptr<const TextContent> _content;
-       dcpomatic::ContentTime _position;
+       boost::optional<dcpomatic::ContentTime> _position;
 };
 
 #endif
index 0b97e5e8771561b2bf470c78ff0901369ab75c5e..7a3a3e19b08b16220e1fd39c3deeefab47a575f4 100644 (file)
@@ -118,7 +118,7 @@ VideoDecoder::emit (shared_ptr<const Film> film, shared_ptr<const ImageProxy> im
 void
 VideoDecoder::seek ()
 {
-       _position = ContentTime();
+       _position = boost::optional<ContentTime>();
        _last_emitted_frame.reset ();
        _last_emitted_eyes.reset ();
 }
index 76a91c5255bac1c26c4aa5d25ad3f6daa61f2ddb..34ce8f288b009d1669141b9c0314543e5064e2a6 100644 (file)
@@ -51,7 +51,7 @@ public:
        friend struct ffmpeg_pts_offset_test;
        friend void ffmpeg_decoder_sequential_test_one (boost::filesystem::path file, float fps, int gaps, int video_length);
 
-       dcpomatic::ContentTime position (boost::shared_ptr<const Film>) const {
+       boost::optional<dcpomatic::ContentTime> position (boost::shared_ptr<const Film>) const {
                return _position;
        }
 
@@ -66,7 +66,7 @@ private:
        /** Frame of last thing to be emitted */
        boost::optional<Frame> _last_emitted_frame;
        boost::optional<Eyes> _last_emitted_eyes;
-       dcpomatic::ContentTime _position;
+       boost::optional<dcpomatic::ContentTime> _position;
 };
 
 #endif