Fix failure to analyse audio in some cases.
authorCarl Hetherington <cth@carlh.net>
Fri, 8 Jul 2016 20:13:06 +0000 (21:13 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 8 Jul 2016 20:13:06 +0000 (21:13 +0100)
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.

src/lib/audio_decoder_stream.cc
src/lib/job_manager.h
test/audio_analysis_test.cc
test/test.cc
test/test.h

index bdcef598d8f68c551597175c0bcd5418d01c9432..150e7c2429f0f329e33ee3819dc6bbbff726fa16 100644 (file)
@@ -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 ()));
index 70ac00b37bc4b86747639548601384a31059a0ec..c6be2a78e754a053609513897ade1eceee1fa977 100644 (file)
@@ -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 ();
index 5923e0698fba9a60fcd35232ab8eeb6c282c3f27..278ea06d9962701562ece6545735bff644d653ef 100644 (file)
@@ -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 ());
+}
index c7a9e95bfd6f8d6a78eda143c4020f4d4bf458ce..c57f76e61c7f98a97effb69622a682308a81ea35 100644 (file)
@@ -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
index 2208929a94b8baa40d9a4965ae22c89fe6a442a2..1593b3a03f1e755024e16e4c07eb3bf6465c5363 100644 (file)
@@ -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);