Make the preview respond to changes in subtitle line spacing.
authorCarl Hetherington <cth@carlh.net>
Wed, 29 Jun 2016 23:20:49 +0000 (00:20 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 1 Jul 2016 00:05:06 +0000 (01:05 +0100)
src/lib/decoder.h
src/lib/player.cc
src/lib/player.h
src/lib/subtitle_decoder.cc
src/lib/subtitle_decoder.h
src/lib/text_subtitle_decoder.cc
src/lib/text_subtitle_decoder.h

index 2a3b56c637be9f5135d1aa933369e077f7ea30a6..181fc6c2ab8869dc96f5269600f69017d362d631 100644 (file)
@@ -64,6 +64,11 @@ public:
 
        /** @return true if this decoder has already returned all its data and will give no more */
        virtual bool pass (PassReason, bool accurate) = 0;
+
+       /** Ensure that any future get() calls return data that reflect
+        *  changes in our content's settings.
+        */
+       virtual void reset () {}
 };
 
 #endif
index 0360858cb2b19a2030b7c4d514a718c14cf3ebf8..e24baf3fa0ae67eea1099bb8a58abe66fb8898af 100644 (file)
@@ -180,6 +180,19 @@ Player::playlist_content_changed (weak_ptr<Content> w, int property, bool freque
                _have_valid_pieces = false;
                Changed (frequent);
 
+       } else if (
+               property == SubtitleContentProperty::LINE_SPACING
+               ) {
+
+               /* These changes just need the pieces' decoders to be reset.
+                  It's quite possible that other changes could be handled by
+                  this branch rather than the _have_valid_pieces = false branch
+                  above.  This would make things a lot faster.
+               */
+
+               reset_pieces ();
+               Changed (frequent);
+
        } else if (
                property == ContentProperty::VIDEO_FRAME_RATE ||
                property == SubtitleContentProperty::USE ||
@@ -775,3 +788,11 @@ Player::overlaps (DCPTime from, DCPTime to, boost::function<bool (Content *)> va
 
        return overlaps;
 }
+
+void
+Player::reset_pieces ()
+{
+       BOOST_FOREACH (shared_ptr<Piece> i, _pieces) {
+               i->decoder->reset ();
+       }
+}
index 940c3f51611f3e113748709dcd038c66419a1e32..cb3403c3d5ae4c9cabe90f865d38bbe3032e5fe5 100644 (file)
@@ -79,6 +79,7 @@ private:
        friend struct player_time_calculation_test3;
 
        void setup_pieces ();
+       void reset_pieces ();
        void flush ();
        void film_changed (Film::Property);
        void playlist_changed ();
index ef9d8384be0a7b09ab6fd2772ad665fa45a5549e..63ab7c471a634a421c03930317fe1e991ab55b8b 100644 (file)
@@ -131,6 +131,12 @@ SubtitleDecoder::get_image (ContentTimePeriod period, bool starting, bool accura
 
 void
 SubtitleDecoder::seek (ContentTime, bool)
+{
+       reset ();
+}
+
+void
+SubtitleDecoder::reset ()
 {
        _decoded_text.clear ();
        _decoded_image.clear ();
index 7a8ab32ecce704c953a58f40c0ba8c5442ed4617..726e898b1dcc979366b45f3a4557a95722e1a569 100644 (file)
@@ -51,6 +51,7 @@ public:
        std::list<ContentTextSubtitle> get_text (ContentTimePeriod period, bool starting, bool accurate);
 
        void seek (ContentTime, bool);
+       void reset ();
 
        void give_image (ContentTimePeriod period, boost::shared_ptr<Image>, dcpomatic::Rect<double>);
        void give_text (ContentTimePeriod period, std::list<dcp::SubtitleString>);
@@ -61,6 +62,7 @@ public:
        }
 
 private:
+
        Decoder* _parent;
        std::list<ContentImageSubtitle> _decoded_image;
        std::list<ContentTextSubtitle> _decoded_text;
index 5216863a0e8e76a6c7e1e23df7b53ff85b51a40c..ad9c00b63da4962a0d3a3447c567f363721fc862 100644 (file)
@@ -103,3 +103,9 @@ TextSubtitleDecoder::content_time_period (sub::Subtitle s) const
                ContentTime::from_seconds (s.to.all_as_seconds())
                );
 }
+
+void
+TextSubtitleDecoder::reset ()
+{
+       subtitle->reset ();
+}
index e5535a932ad071b75d5ba0590056beabee547f5c..c79b89937f33006f682d216ff1dcfb88210bcdae 100644 (file)
@@ -34,6 +34,7 @@ public:
 protected:
        void seek (ContentTime time, bool accurate);
        bool pass (PassReason, bool accurate);
+       void reset ();
 
 private:
        std::list<ContentTimePeriod> image_subtitles_during (ContentTimePeriod, bool starting) const;