summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-07-08 21:13:06 +0100
committerCarl Hetherington <cth@carlh.net>2016-07-08 21:13:06 +0100
commit02cc8c7680381c123a31c23a43f6b34a04c2115a (patch)
tree5891c4c0954a05eaa538feb704cbc99e2ab1d05d
parent167cfacc7fe88f69fa433c46b62a54703ed6dca3 (diff)
Fix failure to analyse audio in some cases.
This fixes audio-only content when the first-emitted audio is not at time zero. This used to cause a seek which is not possible with audio-only. This commit removes the unnecessary seek which was due to missing silent-padding of the first-emitted audio.
-rw-r--r--src/lib/audio_decoder_stream.cc4
-rw-r--r--src/lib/job_manager.h4
-rw-r--r--test/audio_analysis_test.cc20
-rw-r--r--test/test.cc5
-rw-r--r--test/test.h2
5 files changed, 31 insertions, 4 deletions
diff --git a/src/lib/audio_decoder_stream.cc b/src/lib/audio_decoder_stream.cc
index bdcef598d..150e7c242 100644
--- a/src/lib/audio_decoder_stream.cc
+++ b/src/lib/audio_decoder_stream.cc
@@ -45,6 +45,10 @@ AudioDecoderStream::AudioDecoderStream (shared_ptr<const AudioContent> content,
, _stream (stream)
, _decoder (decoder)
, _log (log)
+ /* We effectively start having done a seek to zero; this allows silence-padding of the first
+ data that comes out of our decoder.
+ */
+ , _seek_reference (ContentTime ())
{
if (content->resampled_frame_rate() != _stream->frame_rate() && _stream->channels() > 0) {
_resampler.reset (new Resampler (_stream->frame_rate(), content->resampled_frame_rate(), _stream->channels ()));
diff --git a/src/lib/job_manager.h b/src/lib/job_manager.h
index 70ac00b37..c6be2a78e 100644
--- a/src/lib/job_manager.h
+++ b/src/lib/job_manager.h
@@ -32,7 +32,7 @@ class Job;
class Film;
class Playlist;
-extern void wait_for_jobs ();
+extern bool wait_for_jobs ();
/** @class JobManager
* @brief A simple scheduler for jobs.
@@ -61,7 +61,7 @@ public:
private:
/* This function is part of the test suite */
- friend void ::wait_for_jobs ();
+ friend bool ::wait_for_jobs ();
JobManager ();
~JobManager ();
diff --git a/test/audio_analysis_test.cc b/test/audio_analysis_test.cc
index 5923e0698..278ea06d9 100644
--- a/test/audio_analysis_test.cc
+++ b/test/audio_analysis_test.cc
@@ -32,6 +32,8 @@
#include "lib/ratio.h"
#include "lib/job_manager.h"
#include "lib/audio_content.h"
+#include "lib/content_factory.h"
+#include "lib/playlist.h"
#include "test.h"
using boost::shared_ptr;
@@ -168,3 +170,21 @@ BOOST_AUTO_TEST_CASE (audio_analysis_test3)
wait_for_jobs ();
BOOST_CHECK (done);
}
+
+/** Run an audio analysis that triggered an exception in the audio decoder at one point */
+BOOST_AUTO_TEST_CASE (analyse_audio_test4)
+{
+ shared_ptr<Film> film = new_test_film ("analyse_audio_test");
+ film->set_container (Ratio::from_id ("185"));
+ film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR"));
+ film->set_name ("frobozz");
+ shared_ptr<Content> content = content_factory (film, private_data / "20 The Wedding Convoy Song.m4a");
+ film->examine_and_add_content (content);
+ wait_for_jobs ();
+
+ shared_ptr<Playlist> playlist (new Playlist);
+ playlist->add (content);
+ boost::signals2::connection c;
+ JobManager::instance()->analyse_audio (film, playlist, c, boost::bind (&finished));
+ BOOST_CHECK (!wait_for_jobs ());
+}
diff --git a/test/test.cc b/test/test.cc
index c7a9e95bf..c57f76e61 100644
--- a/test/test.cc
+++ b/test/test.cc
@@ -291,7 +291,7 @@ check_xml (boost::filesystem::path ref, boost::filesystem::path test, list<strin
check_xml (ref_root, test_root, ignore);
}
-void
+bool
wait_for_jobs ()
{
JobManager* jm = JobManager::instance ();
@@ -322,7 +322,10 @@ wait_for_jobs ()
if (jm->errors ()) {
JobManager::drop ();
+ return true;
}
+
+ return false;
}
void
diff --git a/test/test.h b/test/test.h
index 2208929a9..1593b3a03 100644
--- a/test/test.h
+++ b/test/test.h
@@ -25,7 +25,7 @@ class Image;
extern boost::filesystem::path private_data;
-extern void wait_for_jobs ();
+extern bool wait_for_jobs ();
extern boost::shared_ptr<Film> new_test_film (std::string);
extern void check_dcp (boost::filesystem::path, boost::filesystem::path);
extern void check_file (boost::filesystem::path ref, boost::filesystem::path check);