summaryrefslogtreecommitdiff
path: root/src/lib/ffmpeg_decoder.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-04-04 00:13:27 +0100
committerCarl Hetherington <cth@carlh.net>2013-04-04 00:13:27 +0100
commit190c074cc1508c0aa429452ea920f8f94ef0d0f2 (patch)
tree88cfc25fdfc67837aaf84dc3980cce9ee98094bb /src/lib/ffmpeg_decoder.cc
parent675e849d19812f5ed2d63b3bc0e34f142e6abb89 (diff)
More various bits.
Diffstat (limited to 'src/lib/ffmpeg_decoder.cc')
-rw-r--r--src/lib/ffmpeg_decoder.cc12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc
index 3a185bd6a..fdc5189a6 100644
--- a/src/lib/ffmpeg_decoder.cc
+++ b/src/lib/ffmpeg_decoder.cc
@@ -61,6 +61,8 @@ using boost::optional;
using boost::dynamic_pointer_cast;
using libdcp::Size;
+boost::mutex FFmpegDecoder::_mutex;
+
FFmpegDecoder::FFmpegDecoder (shared_ptr<const Film> f, shared_ptr<const FFmpegContent> c, bool video, bool audio, bool subtitles, bool video_sync)
: Decoder (f)
, VideoDecoder (f)
@@ -92,10 +94,12 @@ FFmpegDecoder::FFmpegDecoder (shared_ptr<const Film> f, shared_ptr<const FFmpegC
FFmpegDecoder::~FFmpegDecoder ()
{
+ boost::mutex::scoped_lock lm (_mutex);
+
if (_audio_codec_context) {
avcodec_close (_audio_codec_context);
}
-
+
if (_video_codec_context) {
avcodec_close (_video_codec_context);
}
@@ -160,6 +164,8 @@ FFmpegDecoder::setup_general ()
void
FFmpegDecoder::setup_video ()
{
+ boost::mutex::scoped_lock lm (_mutex);
+
_video_codec_context = _format_context->streams[_video_stream]->codec;
_video_codec = avcodec_find_decoder (_video_codec_context->codec_id);
@@ -175,6 +181,8 @@ FFmpegDecoder::setup_video ()
void
FFmpegDecoder::setup_audio ()
{
+ boost::mutex::scoped_lock lm (_mutex);
+
if (!_ffmpeg_content->audio_stream ()) {
return;
}
@@ -194,6 +202,8 @@ FFmpegDecoder::setup_audio ()
void
FFmpegDecoder::setup_subtitle ()
{
+ boost::mutex::scoped_lock lm (_mutex);
+
if (!_ffmpeg_content->subtitle_stream() || _ffmpeg_content->subtitle_stream()->id >= int (_format_context->nb_streams)) {
return;
}