summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/ffmpeg_decoder.cc10
-rw-r--r--src/lib/ffmpeg_decoder.h5
-rw-r--r--src/lib/film.cc5
-rw-r--r--src/lib/job.cc6
-rw-r--r--src/lib/ui_signaller.h5
5 files changed, 27 insertions, 4 deletions
diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc
index cad247e5a..c2143b949 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<Film> f, DecodeOptions o)
: Decoder (f, o)
, VideoDecoder (f, o)
@@ -83,6 +85,8 @@ FFmpegDecoder::FFmpegDecoder (shared_ptr<Film> f, DecodeOptions o)
FFmpegDecoder::~FFmpegDecoder ()
{
+ boost::mutex::scoped_lock lm (_mutex);
+
if (_audio_codec_context) {
avcodec_close (_audio_codec_context);
}
@@ -157,6 +161,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);
@@ -172,6 +178,8 @@ FFmpegDecoder::setup_video ()
void
FFmpegDecoder::setup_audio ()
{
+ boost::mutex::scoped_lock lm (_mutex);
+
if (!_audio_stream) {
return;
}
@@ -194,6 +202,8 @@ FFmpegDecoder::setup_audio ()
void
FFmpegDecoder::setup_subtitle ()
{
+ boost::mutex::scoped_lock lm (_mutex);
+
if (!_subtitle_stream || _subtitle_stream->id() >= int (_format_context->nb_streams)) {
return;
}
diff --git a/src/lib/ffmpeg_decoder.h b/src/lib/ffmpeg_decoder.h
index 0c89b973d..198f4294e 100644
--- a/src/lib/ffmpeg_decoder.h
+++ b/src/lib/ffmpeg_decoder.h
@@ -107,6 +107,9 @@ public:
private:
+ /* No copy construction */
+ FFmpegDecoder (FFmpegDecoder const &);
+
bool pass ();
bool do_seek (double p, bool, bool);
PixelFormat pixel_format () const;
@@ -145,4 +148,6 @@ private:
std::list<boost::shared_ptr<FilterGraph> > _filter_graphs;
boost::mutex _filter_graphs_mutex;
+
+ static boost::mutex _mutex;
};
diff --git a/src/lib/film.cc b/src/lib/film.cc
index 3d9b3eeb4..827c62082 100644
--- a/src/lib/film.cc
+++ b/src/lib/film.cc
@@ -943,6 +943,9 @@ Film::set_content (string c)
_content = c;
}
+ /* Do this before we start using FFmpeg ourselves */
+ run_ffprobe (c, file ("ffprobe.log"), _log);
+
/* Reset streams here in case the new content doesn't have one or the other */
_content_audio_stream = shared_ptr<AudioStream> ();
_subtitle_stream = shared_ptr<SubtitleStream> ();
@@ -998,8 +1001,6 @@ Film::set_content (string c)
if (content_type() == STILL) {
set_use_content_audio (false);
}
-
- run_ffprobe (c, file ("ffprobe.log"), _log);
}
void
diff --git a/src/lib/job.cc b/src/lib/job.cc
index 9a5812fa7..8bb43a91f 100644
--- a/src/lib/job.cc
+++ b/src/lib/job.cc
@@ -27,6 +27,7 @@
#include "job.h"
#include "util.h"
#include "cross.h"
+#include "ui_signaller.h"
#include "i18n.h"
@@ -172,8 +173,11 @@ Job::set_state (State s)
boost::mutex::scoped_lock lm (_state_mutex);
_state = s;
- if (_state == FINISHED_OK || _state == FINISHED_ERROR) {
+ if (_state == FINISHED_OK || _state == FINISHED_ERROR || _state == FINISHED_CANCELLED) {
_ran_for = elapsed_time ();
+ if (ui_signaller) {
+ ui_signaller->emit (boost::bind (boost::ref (Finished)));
+ }
}
}
diff --git a/src/lib/ui_signaller.h b/src/lib/ui_signaller.h
index 221bcbe95..0d19660bf 100644
--- a/src/lib/ui_signaller.h
+++ b/src/lib/ui_signaller.h
@@ -60,7 +60,10 @@ public:
}
/** This should wake the UI and make it call ui_idle() */
- virtual void wake_ui () = 0;
+ virtual void wake_ui () {
+ /* This is only a sensible implementation when there is no GUI... */
+ ui_idle ();
+ }
private:
/** A io_service which is used as the conduit for messages */