Remove TextType from various places as (I believe) it can be inferred from the content.
authorCarl Hetherington <cth@carlh.net>
Thu, 23 Aug 2018 10:19:06 +0000 (11:19 +0100)
committerCarl Hetherington <cth@carlh.net>
Thu, 23 Aug 2018 10:19:06 +0000 (11:19 +0100)
src/lib/content_text.h
src/lib/player.cc
src/lib/player.h
src/lib/text_decoder.cc
src/lib/text_decoder.h

index 3ef011f61173eefed1902a3a6fd7ae521016772a..2d8910577926c38bd259b1e10a7a7c82c90f356d 100644 (file)
@@ -33,29 +33,23 @@ class Image;
 class ContentText
 {
 public:
-       explicit ContentText (ContentTime f, TextType t)
+       explicit ContentText (ContentTime f)
                : _from (f)
-               , _type (t)
        {}
 
        ContentTime from () const {
                return _from;
        }
 
-       TextType type () const {
-               return _type;
-       }
-
 private:
        ContentTime _from;
-       TextType _type;
 };
 
 class ContentBitmapText : public ContentText
 {
 public:
-       ContentBitmapText (ContentTime f, TextType type, boost::shared_ptr<Image> im, dcpomatic::Rect<double> r)
-               : ContentText (f, type)
+       ContentBitmapText (ContentTime f, boost::shared_ptr<Image> im, dcpomatic::Rect<double> r)
+               : ContentText (f)
                , sub (im, r)
        {}
 
@@ -70,8 +64,8 @@ public:
 class ContentStringText : public ContentText
 {
 public:
-       ContentStringText (ContentTime f, TextType type, std::list<dcp::SubtitleString> s)
-               : ContentText (f, type)
+       ContentStringText (ContentTime f, std::list<dcp::SubtitleString> s)
+               : ContentText (f)
                , subs (s)
        {}
 
index 5dfc4e66dee46483a578d6a620144af1b24efd9f..cf9bc2e63dd61a43c4e64a28d398917e8c4594a3 100644 (file)
@@ -199,7 +199,7 @@ Player::setup_pieces_unlocked ()
                                bind(&Player::plain_text_start, this, weak_ptr<Piece>(piece), weak_ptr<const TextContent>((*j)->content()), _1)
                                );
                        (*j)->Stop.connect (
-                               bind(&Player::subtitle_stop, this, weak_ptr<Piece>(piece), weak_ptr<const TextContent>((*j)->content()), _1, _2)
+                               bind(&Player::subtitle_stop, this, weak_ptr<Piece>(piece), weak_ptr<const TextContent>((*j)->content()), _1)
                                );
 
                        ++j;
@@ -917,7 +917,7 @@ Player::bitmap_text_start (weak_ptr<Piece> wp, weak_ptr<const TextContent> wc, C
        ps.bitmap.push_back (subtitle.sub);
        DCPTime from (content_time_to_dcp (piece, subtitle.from()));
 
-       _active_texts[subtitle.type()].add_from (wc, ps, from);
+       _active_texts[text->type()].add_from (wc, ps, from);
 }
 
 void
@@ -961,19 +961,23 @@ Player::plain_text_start (weak_ptr<Piece> wp, weak_ptr<const TextContent> wc, Co
                ps.add_fonts (text->fonts ());
        }
 
-       _active_texts[subtitle.type()].add_from (wc, ps, from);
+       _active_texts[text->type()].add_from (wc, ps, from);
 }
 
 void
