diff options
| author | Carl Hetherington <cth@carlh.net> | 2018-07-25 23:50:30 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2018-07-25 23:50:30 +0100 |
| commit | c380909d3dcac0809dbeedc6240c33d37118296d (patch) | |
| tree | e2cfb6ef93628c210837bad44ad82f76d6ad0079 /src | |
| parent | c252bea0407deedad31c67ab7dd5de4890cafd53 (diff) | |
Add believed-necessary locking to ActiveText.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/active_text.cc | 13 | ||||
| -rw-r--r-- | src/lib/active_text.h | 2 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/lib/active_text.cc b/src/lib/active_text.cc index de3dc8165..6e813144c 100644 --- a/src/lib/active_text.cc +++ b/src/lib/active_text.cc @@ -45,6 +45,8 @@ ActiveText::add (DCPTimePeriod period, list<PlayerText>& pc, list<Period> p) con list<PlayerText> ActiveText::get (DCPTimePeriod period) const { + boost::mutex::scoped_lock lm (_mutex); + list<PlayerText> ps; for (Map::const_iterator i = _data.begin(); i != _data.end(); ++i) { @@ -67,6 +69,8 @@ ActiveText::get (DCPTimePeriod period) const list<PlayerText> ActiveText::get_burnt (DCPTimePeriod period, bool always_burn_captions) const { + boost::mutex::scoped_lock lm (_mutex); + list<PlayerText> ps; for (Map::const_iterator i = _data.begin(); i != _data.end(); ++i) { @@ -93,6 +97,8 @@ ActiveText::get_burnt (DCPTimePeriod period, bool always_burn_captions) const void ActiveText::clear_before (DCPTime time) { + boost::mutex::scoped_lock lm (_mutex); + Map updated; for (Map::const_iterator i = _data.begin(); i != _data.end(); ++i) { list<Period> as; @@ -116,6 +122,8 @@ ActiveText::clear_before (DCPTime time) void ActiveText::add_from (weak_ptr<const TextContent> content, PlayerText ps, DCPTime from) { + boost::mutex::scoped_lock lm (_mutex); + if (_data.find(content) == _data.end()) { _data[content] = list<Period>(); } @@ -130,6 +138,8 @@ ActiveText::add_from (weak_ptr<const TextContent> content, PlayerText ps, DCPTim pair<PlayerText, DCPTime> ActiveText::add_to (weak_ptr<const TextContent> content, DCPTime to) { + boost::mutex::scoped_lock lm (_mutex); + DCPOMATIC_ASSERT (_data.find(content) != _data.end()); _data[content].back().to = to; @@ -147,6 +157,8 @@ ActiveText::add_to (weak_ptr<const TextContent> content, DCPTime to) bool ActiveText::have (weak_ptr<const TextContent> content) const { + boost::mutex::scoped_lock lm (_mutex); + Map::const_iterator i = _data.find(content); if (i == _data.end()) { return false; @@ -158,5 +170,6 @@ ActiveText::have (weak_ptr<const TextContent> content) const void ActiveText::clear () { + boost::mutex::scoped_lock lm (_mutex); _data.clear (); } diff --git a/src/lib/active_text.h b/src/lib/active_text.h index 10ce30f08..1dab7a867 100644 --- a/src/lib/active_text.h +++ b/src/lib/active_text.h @@ -25,6 +25,7 @@ #include "dcpomatic_time.h" #include "player_text.h" #include <boost/noncopyable.hpp> +#include <boost/thread/mutex.hpp> #include <list> #include <map> @@ -64,5 +65,6 @@ private: void add (DCPTimePeriod period, std::list<PlayerText>& pc, std::list<Period> p) const; + mutable boost::mutex _mutex; Map _data; }; |
