diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-09-27 00:50:35 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-09-27 13:46:16 +0200 |
| commit | 111c05bebe5bc2b6f0031f66e429390ffe704556 (patch) | |
| tree | e39ef0d9391ccab84d1a05582589e00a02cdd36c /src | |
| parent | 9adbb3c5ab5d90268a3009c4a6f1bbc5f6290d81 (diff) | |
Use EnumIndexedVector in Player.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/player.cc | 18 | ||||
| -rw-r--r-- | src/lib/player.h | 3 |
2 files changed, 9 insertions, 12 deletions
diff --git a/src/lib/player.cc b/src/lib/player.cc index c6803b054..7e3a1bdcf 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -760,7 +760,7 @@ Player::open_subtitles_for_frame (DCPTime time) const for ( auto j: - _active_texts[static_cast<int>(TextType::OPEN_SUBTITLE)].get_burnt(DCPTimePeriod(time, time + DCPTime::from_frames(1, vfr)), _always_burn_open_subtitles) + _active_texts[TextType::OPEN_SUBTITLE].get_burnt(DCPTimePeriod(time, time + DCPTime::from_frames(1, vfr)), _always_burn_open_subtitles) ) { /* Bitmap subtitles */ @@ -1051,7 +1051,7 @@ Player::bitmap_text_start (weak_ptr<Piece> weak_piece, weak_ptr<const TextConten } DCPTime from(content_time_to_dcp(piece, subtitle.from())); - _active_texts[static_cast<int>(content->type())].add_from(weak_content, ps, from); + _active_texts[content->type()].add_from(weak_content, ps, from); } @@ -1099,7 +1099,7 @@ Player::plain_text_start (weak_ptr<Piece> weak_piece, weak_ptr<const TextContent ps.string.push_back (s); } - _active_texts[static_cast<int>(content->type())].add_from(weak_content, ps, from); + _active_texts[content->type()].add_from(weak_content, ps, from); } @@ -1115,7 +1115,7 @@ Player::subtitle_stop (weak_ptr<Piece> weak_piece, weak_ptr<const TextContent> w return; } - if (!_active_texts[static_cast<int>(content->type())].have(weak_content)) { + if (!_active_texts[content->type()].have(weak_content)) { return; } @@ -1130,7 +1130,7 @@ Player::subtitle_stop (weak_ptr<Piece> weak_piece, weak_ptr<const TextContent> w return; } - auto from = _active_texts[static_cast<int>(content->type())].add_to(weak_content, dcp_to); + auto from = _active_texts[content->type()].add_to(weak_content, dcp_to); bool const always = (content->type() == TextType::OPEN_SUBTITLE && _always_burn_open_subtitles); if (content->use() && !always && !content->burn()) { @@ -1161,9 +1161,7 @@ Player::seek (DCPTime time, bool accurate) } _audio_merger.clear (); - for (int i = 0; i < static_cast<int>(TextType::COUNT); ++i) { - _active_texts[i].clear (); - } + std::for_each(_active_texts.begin(), _active_texts.end(), [](ActiveText& a) { a.clear(); }); for (auto i: _pieces) { if (time < i->content->position()) { @@ -1238,9 +1236,7 @@ void Player::do_emit_video (shared_ptr<PlayerVideo> pv, DCPTime time) { if (pv->eyes() == Eyes::BOTH || pv->eyes() == Eyes::RIGHT) { - for (int i = 0; i < static_cast<int>(TextType::COUNT); ++i) { - _active_texts[i].clear_before (time); - } + std::for_each(_active_texts.begin(), _active_texts.end(), [time](ActiveText& a) { a.clear_before(time); }); } auto subtitles = open_subtitles_for_frame (time); diff --git a/src/lib/player.h b/src/lib/player.h index 22701cb2c..b6ee4e9c6 100644 --- a/src/lib/player.h +++ b/src/lib/player.h @@ -32,6 +32,7 @@ #include "content_text.h" #include "content_video.h" #include "empty.h" +#include "enum_indexed_vector.h" #include "film.h" #include "image.h" #include "player_text.h" @@ -224,7 +225,7 @@ private: Empty _black; Empty _silent; - ActiveText _active_texts[static_cast<int>(TextType::COUNT)]; + EnumIndexedVector<ActiveText, TextType> _active_texts; std::shared_ptr<AudioProcessor> _audio_processor; boost::atomic<dcpomatic::DCPTime> _playback_length; |