-Player::subtitle_stop (weak_ptr<Piece> wp, weak_ptr<const TextContent> wc, ContentTime to, TextType type)
+Player::subtitle_stop (weak_ptr<Piece> wp, weak_ptr<const TextContent> wc, ContentTime to)
 {
-       if (!_active_texts[type].have (wc)) {
+       shared_ptr<const TextContent> text = wc.lock ();
+       if (!text) {
+               return;
+       }
+
+       if (!_active_texts[text->type()].have(wc)) {
                return;
        }
 
        shared_ptr<Piece> piece = wp.lock ();
-       shared_ptr<const TextContent> text = wc.lock ();
-       if (!piece || !text) {
+       if (!piece) {
                return;
        }
 
@@ -983,11 +987,11 @@ Player::subtitle_stop (weak_ptr<Piece> wp, weak_ptr<const TextContent> wc, Conte
                return;
        }
 
-       pair<PlayerText, DCPTime> from = _active_texts[type].add_to (wc, dcp_to);
+       pair<PlayerText, DCPTime> from = _active_texts[text->type()].add_to (wc, dcp_to);
 
-       bool const always = (type == TEXT_OPEN_SUBTITLE && _always_burn_open_subtitles);
+       bool const always = (text->type() == TEXT_OPEN_SUBTITLE && _always_burn_open_subtitles);
        if (text->use() && !always && !text->burn()) {
-               Text (from.first, type, DCPTimePeriod (from.second, dcp_to));
+               Text (from.first, text->type(), DCPTimePeriod (from.second, dcp_to));
        }
 }
 
index e17456cf2d87838861404484822c523e2f47612b..b4f41f6da0348198130fcfdaa8d806decd38f773 100644 (file)
@@ -127,7 +127,7 @@ private:
        void audio (boost::weak_ptr<Piece>, AudioStreamPtr, ContentAudio);
        void bitmap_text_start (boost::weak_ptr<Piece>, boost::weak_ptr<const TextContent>, ContentBitmapText);
        void plain_text_start (boost::weak_ptr<Piece>, boost::weak_ptr<const TextContent>, ContentStringText);
-       void subtitle_stop (boost::weak_ptr<Piece>, boost::weak_ptr<const TextContent>, ContentTime, TextType);
+       void subtitle_stop (boost::weak_ptr<Piece>, boost::weak_ptr<const TextContent>, ContentTime);
        DCPTime one_video_frame () const;
        void fill_audio (DCPTimePeriod period);
        std::pair<boost::shared_ptr<AudioBuffers>, DCPTime> discard_audio (
index 3b6a06ea1744a2a5a4b0763c251a0aff94fbba35..00d58af869f0135fa45d4d00388f02d734623453 100644 (file)
@@ -60,7 +60,7 @@ TextDecoder::TextDecoder (
 void
 TextDecoder::emit_bitmap_start (ContentTime from, shared_ptr<Image> image, dcpomatic::Rect<double> rect)
 {
-       BitmapStart (ContentBitmapText (from, _content->type(), image, rect));
+       BitmapStart (ContentBitmapText (from, image, rect));
        _position = from;
 }
 
@@ -94,7 +94,7 @@ TextDecoder::emit_plain_start (ContentTime from, list<dcp::SubtitleString> s)
                }
        }
 
-       PlainStart (ContentStringText (from, _content->type(), s));
+       PlainStart (ContentStringText (from, s));
        _position = from;
 }
 
@@ -233,7 +233,7 @@ TextDecoder::emit_plain_start (ContentTime from, sub::Subtitle const & subtitle)
 void
 TextDecoder::emit_stop (ContentTime to)
 {
-       Stop (to, _content->type());
+       Stop (to);
 }
 
 void
index 25125e701ae07d5365fbe1a444ae44f507e2311f..d8a64157e9f7f96ea48456312a6818ce34cff8f0 100644 (file)
@@ -64,7 +64,7 @@ public:
 
        boost::signals2::signal<void (ContentBitmapText)> BitmapStart;
        boost::signals2::signal<void (ContentStringText)> PlainStart;
-       boost::signals2::signal<void (ContentTime, TextType)> Stop;
+       boost::signals2::signal<void (ContentTime)> Stop;
 
 private:
        boost::shared_ptr<const TextContent> _content;