diff options
| author | Carl Hetherington <cth@carlh.net> | 2019-01-26 19:58:37 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2019-01-26 19:58:37 +0000 |
| commit | bccf7c5c6ff50e25dff8e0e433b81379d8999f9b (patch) | |
| tree | b14078351106bede2ca5a8d2c28460686ad9da35 /src/lib | |
| parent | 3743fb15c41eaa66cf625cb4ce9b1f8122b900b4 (diff) | |
Add lock to _colours since it can be manipulated by a Job thread.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/ffmpeg_subtitle_stream.cc | 4 | ||||
| -rw-r--r-- | src/lib/ffmpeg_subtitle_stream.h | 2 |
2 files changed, 6 insertions, 0 deletions
diff --git a/src/lib/ffmpeg_subtitle_stream.cc b/src/lib/ffmpeg_subtitle_stream.cc index c3c6c1f86..da8bafc0a 100644 --- a/src/lib/ffmpeg_subtitle_stream.cc +++ b/src/lib/ffmpeg_subtitle_stream.cc @@ -39,6 +39,7 @@ FFmpegSubtitleStream::FFmpegSubtitleStream (cxml::ConstNodePtr node, int version : FFmpegStream (node) { if (version >= 33) { + boost::mutex::scoped_lock lm (_mutex); BOOST_FOREACH (cxml::NodePtr i, node->node_children ("Colour")) { _colours[RGBA(i->node_child("From"))] = RGBA (i->node_child("To")); } @@ -50,6 +51,7 @@ FFmpegSubtitleStream::as_xml (xmlpp::Node* root) const { FFmpegStream::as_xml (root); + boost::mutex::scoped_lock lm (_mutex); for (map<RGBA, RGBA>::const_iterator i = _colours.begin(); i != _colours.end(); ++i) { xmlpp::Node* node = root->add_child("Colour"); i->first.as_xml (node->add_child("From")); @@ -60,11 +62,13 @@ FFmpegSubtitleStream::as_xml (xmlpp::Node* root) const map<RGBA, RGBA> FFmpegSubtitleStream::colours () const { + boost::mutex::scoped_lock lm (_mutex); return _colours; } void FFmpegSubtitleStream::set_colour (RGBA from, RGBA to) { + boost::mutex::scoped_lock lm (_mutex); _colours[from] = to; } diff --git a/src/lib/ffmpeg_subtitle_stream.h b/src/lib/ffmpeg_subtitle_stream.h index 064c72f8d..85c4df889 100644 --- a/src/lib/ffmpeg_subtitle_stream.h +++ b/src/lib/ffmpeg_subtitle_stream.h @@ -38,5 +38,7 @@ public: std::map<RGBA, RGBA> colours () const; private: + /** mutex to protect _colours as it can be set from the "examine FFMpeg subtitles" job thread */ + mutable boost::mutex _mutex; std::map<RGBA, RGBA> _colours; }; |
