summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2012-10-22 13:33:11 +0100
committerCarl Hetherington <cth@carlh.net>2012-10-22 13:33:11 +0100
commitc0e04acd1e9875fa67800a7861bd8a370157b49f (patch)
tree418dc2124d14c82fade43e3b47043f1ee69e331e /src/lib
parent4cb33e432c7070f59c3ee3fbeb0b5c8755bba3bd (diff)
Fix crash on using delay; fix x-thread GUI access caused by FilmState default copy constructor copying its Changed signal's connections; fix up delay setup after film examine.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/decoder.cc2
-rw-r--r--src/lib/examine_content_job.cc8
-rw-r--r--src/lib/examine_content_job.h1
-rw-r--r--src/lib/film_state.h40
-rw-r--r--src/lib/util.cc16
-rw-r--r--src/lib/util.h1
6 files changed, 63 insertions, 5 deletions
diff --git a/src/lib/decoder.cc b/src/lib/decoder.cc
index 173360ec1..a90c14b2b 100644
--- a/src/lib/decoder.cc
+++ b/src/lib/decoder.cc
@@ -105,7 +105,7 @@ Decoder::process_end ()
uint8_t remainder[-_delay_in_bytes];
_delay_line->get_remaining (remainder);
_audio_frames_processed += _delay_in_bytes / (_fs->audio_channels() * bytes_per_audio_sample());
- emit_audio (remainder, _delay_in_bytes);
+ emit_audio (remainder, -_delay_in_bytes);
}
/* If we cut the decode off, the audio may be short; push some silence
diff --git a/src/lib/examine_content_job.cc b/src/lib/examine_content_job.cc
index d91fc2136..d12e06069 100644
--- a/src/lib/examine_content_job.cc
+++ b/src/lib/examine_content_job.cc
@@ -70,7 +70,6 @@ ExamineContentJob::run ()
_decoder->go ();
fs->set_length (_decoder->last_video_frame ());
- fs->set_audio_delay (-_decoder->audio_to_discard ());
_log->log (String::compose ("Video length is %1 frames", _decoder->last_video_frame()));
_log->log (String::compose ("%1ms of audio to discard", _decoder->audio_to_discard()));
@@ -112,3 +111,10 @@ ExamineContentJob::last_video_frame () const
{
return _decoder->last_video_frame ();
}
+
+int
+ExamineContentJob::audio_to_discard () const
+{
+ return _decoder->audio_to_discard ();
+}
+
diff --git a/src/lib/examine_content_job.h b/src/lib/examine_content_job.h
index 3bbd673a8..d8e94f1ec 100644
--- a/src/lib/examine_content_job.h
+++ b/src/lib/examine_content_job.h
@@ -38,6 +38,7 @@ public:
void run ();
int last_video_frame () const;
+ int audio_to_discard () const;
private:
boost::shared_ptr<Decoder> _decoder;
diff --git a/src/lib/film_state.h b/src/lib/film_state.h
index aa427fcad..294b9aa10 100644
--- a/src/lib/film_state.h
+++ b/src/lib/film_state.h
@@ -76,6 +76,46 @@ public:
, _dirty (false)
{}
+ FilmState (FilmState const & o)
+ : _directory (o._directory)
+ , _name (o._name)
+ , _use_dci_name (o._use_dci_name)
+ , _content (o._content)
+ , _dcp_content_type (o._dcp_content_type)
+ , _format (o._format)
+ , _crop (o._crop)
+ , _filters (o._filters)
+ , _scaler (o._scaler)
+ , _dcp_frames (o._dcp_frames)
+ , _dcp_trim_action (o._dcp_trim_action)
+ , _dcp_ab (o._dcp_ab)
+ , _audio_stream (o._audio_stream)
+ , _audio_gain (o._audio_gain)
+ , _audio_delay (o._audio_delay)
+ , _still_duration (o._still_duration)
+ , _subtitle_stream (o._subtitle_stream)
+ , _with_subtitles (o._with_subtitles)
+ , _subtitle_offset (o._subtitle_offset)
+ , _subtitle_scale (o._subtitle_scale)
+ , _audio_language (o._audio_language)
+ , _subtitle_language (o._subtitle_language)
+ , _territory (o._territory)
+ , _rating (o._rating)
+ , _studio (o._studio)
+ , _facility (o._facility)
+ , _package_type (o._package_type)
+ , _thumbs (o._thumbs)
+ , _size (o._size)
+ , _length (o._length)
+ , _audio_sample_rate (o._audio_sample_rate)
+ , _content_digest (o._content_digest)
+ , _has_subtitles (o._has_subtitles)
+ , _audio_streams (o._audio_streams)
+ , _subtitle_streams (o._subtitle_streams)
+ , _frames_per_second (o._frames_per_second)
+ , _dirty (o._dirty)
+ {}
+
virtual ~FilmState () {}
std::string file (std::string f) const;
diff --git a/src/lib/util.cc b/src/lib/util.cc
index 52a75474b..6221b8b62 100644
--- a/src/lib/util.cc
+++ b/src/lib/util.cc
@@ -36,6 +36,7 @@
#include <boost/bind.hpp>
#include <boost/lambda/lambda.hpp>
#include <boost/lexical_cast.hpp>
+#include <boost/thread.hpp>
#include <openjpeg.h>
#include <openssl/md5.h>
#include <magick/MagickCore.h>
@@ -65,6 +66,8 @@ extern "C" {
using namespace std;
using namespace boost;
+thread::id ui_thread;
+
/** Convert some number of seconds to a string representation
* in hours, minutes and seconds.
*
@@ -265,7 +268,9 @@ sigchld_handler (int, siginfo_t* info, void *)
}
#endif
-/** Call the required functions to set up DVD-o-matic's static arrays, etc. */
+/** Call the required functions to set up DVD-o-matic's static arrays, etc.
+ * Must be called from the UI thread, if there is one.
+ */
void
dvdomatic_setup ()
{
@@ -275,6 +280,8 @@ dvdomatic_setup ()
Filter::setup_filters ();
SoundProcessor::setup_sound_processors ();
+ ui_thread = this_thread::get_id ();
+
#ifdef DVDOMATIC_POSIX
struct sigaction sa;
sa.sa_flags = SA_SIGINFO;
@@ -727,5 +734,8 @@ AudioBuffers::set_frames (int f)
_frames = f;
}
-
-
+void
+ensure_ui_thread ()
+{
+ assert (this_thread::get_id() == ui_thread);
+}
diff --git a/src/lib/util.h b/src/lib/util.h
index a6d95b85d..2265dfe70 100644
--- a/src/lib/util.h
+++ b/src/lib/util.h
@@ -52,6 +52,7 @@ extern void dvdomatic_setup ();
extern std::vector<std::string> split_at_spaces_considering_quotes (std::string);
extern std::string md5_digest (std::string);
extern std::string md5_digest (void const *, int);
+extern void ensure_ui_thread ();
enum ContentType {
STILL,