From: Carl Hetherington Date: Fri, 8 Jul 2016 20:13:06 +0000 (+0100) Subject: Fix failure to analyse audio in some cases. X-Git-Tag: v2.9.2~11 X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=02cc8c7680381c123a31c23a43f6b34a04c2115a 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. --- 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 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 = 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_factory (film, private_data / "20 The Wedding Convoy Song.m4a"); + film->examine_and_add_content (content); + wait_for_jobs (); + + shared_ptr 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, listerrors ()) { 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 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);