summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-06-30 00:20:49 +0100
committerCarl Hetherington <cth@carlh.net>2016-07-01 01:05:06 +0100
commit9b7e3d7d992f64da4bc78bc99d1eb706f181b798 (patch)
tree24a9c3c9a9914e19454ca70d8e55c7f5e0746dc0 /src/lib
parent2894023433c3addfb04ba7ae0be534e251b641b9 (diff)
Make the preview respond to changes in subtitle line spacing.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/decoder.h5
-rw-r--r--src/lib/player.cc21
-rw-r--r--src/lib/player.h1
-rw-r--r--src/lib/subtitle_decoder.cc6
-rw-r--r--src/lib/subtitle_decoder.h2
-rw-r--r--src/lib/text_subtitle_decoder.cc6
-rw-r--r--src/lib/text_subtitle_decoder.h1
7 files changed, 42 insertions, 0 deletions
diff --git a/src/lib/decoder.h b/src/lib/decoder.h
index 2a3b56c63..181fc6c2a 100644
--- a/src/lib/decoder.h
+++ b/src/lib/decoder.h
@@ -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
diff --git a/src/lib/player.cc b/src/lib/player.cc
index 0360858cb..e24baf3fa 100644
--- a/src/lib/player.cc
+++ b/src/lib/player.cc
@@ -181,6 +181,19 @@ Player::playlist_content_changed (weak_ptr<Content> w, int property, bool freque
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 ||
property == SubtitleContentProperty::X_OFFSET ||
@@ -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 ();
+ }
+}
diff --git a/src/lib/player.h b/src/lib/player.h
index 940c3f516..cb3403c3d 100644
--- a/src/lib/player.h
+++ b/src/lib/player.h
@@ -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 ();
diff --git a/src/lib/subtitle_decoder.cc b/src/lib/subtitle_decoder.cc
index ef9d8384b..63ab7c471 100644
--- a/src/lib/subtitle_decoder.cc
+++ b/src/lib/subtitle_decoder.cc
@@ -132,6 +132,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 ();
}
diff --git a/src/lib/subtitle_decoder.h b/src/lib/subtitle_decoder.h
index 7a8ab32ec..726e898b1 100644
--- a/src/lib/subtitle_decoder.h
+++ b/src/lib/subtitle_decoder.h
@@ -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;
diff --git a/src/lib/text_subtitle_decoder.cc b/src/lib/text_subtitle_decoder.cc
index 5216863a0..ad9c00b63 100644
--- a/src/lib/text_subtitle_decoder.cc
+++ b/src/lib/text_subtitle_decoder.cc
@@ -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 ();
+}
diff --git a/src/lib/text_subtitle_decoder.h b/src/lib/text_subtitle_decoder.h
index e5535a932..c79b89937 100644
--- a/src/lib/text_subtitle_decoder.h
+++ b/src/lib/text_subtitle_decoder.h
@@ -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;