X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fanalyse_audio_job.cc;h=b17dd07dcb0869cb1891aecbe7068319a433a1f0;hb=93a7ccee1d8d6a89fa90b15893f48c0aaf1d7c9d;hp=31b9dccae953e4ced010feeab571e5a12fadd3a6;hpb=148cc238cfba25ebfab198d7ba3134fc2ea37647;p=dcpomatic.git diff --git a/src/lib/analyse_audio_job.cc b/src/lib/analyse_audio_job.cc index 31b9dccae..b17dd07dc 100644 --- a/src/lib/analyse_audio_job.cc +++ b/src/lib/analyse_audio_job.cc @@ -23,6 +23,7 @@ #include "compose.hpp" #include "film.h" #include "player.h" +#include #include "i18n.h" @@ -31,6 +32,7 @@ using std::max; using std::min; using std::cout; using boost::shared_ptr; +using boost::dynamic_pointer_cast; int const AnalyseAudioJob::_num_points = 1024; @@ -69,11 +71,20 @@ AnalyseAudioJob::run () _current.resize (_film->audio_channels ()); _analysis.reset (new AudioAnalysis (_film->audio_channels ())); - _done = 0; - DCPTime const block = DCPTime::from_seconds (1.0 / 8); - for (DCPTime t; t < _film->length(); t += block) { - analyse (player->get_audio (t, block, false)); - set_progress (t.seconds() / _film->length().seconds()); + bool has_any_audio = false; + BOOST_FOREACH (shared_ptr c, _film->content ()) { + if (dynamic_pointer_cast (c)) { + has_any_audio = true; + } + } + + if (has_any_audio) { + _done = 0; + DCPTime const block = DCPTime::from_seconds (1.0 / 8); + for (DCPTime t; t < _film->length(); t += block) { + analyse (player->get_audio (t, block, false)); + set_progress (t.seconds() / _film->length().seconds()); + } } _analysis->set_peak (_overall_peak, DCPTime::from_frames (_overall_peak_frame, _film->audio_frame_rate ()));