From: Carl Hetherington Date: Fri, 30 Apr 2021 23:31:35 +0000 (+0200) Subject: C++11 tidying. X-Git-Tag: v2.15.141~12 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=8963f0007af1a312017b9627c18b82ec2a577591 C++11 tidying. --- diff --git a/src/lib/analytics.cc b/src/lib/analytics.cc index f20b213e4..ac0abc222 100644 --- a/src/lib/analytics.cc +++ b/src/lib/analytics.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Carl Hetherington + Copyright (C) 2018-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,33 +18,37 @@ */ + #include "analytics.h" -#include "exceptions.h" #include "compose.hpp" +#include "exceptions.h" #include "warnings.h" #include #include DCPOMATIC_DISABLE_WARNINGS #include DCPOMATIC_ENABLE_WARNINGS -#include #include +#include #include "i18n.h" + using std::string; using dcp::raw_convert; using boost::algorithm::trim; + Analytics* Analytics::_instance; int const Analytics::_current_version = 1; + Analytics::Analytics () - : _successful_dcp_encodes (0) { } + void Analytics::successful_dcp_encode () { @@ -81,11 +85,12 @@ Analytics::successful_dcp_encode () } } + void Analytics::write () const { xmlpp::Document doc; - xmlpp::Element* root = doc.create_root_node ("Analytics"); + auto root = doc.create_root_node ("Analytics"); root->add_child("Version")->add_child_text(raw_convert(_current_version)); root->add_child("SuccessfulDCPEncodes")->add_child_text(raw_convert(_successful_dcp_encodes)); @@ -99,6 +104,7 @@ Analytics::write () const } } + void Analytics::read () try @@ -110,6 +116,7 @@ try /* Never mind */ } + Analytics* Analytics::instance () { diff --git a/src/lib/analytics.h b/src/lib/analytics.h index be41e3a1b..c0a3e17ef 100644 --- a/src/lib/analytics.h +++ b/src/lib/analytics.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2018-2019 Carl Hetherington + Copyright (C) 2018-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,10 +18,12 @@ */ -#include "state.h" + #include "signaller.h" +#include "state.h" #include + class Analytics : public State, public Signaller { public: @@ -37,7 +39,7 @@ public: static Analytics* instance (); private: - int _successful_dcp_encodes; + int _successful_dcp_encodes = 0; static Analytics* _instance; static int const _current_version; diff --git a/src/lib/audio_delay.cc b/src/lib/audio_delay.cc index 167c522e8..90214470c 100644 --- a/src/lib/audio_delay.cc +++ b/src/lib/audio_delay.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2015 Carl Hetherington + Copyright (C) 2015-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,20 +18,25 @@ */ + #include "audio_delay.h" #include "audio_buffers.h" #include "dcpomatic_assert.h" #include + using std::cout; +using std::make_shared; using std::shared_ptr; + AudioDelay::AudioDelay (int samples) : _samples (samples) { } + shared_ptr AudioDelay::run (shared_ptr in) { @@ -55,7 +60,7 @@ AudioDelay::run (shared_ptr in) /* Keep tail */ if (!_tail) { - _tail.reset (new AudioBuffers (in->channels(), _samples)); + _tail = make_shared(in->channels(), _samples); } _tail->copy_from (in.get(), _samples, in->frames() - _samples, 0); @@ -66,7 +71,7 @@ AudioDelay::run (shared_ptr in) out->copy_from (_tail.get(), out->frames(), 0, 0); } else { out->make_silent (); - _tail.reset (new AudioBuffers (out->channels(), _samples)); + _tail = make_shared(out->channels(), _samples); _tail->make_silent (); } @@ -80,6 +85,7 @@ AudioDelay::run (shared_ptr in) return out; } + void AudioDelay::flush () { diff --git a/src/lib/audio_delay.h b/src/lib/audio_delay.h index 3731013e5..5f3f89a65 100644 --- a/src/lib/audio_delay.h +++ b/src/lib/audio_delay.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2015 Carl Hetherington + Copyright (C) 2015-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -24,8 +24,9 @@ class AudioBuffers; + /** @class AudioDelay - * @brief An audio delay line. + * @brief An audio delay line */ class AudioDelay { diff --git a/src/lib/audio_point.cc b/src/lib/audio_point.cc index 722673b96..abf8485e3 100644 --- a/src/lib/audio_point.cc +++ b/src/lib/audio_point.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2015 Carl Hetherington + Copyright (C) 2012-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "audio_point.h" #include "warnings.h" #include @@ -25,9 +26,11 @@ DCPOMATIC_DISABLE_WARNINGS #include DCPOMATIC_ENABLE_WARNINGS + using std::string; using dcp::raw_convert; + AudioPoint::AudioPoint () { for (int i = 0; i < COUNT; ++i) { @@ -35,12 +38,14 @@ AudioPoint::AudioPoint () } } + AudioPoint::AudioPoint (cxml::ConstNodePtr node) { - _data[PEAK] = node->number_child ("Peak"); - _data[RMS] = node->number_child ("RMS"); + _data[PEAK] = node->number_child("Peak"); + _data[RMS] = node->number_child("RMS"); } + AudioPoint::AudioPoint (AudioPoint const & other) { for (int i = 0; i < COUNT; ++i) { @@ -48,6 +53,7 @@ AudioPoint::AudioPoint (AudioPoint const & other) } } + AudioPoint & AudioPoint::operator= (AudioPoint const & other) { @@ -62,9 +68,10 @@ AudioPoint::operator= (AudioPoint const & other) return *this; } + void AudioPoint::as_xml (xmlpp::Element* parent) const { - parent->add_child ("Peak")->add_child_text (raw_convert (_data[PEAK])); - parent->add_child ("RMS")->add_child_text (raw_convert (_data[RMS])); + parent->add_child("Peak")->add_child_text(raw_convert(_data[PEAK])); + parent->add_child("RMS")->add_child_text(raw_convert(_data[RMS])); } diff --git a/src/lib/audio_point.h b/src/lib/audio_point.h index 91f0cb0e9..e7c232728 100644 --- a/src/lib/audio_point.h +++ b/src/lib/audio_point.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2015 Carl Hetherington + Copyright (C) 2012-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,15 +18,19 @@ */ + #ifndef DCPOMATIC_AUDIO_POINT_H #define DCPOMATIC_AUDIO_POINT_H + #include + namespace xmlpp { class Element; } + class AudioPoint { public: @@ -51,4 +55,5 @@ private: float _data[COUNT]; }; + #endif diff --git a/src/lib/audio_processor.cc b/src/lib/audio_processor.cc index 6cccbdc80..1eb796b38 100644 --- a/src/lib/audio_processor.cc +++ b/src/lib/audio_processor.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington + Copyright (C) 2014-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,41 +18,47 @@ */ + #include "audio_processor.h" +#include "config.h" #include "mid_side_decoder.h" #include "upmixer_a.h" #include "upmixer_b.h" -#include "config.h" + using std::string; using std::list; + list AudioProcessor::_all; list AudioProcessor::_non_experimental; + void AudioProcessor::setup_audio_processors () { - AudioProcessor* mid_side = new MidSideDecoder (); + auto mid_side = new MidSideDecoder (); _all.push_back (mid_side); _non_experimental.push_back (mid_side); - _all.push_back (new UpmixerA (48000)); - _all.push_back (new UpmixerB (48000)); + _all.push_back (new UpmixerA(48000)); + _all.push_back (new UpmixerB(48000)); } + AudioProcessor const * AudioProcessor::from_id (string id) { - for (list::const_iterator i = _all.begin(); i != _all.end(); ++i) { - if ((*i)->id() == id) { - return *i; + for (auto i: _all) { + if (i->id() == id) { + return i; } } - return 0; + return nullptr; } + list AudioProcessor::visible () { @@ -63,6 +69,7 @@ AudioProcessor::visible () return _non_experimental; } + list AudioProcessor::all () { diff --git a/src/lib/audio_processor.h b/src/lib/audio_processor.h index e2f1c48eb..ca80c92b2 100644 --- a/src/lib/audio_processor.h +++ b/src/lib/audio_processor.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2015 Carl Hetherington + Copyright (C) 2014-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,21 +18,26 @@ */ + /** @file src/lib/audio_processor.h * @brief AudioProcessor class. */ + #ifndef DCPOMATIC_AUDIO_PROCESSOR_H #define DCPOMATIC_AUDIO_PROCESSOR_H + #include "types.h" #include #include #include + class AudioBuffers; class AudioMapping; + /** @class AudioProcessor * @brief A parent class for processors of audio data. * @@ -70,4 +75,5 @@ private: static std::list _non_experimental; }; + #endif diff --git a/src/lib/butler.cc b/src/lib/butler.cc index 6de5d5790..b2128efdb 100644 --- a/src/lib/butler.cc +++ b/src/lib/butler.cc @@ -37,7 +37,7 @@ using std::weak_ptr; using std::shared_ptr; using boost::bind; using boost::optional; -using boost::function; +using std::function; using namespace dcpomatic; #if BOOST_VERSION >= 106100 using namespace boost::placeholders; diff --git a/src/lib/butler.h b/src/lib/butler.h index ac83cecec..29966b956 100644 --- a/src/lib/butler.h +++ b/src/lib/butler.h @@ -40,7 +40,7 @@ public: std::shared_ptr player, AudioMapping map, int audio_channels, - boost::function pixel_format, + std::function pixel_format, VideoRange video_range, bool aligned, bool fast @@ -119,7 +119,7 @@ private: bool _disable_audio; - boost::function _pixel_format; + std::function _pixel_format; VideoRange _video_range; bool _aligned; bool _fast; diff --git a/src/lib/cross.h b/src/lib/cross.h index bdcae3537..b70d84a0e 100644 --- a/src/lib/cross.h +++ b/src/lib/cross.h @@ -31,7 +31,6 @@ #include #include #include -#include #ifdef DCPOMATIC_WINDOWS #define WEXITSTATUS(w) (w) diff --git a/src/lib/cross_linux.cc b/src/lib/cross_linux.cc index 816573230..a3dbdebf2 100644 --- a/src/lib/cross_linux.cc +++ b/src/lib/cross_linux.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2020 Carl Hetherington + Copyright (C) 2012-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,20 +18,20 @@ */ -#include "cross.h" + #include "compose.hpp" -#include "log.h" -#include "dcpomatic_log.h" #include "config.h" -#include "exceptions.h" +#include "cross.h" +#include "dcpomatic_log.h" #include "dcpomatic_log.h" +#include "exceptions.h" +#include "log.h" #include #include extern "C" { #include } #include -#include #if BOOST_VERSION >= 106100 #include #endif @@ -46,19 +46,21 @@ extern "C" { #include "i18n.h" -using std::pair; -using std::list; -using std::ifstream; -using std::string; -using std::wstring; -using std::make_pair; -using std::vector; + using std::cerr; using std::cout; +using std::function; +using std::ifstream; +using std::list; +using std::make_pair; +using std::pair; using std::runtime_error; using std::shared_ptr; +using std::string; +using std::vector; +using std::wstring; using boost::optional; -using boost::function; + /** @param s Number of seconds to sleep for */ void @@ -67,12 +69,14 @@ dcpomatic_sleep_seconds (int s) sleep (s); } + void dcpomatic_sleep_milliseconds (int ms) { usleep (ms * 1000); } + /** @return A string of CPU information (model name etc.) */ string cpu_info () @@ -97,6 +101,7 @@ cpu_info () return info; } + boost::filesystem::path resources_path () { @@ -135,12 +140,13 @@ run_ffprobe (boost::filesystem::path content, boost::filesystem::path out) } } -list > + +list> mount_info () { - list > m; + list> m; - FILE* f = setmntent ("/etc/mtab", "r"); + auto f = setmntent ("/etc/mtab", "r"); if (!f) { return m; } @@ -176,7 +182,7 @@ directory_containing_executable () boost::filesystem::path openssl_path () { - boost::filesystem::path p = directory_containing_executable() / "dcpomatic2_openssl"; + auto p = directory_containing_executable() / "dcpomatic2_openssl"; if (boost::filesystem::is_regular_file(p)) { return p; } @@ -201,26 +207,30 @@ disk_writer_path () FILE * fopen_boost (boost::filesystem::path p, string t) { - return fopen (p.c_str(), t.c_str ()); + return fopen(p.c_str(), t.c_str()); } + int dcpomatic_fseek (FILE* stream, int64_t offset, int whence) { return fseek (stream, offset, whence); } + void Waker::nudge () { } + Waker::Waker () { } + Waker::~Waker () { @@ -230,7 +240,7 @@ Waker::~Waker () void start_tool (string executable) { - boost::filesystem::path batch = directory_containing_executable() / executable; + auto batch = directory_containing_executable() / executable; pid_t pid = fork (); if (pid == 0) { @@ -260,6 +270,7 @@ thread_id () return (uint64_t) pthread_self (); } + int avio_open_boost (AVIOContext** s, boost::filesystem::path file, int flags) { @@ -273,6 +284,7 @@ home_directory () return getenv("HOME"); } + /** @return true if this process is a 32-bit one running on a 64-bit-capable OS */ bool running_32_on_64 () @@ -283,10 +295,10 @@ running_32_on_64 () static -vector > +vector> get_mounts (string prefix) { - vector > mounts; + vector> mounts; std::ifstream f("/proc/mounts"); string line; @@ -382,6 +394,7 @@ unprivileged () bool PrivilegeEscalator::test = false; + PrivilegeEscalator::~PrivilegeEscalator () { if (!test) { @@ -389,6 +402,7 @@ PrivilegeEscalator::~PrivilegeEscalator () } } + PrivilegeEscalator::PrivilegeEscalator () { if (!test) { @@ -399,6 +413,7 @@ PrivilegeEscalator::PrivilegeEscalator () } } + boost::filesystem::path config_path () { @@ -415,6 +430,7 @@ disk_write_finished () } + string dcpomatic::get_process_id () { diff --git a/src/lib/cross_osx.cc b/src/lib/cross_osx.cc index bd31541c5..58ec8e3c4 100644 --- a/src/lib/cross_osx.cc +++ b/src/lib/cross_osx.cc @@ -65,7 +65,7 @@ using std::runtime_error; using std::map; using std::shared_ptr; using boost::optional; -using boost::function; +using std::function; /** @param s Number of seconds to sleep for */ void diff --git a/src/lib/curl_uploader.cc b/src/lib/curl_uploader.cc index 1fd8ced01..82dca98f8 100644 --- a/src/lib/curl_uploader.cc +++ b/src/lib/curl_uploader.cc @@ -29,7 +29,7 @@ using std::string; using std::cout; -using boost::function; +using std::function; static size_t read_callback (void* ptr, size_t size, size_t nmemb, void* object) diff --git a/src/lib/curl_uploader.h b/src/lib/curl_uploader.h index 9fb3022f2..14cbce363 100644 --- a/src/lib/curl_uploader.h +++ b/src/lib/curl_uploader.h @@ -24,7 +24,7 @@ class CurlUploader : public Uploader { public: - CurlUploader (boost::function set_status, boost::function set_progress); + CurlUploader (std::function set_status, std::function set_progress); ~CurlUploader (); size_t read_callback (void* ptr, size_t size, size_t nmemb); diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc index 0da42502f..f6a74501c 100644 --- a/src/lib/dcp_content.cc +++ b/src/lib/dcp_content.cc @@ -56,7 +56,7 @@ using std::string; using std::vector; using boost::scoped_ptr; using boost::optional; -using boost::function; +using std::function; using std::dynamic_pointer_cast; #if BOOST_VERSION >= 106100 using namespace boost::placeholders; diff --git a/src/lib/dcp_content.h b/src/lib/dcp_content.h index 136c527a5..69520fbd6 100644 --- a/src/lib/dcp_content.h +++ b/src/lib/dcp_content.h @@ -176,7 +176,7 @@ private: std::list reels (std::shared_ptr film) const; bool can_reference ( std::shared_ptr film, - boost::function )>, + std::function )>, std::string overlapping, std::string& why_not ) const; diff --git a/src/lib/dcp_subtitle.cc b/src/lib/dcp_subtitle.cc index 6f579b2d3..0943a6b08 100644 --- a/src/lib/dcp_subtitle.cc +++ b/src/lib/dcp_subtitle.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2015 Carl Hetherington + Copyright (C) 2014-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "dcp_subtitle.h" #include "exceptions.h" #include "compose.hpp" @@ -26,9 +27,12 @@ #include "i18n.h" -using std::string; + using std::exception; using std::shared_ptr; +using std::string; +using std::make_shared; + shared_ptr DCPSubtitle::load (boost::filesystem::path file) const @@ -38,21 +42,21 @@ DCPSubtitle::load (boost::filesystem::path file) const string smpte_error; try { - sc.reset (new dcp::InteropSubtitleAsset (file)); + sc = make_shared(file); } catch (exception& e) { interop_error = e.what (); } if (!sc) { try { - sc.reset (new dcp::SMPTESubtitleAsset (file)); + sc = make_shared(file); } catch (exception& e) { smpte_error = e.what(); } } if (!sc) { - throw FileError (String::compose (_("Could not read subtitles (%1 / %2)"), interop_error, smpte_error), file); + throw FileError(String::compose(_("Could not read subtitles (%1 / %2)"), interop_error, smpte_error), file); } return sc; diff --git a/src/lib/dcp_subtitle.h b/src/lib/dcp_subtitle.h index 9cd0685aa..2011759aa 100644 --- a/src/lib/dcp_subtitle.h +++ b/src/lib/dcp_subtitle.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2015 Carl Hetherington + Copyright (C) 2014-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,19 +18,24 @@ */ + #ifndef DCPOMATIC_DCP_SUBTITLE_H #define DCPOMATIC_DCP_SUBTITLE_H + #include + namespace dcp { class SubtitleAsset; } + class DCPSubtitle { protected: std::shared_ptr load (boost::filesystem::path) const; }; + #endif diff --git a/src/lib/dcpomatic_log.cc b/src/lib/dcpomatic_log.cc index a64dc907c..cffc79830 100644 --- a/src/lib/dcpomatic_log.cc +++ b/src/lib/dcpomatic_log.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Carl Hetherington + Copyright (C) 2018-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,8 +18,10 @@ */ + #include "dcpomatic_log.h" #include "null_log.h" + /** The current log; set up by the front-ends when they have a Film to log into */ std::shared_ptr dcpomatic_log (new NullLog()); diff --git a/src/lib/dcpomatic_log.h b/src/lib/dcpomatic_log.h index 605f95122..6a1c3a6ec 100644 --- a/src/lib/dcpomatic_log.h +++ b/src/lib/dcpomatic_log.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2018-2020 Carl Hetherington + Copyright (C) 2018-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,12 +18,15 @@ */ + #include "log.h" #include "compose.hpp" + /** The current log; set up by the front-ends when they have a Film to log into */ extern std::shared_ptr dcpomatic_log; + #define LOG_GENERAL(...) dcpomatic_log->log(String::compose(__VA_ARGS__), LogEntry::TYPE_GENERAL); #define LOG_GENERAL_NC(...) dcpomatic_log->log(__VA_ARGS__, LogEntry::TYPE_GENERAL); #define LOG_ERROR(...) dcpomatic_log->log(String::compose(__VA_ARGS__), LogEntry::TYPE_ERROR); diff --git a/src/lib/decoder_part.cc b/src/lib/decoder_part.cc index 2bab1603e..bcddcb785 100644 --- a/src/lib/decoder_part.cc +++ b/src/lib/decoder_part.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2016 Carl Hetherington + Copyright (C) 2012-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,10 +18,10 @@ */ + #include "decoder_part.h" #include "decoder.h" -using std::shared_ptr; DecoderPart::DecoderPart (Decoder* parent) : _parent (parent) diff --git a/src/lib/decoder_part.h b/src/lib/decoder_part.h index 96225f3dd..57ddee781 100644 --- a/src/lib/decoder_part.h +++ b/src/lib/decoder_part.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2016 Carl Hetherington + Copyright (C) 2012-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,16 +18,20 @@ */ + #ifndef DCPOMATIC_DECODER_PART_H #define DCPOMATIC_DECODER_PART_H + #include "dcpomatic_time.h" #include + class Decoder; class Log; class Film; + class DecoderPart { public: @@ -52,4 +56,5 @@ private: bool _ignore; }; + #endif diff --git a/src/lib/ffmpeg_audio_stream.cc b/src/lib/ffmpeg_audio_stream.cc index 32828f13a..91020e288 100644 --- a/src/lib/ffmpeg_audio_stream.cc +++ b/src/lib/ffmpeg_audio_stream.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2014 Carl Hetherington + Copyright (C) 2013-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "ffmpeg_audio_stream.h" #include #include "warnings.h" @@ -26,37 +27,40 @@ DCPOMATIC_DISABLE_WARNINGS DCPOMATIC_ENABLE_WARNINGS #include + using std::string; using boost::optional; using dcp::raw_convert; using namespace dcpomatic; + FFmpegAudioStream::FFmpegAudioStream (cxml::ConstNodePtr node, int version) : FFmpegStream (node) , AudioStream ( - node->number_child ("FrameRate"), - node->optional_number_child("Length").get_value_or (0), - AudioMapping (node->node_child ("Mapping"), version) + node->number_child("FrameRate"), + node->optional_number_child("Length").get_value_or(0), + AudioMapping (node->node_child("Mapping"), version) ) { - optional const f = node->optional_number_child ("FirstAudio"); + optional const f = node->optional_number_child("FirstAudio"); if (f) { - first_audio = ContentTime (f.get ()); + first_audio = ContentTime(f.get()); } codec_name = node->optional_string_child("CodecName"); } + void FFmpegAudioStream::as_xml (xmlpp::Node* root) const { FFmpegStream::as_xml (root); - root->add_child("FrameRate")->add_child_text (raw_convert (frame_rate ())); - root->add_child("Length")->add_child_text (raw_convert (length ())); + root->add_child("FrameRate")->add_child_text(raw_convert(frame_rate())); + root->add_child("Length")->add_child_text(raw_convert(length())); mapping().as_xml (root->add_child("Mapping")); if (first_audio) { - root->add_child("FirstAudio")->add_child_text (raw_convert (first_audio.get().get ())); + root->add_child("FirstAudio")->add_child_text(raw_convert(first_audio.get().get())); } if (codec_name) { - root->add_child("CodecName")->add_child_text (codec_name.get()); + root->add_child("CodecName")->add_child_text(codec_name.get()); } } diff --git a/src/lib/ffmpeg_audio_stream.h b/src/lib/ffmpeg_audio_stream.h index 65c4aba5e..a5ed90c97 100644 --- a/src/lib/ffmpeg_audio_stream.h +++ b/src/lib/ffmpeg_audio_stream.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2014 Carl Hetherington + Copyright (C) 2013-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,12 +18,15 @@ */ -#include "ffmpeg_stream.h" + #include "audio_stream.h" #include "dcpomatic_time.h" +#include "ffmpeg_stream.h" + struct ffmpeg_pts_offset_test; + class FFmpegAudioStream : public FFmpegStream, public AudioStream { public: @@ -61,3 +64,4 @@ private: , AudioStream (0, 0, 0) {} }; + diff --git a/src/lib/file_group.cc b/src/lib/file_group.cc index aaf94acf4..7dae1da92 100644 --- a/src/lib/file_group.cc +++ b/src/lib/file_group.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2020 Carl Hetherington + Copyright (C) 2013-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,51 +18,49 @@ */ + /** @file src/lib/file_group.cc * @brief FileGroup class. */ -#include "file_group.h" -#include "exceptions.h" -#include "cross.h" + #include "compose.hpp" +#include "cross.h" #include "dcpomatic_assert.h" +#include "exceptions.h" +#include "file_group.h" #include #include + using std::vector; + /** Construct a FileGroup with no files */ FileGroup::FileGroup () - : _current_path (0) - , _current_file (0) - , _current_size (0) - , _position (0) { } + /** Construct a FileGroup with a single file */ FileGroup::FileGroup (boost::filesystem::path p) - : _current_path (0) - , _current_file (0) - , _current_size (0) { _paths.push_back (p); ensure_open_path (0); seek (0, SEEK_SET); } + /** Construct a FileGroup with multiple files */ FileGroup::FileGroup (vector const & p) : _paths (p) - , _current_path (0) - , _current_file (0) { ensure_open_path (0); seek (0, SEEK_SET); } + /** Destroy a FileGroup, closing any open file */ FileGroup::~FileGroup () { @@ -71,6 +69,7 @@ FileGroup::~FileGroup () } } + void FileGroup::set_paths (vector const & p) { @@ -79,6 +78,7 @@ FileGroup::set_paths (vector const & p) seek (0, SEEK_SET); } + /** Ensure that the given path index in the content is the _current_file */ void FileGroup::ensure_open_path (size_t p) const @@ -94,12 +94,13 @@ FileGroup::ensure_open_path (size_t p) const _current_path = p; _current_file = fopen_boost (_paths[_current_path], "rb"); - if (_current_file == 0) { + if (!_current_file) { throw OpenFileError (_paths[_current_path], errno, OpenFileError::READ); } _current_size = boost::filesystem::file_size (_paths[_current_path]); } + int64_t FileGroup::seek (int64_t pos, int whence) const { @@ -138,6 +139,7 @@ FileGroup::seek (int64_t pos, int whence) const return _position; } + /** Try to read some data from the current position into a buffer. * @param buffer Buffer to write data into. * @param amount Number of bytes to read. @@ -195,6 +197,7 @@ FileGroup::read (uint8_t* buffer, int amount) const return read; } + /** @return Combined length of all the files */ int64_t FileGroup::length () const diff --git a/src/lib/file_group.h b/src/lib/file_group.h index a696343a0..9521da7ec 100644 --- a/src/lib/file_group.h +++ b/src/lib/file_group.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2014 Carl Hetherington + Copyright (C) 2013-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,16 +18,20 @@ */ + /** @file src/lib/file_group.h * @brief FileGroup class. */ + #ifndef DCPOMATIC_FILE_GROUP_H #define DCPOMATIC_FILE_GROUP_H + #include #include + /** @class FileGroup * @brief A class to make a list of files behave like they were concatenated. */ @@ -53,10 +57,11 @@ private: std::vector _paths; /** Index of path that we are currently reading from */ - mutable size_t _current_path; - mutable FILE* _current_file; - mutable size_t _current_size; - mutable int64_t _position; + mutable size_t _current_path = 0; + mutable FILE* _current_file = nullptr; + mutable size_t _current_size = 0; + mutable int64_t _position = 0; }; + #endif diff --git a/src/lib/frame_interval_checker.cc b/src/lib/frame_interval_checker.cc index dcb9aeaf5..e40958a42 100644 --- a/src/lib/frame_interval_checker.cc +++ b/src/lib/frame_interval_checker.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2020 Carl Hetherington + Copyright (C) 2020-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,12 +18,16 @@ */ + #include "frame_interval_checker.h" + using namespace dcpomatic; + int const FrameIntervalChecker::_frames = 16; + void FrameIntervalChecker::feed (ContentTime time, double frame_rate) { @@ -39,6 +43,7 @@ FrameIntervalChecker::feed (ContentTime time, double frame_rate) _last = time; } + FrameIntervalChecker::Guess FrameIntervalChecker::guess () const { @@ -46,7 +51,7 @@ FrameIntervalChecker::guess () const /* How soon can you land? * I can't tell. * You can tell me, I'm a doctor. - * Nom I mean I'm just not sure. + * No I mean I'm just not sure. * Can't you take a guess? * Well, not for another two hours. * You can't take a guess for another two hours? diff --git a/src/lib/internet.cc b/src/lib/internet.cc index 943363d1a..ca72399f3 100644 --- a/src/lib/internet.cc +++ b/src/lib/internet.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2019 Carl Hetherington + Copyright (C) 2014-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "scoped_temporary.h" #include "compose.hpp" #include "exceptions.h" @@ -25,7 +26,6 @@ #include "util.h" #include #include -#include #include #include #include @@ -33,12 +33,14 @@ #include "i18n.h" -using std::string; + +using std::function; using std::list; +using std::string; using boost::optional; -using boost::function; using boost::algorithm::trim; + static size_t ls_url_data (void* buffer, size_t size, size_t nmemb, void* output) { @@ -50,17 +52,18 @@ ls_url_data (void* buffer, size_t size, size_t nmemb, void* output) return nmemb; } + list ls_url (string url) { - CURL* curl = curl_easy_init (); + auto curl = curl_easy_init (); curl_easy_setopt (curl, CURLOPT_URL, url.c_str()); curl_easy_setopt (curl, CURLOPT_DIRLISTONLY, 1); string ls; curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, ls_url_data); curl_easy_setopt (curl, CURLOPT_WRITEDATA, &ls); - CURLcode const cr = curl_easy_perform (curl); + auto const cr = curl_easy_perform (curl); if (cr != CURLE_OK) { return list(); @@ -80,20 +83,22 @@ ls_url (string url) return result; } + static size_t get_from_url_data (void* buffer, size_t size, size_t nmemb, void* stream) { - FILE* f = reinterpret_cast (stream); + auto f = reinterpret_cast (stream); return fwrite (buffer, size, nmemb, f); } + optional get_from_url (string url, bool pasv, bool skip_pasv_ip, ScopedTemporary& temp) { - CURL* curl = curl_easy_init (); + auto curl = curl_easy_init (); curl_easy_setopt (curl, CURLOPT_URL, url.c_str()); - FILE* f = temp.open ("wb"); + auto f = temp.open ("wb"); curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, get_from_url_data); curl_easy_setopt (curl, CURLOPT_WRITEDATA, f); curl_easy_setopt (curl, CURLOPT_FTP_USE_EPSV, 0); @@ -124,7 +129,7 @@ optional get_from_url (string url, bool pasv, bool skip_pasv_ip, function (boost::filesystem::path)> load) { ScopedTemporary temp; - optional e = get_from_url (url, pasv, skip_pasv_ip, temp); + auto e = get_from_url (url, pasv, skip_pasv_ip, temp); if (e) { return e; } @@ -141,7 +146,7 @@ get_from_zip_url (string url, string file, bool pasv, bool skip_pasv_ip, functio { /* Download the ZIP file to temp_zip */ ScopedTemporary temp_zip; - optional e = get_from_url (url, pasv, skip_pasv_ip, temp_zip); + auto e = get_from_url (url, pasv, skip_pasv_ip, temp_zip); if (e) { return e; } @@ -154,19 +159,19 @@ get_from_zip_url (string url, string file, bool pasv, bool skip_pasv_ip, functio Centos 6, Centos 7, Debian 7 and Debian 8. */ - FILE* zip_file = fopen_boost (temp_zip.file (), "rb"); + auto zip_file = fopen_boost (temp_zip.file (), "rb"); if (!zip_file) { return optional (_("Could not open downloaded ZIP file")); } - zip_source_t* zip_source = zip_source_filep_create (zip_file, 0, -1, 0); + auto zip_source = zip_source_filep_create (zip_file, 0, -1, 0); if (!zip_source) { return optional (_("Could not open downloaded ZIP file")); } zip_error_t error; zip_error_init (&error); - zip_t* zip = zip_open_from_source (zip_source, ZIP_RDONLY, &error); + auto zip = zip_open_from_source (zip_source, ZIP_RDONLY, &error); if (!zip) { return String::compose (_("Could not open downloaded ZIP file (%1:%2: %3)"), error.zip_err, error.sys_err, error.str ? error.str : ""); } @@ -181,7 +186,7 @@ get_from_zip_url (string url, string file, bool pasv, bool skip_pasv_ip, functio } ScopedTemporary temp_cert; - FILE* f = temp_cert.open ("wb"); + auto f = temp_cert.open ("wb"); char buffer[4096]; while (true) { int const N = zip_fread (file_in_zip, buffer, sizeof (buffer)); diff --git a/src/lib/internet.h b/src/lib/internet.h index 8aa7264c6..25513e666 100644 --- a/src/lib/internet.h +++ b/src/lib/internet.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2020 Carl Hetherington + Copyright (C) 2014-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -19,12 +19,13 @@ */ #include -#include #include + class ScopedTemporary; + boost::optional get_from_url (std::string url, bool pasv, bool skip_pasv_ip, ScopedTemporary& temp); -boost::optional get_from_url (std::string url, bool pasv, bool skip_pasv_ip, boost::function (boost::filesystem::path)> load); -boost::optional get_from_zip_url (std::string url, std::string file, bool pasv, bool skip_pasv_ip, boost::function (boost::filesystem::path)> load); +boost::optional get_from_url (std::string url, bool pasv, bool skip_pasv_ip, std::function (boost::filesystem::path)> load); +boost::optional get_from_zip_url (std::string url, std::string file, bool pasv, bool skip_pasv_ip, std::function (boost::filesystem::path)> load); std::list ls_url (std::string url); diff --git a/src/lib/j2k_image_proxy.cc b/src/lib/j2k_image_proxy.cc index fcd1689cb..144da396d 100644 --- a/src/lib/j2k_image_proxy.cc +++ b/src/lib/j2k_image_proxy.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2015 Carl Hetherington + Copyright (C) 2014-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "j2k_image_proxy.h" #include "dcpomatic_socket.h" #include "image.h" @@ -38,17 +39,20 @@ DCPOMATIC_ENABLE_WARNINGS #include "i18n.h" -using std::string; + using std::cout; +using std::dynamic_pointer_cast; +using std::make_pair; +using std::make_shared; using std::max; using std::pair; -using std::make_pair; using std::shared_ptr; +using std::string; using boost::optional; -using std::dynamic_pointer_cast; using dcp::ArrayData; using dcp::raw_convert; + /** Construct a J2KImageProxy from a JPEG2000 file */ J2KImageProxy::J2KImageProxy (boost::filesystem::path path, dcp::Size size, AVPixelFormat pixel_format) : _data (new dcp::ArrayData(path)) @@ -100,9 +104,9 @@ J2KImageProxy::J2KImageProxy ( J2KImageProxy::J2KImageProxy (shared_ptr xml, shared_ptr socket) : _error (false) { - _size = dcp::Size (xml->number_child ("Width"), xml->number_child ("Height")); - if (xml->optional_number_child ("Eye")) { - _eye = static_cast (xml->number_child ("Eye")); + _size = dcp::Size (xml->number_child("Width"), xml->number_child("Height")); + if (xml->optional_number_child("Eye")) { + _eye = static_cast(xml->number_child("Eye")); } shared_ptr data(new ArrayData(xml->number_child("Size"))); /* This only matters when we are using J2KImageProxy for the preview, which @@ -114,6 +118,7 @@ J2KImageProxy::J2KImageProxy (shared_ptr xml, shared_ptr soc _data = data; } + int J2KImageProxy::prepare (optional target_size) const { @@ -139,7 +144,7 @@ J2KImageProxy::prepare (optional target_size) const try { /* XXX: should check that potentially trashing _data here doesn't matter */ - shared_ptr decompressed = dcp::decompress_j2k (const_cast(_data->data()), _data->size(), reduce); + auto decompressed = dcp::decompress_j2k (const_cast(_data->data()), _data->size(), reduce); _image.reset (new Image (_pixel_format, decompressed->size(), true)); int const shift = 16 - decompressed->precision (0); @@ -155,7 +160,7 @@ J2KImageProxy::prepare (optional target_size) const int* decomp_1 = decompressed->data (1); int* decomp_2 = decompressed->data (2); for (int y = 0; y < decompressed->size().height; ++y) { - uint16_t* q = (uint16_t *) (_image->data()[0] + y * _image->stride()[0]); + auto q = reinterpret_cast(_image->data()[0] + y * _image->stride()[0]); for (int x = 0; x < width; ++x) { *q++ = decomp_0[p] << shift; *q++ = decomp_1[p] << shift; @@ -164,7 +169,7 @@ J2KImageProxy::prepare (optional target_size) const } } } catch (dcp::J2KDecompressionError& e) { - _image.reset (new Image (_pixel_format, _size, true)); + _image = make_shared(_pixel_format, _size, true); _image->make_black (); _error = true; } @@ -191,25 +196,27 @@ J2KImageProxy::image (optional target_size) const void J2KImageProxy::add_metadata (xmlpp::Node* node) const { - node->add_child("Type")->add_child_text (N_("J2K")); - node->add_child("Width")->add_child_text (raw_convert (_size.width)); - node->add_child("Height")->add_child_text (raw_convert (_size.height)); + node->add_child("Type")->add_child_text(N_("J2K")); + node->add_child("Width")->add_child_text(raw_convert(_size.width)); + node->add_child("Height")->add_child_text(raw_convert(_size.height)); if (_eye) { - node->add_child("Eye")->add_child_text (raw_convert (static_cast (_eye.get ()))); + node->add_child("Eye")->add_child_text(raw_convert(static_cast(_eye.get()))); } - node->add_child("Size")->add_child_text (raw_convert(_data->size())); + node->add_child("Size")->add_child_text(raw_convert(_data->size())); } + void J2KImageProxy::write_to_socket (shared_ptr socket) const { socket->write (_data->data(), _data->size()); } + bool J2KImageProxy::same (shared_ptr other) const { - shared_ptr jp = dynamic_pointer_cast (other); + auto jp = dynamic_pointer_cast(other); if (!jp) { return false; } @@ -217,6 +224,7 @@ J2KImageProxy::same (shared_ptr other) const return *_data == *jp->_data; } + J2KImageProxy::J2KImageProxy (ArrayData data, dcp::Size size, AVPixelFormat pixel_format) : _data (new ArrayData(data)) , _size (size) @@ -227,6 +235,7 @@ J2KImageProxy::J2KImageProxy (ArrayData data, dcp::Size size, AVPixelFormat pixe DCPOMATIC_ASSERT (_pixel_format == AV_PIX_FMT_RGB48 || _pixel_format == AV_PIX_FMT_XYZ12LE); } + size_t J2KImageProxy::memory_used () const { diff --git a/src/lib/j2k_image_proxy.h b/src/lib/j2k_image_proxy.h index 437a563eb..5235d8e42 100644 --- a/src/lib/j2k_image_proxy.h +++ b/src/lib/j2k_image_proxy.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2015-2017 Carl Hetherington + Copyright (C) 2015-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,16 +18,19 @@ */ + #include "image_proxy.h" #include #include #include + namespace dcp { class MonoPictureFrame; class StereoPictureFrame; } + class J2KImageProxy : public ImageProxy { public: diff --git a/src/lib/job.cc b/src/lib/job.cc index b0ca8a737..52558046a 100644 --- a/src/lib/job.cc +++ b/src/lib/job.cc @@ -44,7 +44,7 @@ using std::list; using std::cout; using std::shared_ptr; using boost::optional; -using boost::function; +using std::function; using namespace dcpomatic; /** @param film Associated film, or 0 */ diff --git a/src/lib/job.h b/src/lib/job.h index 6d8435c60..96f0acbe5 100644 --- a/src/lib/job.h +++ b/src/lib/job.h @@ -86,7 +86,7 @@ public: return _film; } - void when_finished (boost::signals2::connection& connection, boost::function finished); + void when_finished (boost::signals2::connection& connection, std::function finished); boost::signals2::signal Progress; /** Emitted from the UI thread when the job is finished */ diff --git a/src/lib/job_manager.cc b/src/lib/job_manager.cc index 4ed360bed..d8c0b02f2 100644 --- a/src/lib/job_manager.cc +++ b/src/lib/job_manager.cc @@ -34,13 +34,13 @@ using std::dynamic_pointer_cast; +using std::function; using std::list; using std::make_shared; using std::shared_ptr; using std::string; using std::weak_ptr; using boost::bind; -using boost::function; using boost::optional; diff --git a/src/lib/job_manager.h b/src/lib/job_manager.h index 4fe1e45d6..ff5800aa8 100644 --- a/src/lib/job_manager.h +++ b/src/lib/job_manager.h @@ -70,14 +70,14 @@ public: std::shared_ptr playlist, bool from_zero, boost::signals2::connection& connection, - boost::function ready + std::function ready ); void analyse_subtitles ( std::shared_ptr film, std::shared_ptr content, boost::signals2::connection& connection, - boost::function ready + std::function ready ); boost::signals2::signal)> JobAdded; diff --git a/src/lib/kdm_with_metadata.cc b/src/lib/kdm_with_metadata.cc index fbd2e4bd4..3159b4c72 100644 --- a/src/lib/kdm_with_metadata.cc +++ b/src/lib/kdm_with_metadata.cc @@ -27,8 +27,6 @@ #include "config.h" #include "dcpomatic_log.h" #include "emailer.h" -#include -#include #include "i18n.h" @@ -38,7 +36,7 @@ using std::cout; using std::list; using std::shared_ptr; using boost::optional; -using boost::function; +using std::function; int @@ -46,7 +44,7 @@ write_files ( list kdms, boost::filesystem::path directory, dcp::NameFormat name_format, - boost::function confirm_overwrite + std::function confirm_overwrite ) { int written = 0; diff --git a/src/lib/kdm_with_metadata.h b/src/lib/kdm_with_metadata.h index 99c2ef8dc..3e0b7e554 100644 --- a/src/lib/kdm_with_metadata.h +++ b/src/lib/kdm_with_metadata.h @@ -75,7 +75,7 @@ typedef std::shared_ptr KDMWithMetadataPtr; int write_files ( std::list screen_kdms, boost::filesystem::path directory, - dcp::NameFormat name_format, boost::function confirm_overwrite + dcp::NameFormat name_format, std::function confirm_overwrite ); @@ -90,7 +90,7 @@ int write_directories ( boost::filesystem::path directory, dcp::NameFormat container_name_format, dcp::NameFormat filename_format, - boost::function confirm_overwrite + std::function confirm_overwrite ); @@ -99,7 +99,7 @@ int write_zip_files ( boost::filesystem::path directory, dcp::NameFormat container_name_format, dcp::NameFormat filename_format, - boost::function confirm_overwrite + std::function confirm_overwrite ); diff --git a/src/lib/overlaps.cc b/src/lib/overlaps.cc index 32801de39..09e7f63ac 100644 --- a/src/lib/overlaps.cc +++ b/src/lib/overlaps.cc @@ -23,7 +23,7 @@ #include "content.h" using std::shared_ptr; -using boost::function; +using std::function; using namespace dcpomatic; ContentList overlaps (shared_ptr film, ContentList cl, function)> part, DCPTime from, DCPTime to) diff --git a/src/lib/overlaps.h b/src/lib/overlaps.h index 60c0cd537..6c5a85a8b 100644 --- a/src/lib/overlaps.h +++ b/src/lib/overlaps.h @@ -29,5 +29,5 @@ class Film; * ContentList */ ContentList overlaps ( - std::shared_ptr film, ContentList cl, boost::function)> part, dcpomatic::DCPTime from, dcpomatic::DCPTime to + std::shared_ptr film, ContentList cl, std::function)> part, dcpomatic::DCPTime from, dcpomatic::DCPTime to ); diff --git a/src/lib/player_video.cc b/src/lib/player_video.cc index f91b990c8..e473b8750 100644 --- a/src/lib/player_video.cc +++ b/src/lib/player_video.cc @@ -41,7 +41,7 @@ using std::shared_ptr; using std::string; using std::weak_ptr; using boost::optional; -using boost::function; +using std::function; using dcp::Data; using dcp::raw_convert; diff --git a/src/lib/player_video.h b/src/lib/player_video.h index df0007ddf..f29684832 100644 --- a/src/lib/player_video.h +++ b/src/lib/player_video.h @@ -71,8 +71,8 @@ public: void set_text (PositionImage); - void prepare (boost::function pixel_format, VideoRange video_range, bool aligned, bool fast); - std::shared_ptr image (boost::function pixel_format, VideoRange video_range, bool aligned, bool fast) const; + void prepare (std::function pixel_format, VideoRange video_range, bool aligned, bool fast); + std::shared_ptr image (std::function pixel_format, VideoRange video_range, bool aligned, bool fast) const; static AVPixelFormat force (AVPixelFormat, AVPixelFormat); static AVPixelFormat keep_xyz_or_rgb (AVPixelFormat); @@ -118,7 +118,7 @@ public: } private: - void make_image (boost::function pixel_format, VideoRange video_range, bool aligned, bool fast) const; + void make_image (std::function pixel_format, VideoRange video_range, bool aligned, bool fast) const; std::shared_ptr _in; Crop _crop; diff --git a/src/lib/position_image.cc b/src/lib/position_image.cc index c342e1866..9ba2e9c3f 100644 --- a/src/lib/position_image.cc +++ b/src/lib/position_image.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington + Copyright (C) 2014-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,11 +18,10 @@ */ + #include "position_image.h" #include "image.h" -#include -using std::cout; bool PositionImage::same (PositionImage const & other) const diff --git a/src/lib/position_image.h b/src/lib/position_image.h index b78effbd5..2b7e7080a 100644 --- a/src/lib/position_image.h +++ b/src/lib/position_image.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington + Copyright (C) 2014-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #ifndef DCPOMATIC_POSITION_IMAGE_H #define DCPOMATIC_POSITION_IMAGE_H @@ -28,6 +29,7 @@ class Image; + class PositionImage { public: @@ -44,4 +46,5 @@ public: bool same (PositionImage const & other) const; }; + #endif diff --git a/src/lib/reel_writer.cc b/src/lib/reel_writer.cc index a3d499abe..0b367ae38 100644 --- a/src/lib/reel_writer.cc +++ b/src/lib/reel_writer.cc @@ -744,7 +744,7 @@ ReelWriter::create_reel ( } void -ReelWriter::calculate_digests (boost::function set_progress) +ReelWriter::calculate_digests (std::function set_progress) try { if (_picture_asset) { diff --git a/src/lib/reel_writer.h b/src/lib/reel_writer.h index 5eb0e1b08..804a93c05 100644 --- a/src/lib/reel_writer.h +++ b/src/lib/reel_writer.h @@ -81,7 +81,7 @@ public: bool ensure_subtitles, std::set ensure_closed_captions ); - void calculate_digests (boost::function set_progress); + void calculate_digests (std::function set_progress); Frame start () const; diff --git a/src/lib/rgba.cc b/src/lib/rgba.cc index 1076af433..4d2c28085 100644 --- a/src/lib/rgba.cc +++ b/src/lib/rgba.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Carl Hetherington + Copyright (C) 2016-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "rgba.h" #include "warnings.h" DCPOMATIC_DISABLE_WARNINGS @@ -25,26 +26,30 @@ DCPOMATIC_DISABLE_WARNINGS DCPOMATIC_ENABLE_WARNINGS #include + using std::string; using boost::lexical_cast; + RGBA::RGBA (cxml::ConstNodePtr node) { - r = node->number_child ("R"); - g = node->number_child ("G"); - b = node->number_child ("B"); - a = node->number_child ("A"); + r = node->number_child("R"); + g = node->number_child("G"); + b = node->number_child("B"); + a = node->number_child("A"); } + void RGBA::as_xml (xmlpp::Node* parent) const { - parent->add_child("R")->add_child_text (lexical_cast (int (r))); - parent->add_child("G")->add_child_text (lexical_cast (int (g))); - parent->add_child("B")->add_child_text (lexical_cast (int (b))); - parent->add_child("A")->add_child_text (lexical_cast (int (a))); + parent->add_child("R")->add_child_text(lexical_cast(int(r))); + parent->add_child("G")->add_child_text(lexical_cast(int(g))); + parent->add_child("B")->add_child_text(lexical_cast(int(b))); + parent->add_child("A")->add_child_text(lexical_cast(int(a))); } + bool RGBA::operator< (RGBA const & other) const { diff --git a/src/lib/rgba.h b/src/lib/rgba.h index c9521f311..96fed710e 100644 --- a/src/lib/rgba.h +++ b/src/lib/rgba.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Carl Hetherington + Copyright (C) 2016-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,25 +18,22 @@ */ + #ifndef DCPOMATIC_RGBA_H #define DCPOMATIC_RGBA_H + #include #include + /** @class RGBA * @brief A 32-bit RGBA colour. */ - class RGBA { public: - RGBA () - : r (0) - , g (0) - , b (0) - , a (0) - {} + RGBA () {} RGBA (uint8_t r_, uint8_t g_, uint8_t b_, uint8_t a_) : r (r_) @@ -49,12 +46,13 @@ public: void as_xml (xmlpp::Node* parent) const; - uint8_t r; - uint8_t g; - uint8_t b; - uint8_t a; + uint8_t r = 0; + uint8_t g = 0; + uint8_t b = 0; + uint8_t a = 0; bool operator< (RGBA const & other) const; }; + #endif diff --git a/src/lib/shuffler.cc b/src/lib/shuffler.cc index a13e7f6de..5a4faf4d1 100644 --- a/src/lib/shuffler.cc +++ b/src/lib/shuffler.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2018-2020 Carl Hetherington + Copyright (C) 2018-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "shuffler.h" #include "content_video.h" #include "dcpomatic_assert.h" @@ -25,14 +26,17 @@ #include #include + using std::make_pair; +using std::shared_ptr; using std::string; using std::weak_ptr; -using std::shared_ptr; using boost::optional; + int const Shuffler::_max_size = 64; + struct Comparator { bool operator()(Shuffler::Store const & a, Shuffler::Store const & b) { @@ -43,6 +47,7 @@ struct Comparator } }; + void Shuffler::video (weak_ptr weak_piece, ContentVideo video) { @@ -54,7 +59,7 @@ Shuffler::video (weak_ptr weak_piece, ContentVideo video) return; } - shared_ptr piece = weak_piece.lock (); + auto piece = weak_piece.lock (); DCPOMATIC_ASSERT (piece); if (!_last && video.eyes == Eyes::LEFT) { @@ -103,6 +108,7 @@ Shuffler::video (weak_ptr weak_piece, ContentVideo video) } } + void Shuffler::clear () { @@ -111,6 +117,7 @@ Shuffler::clear () _last = optional(); } + void Shuffler::flush () { diff --git a/src/lib/shuffler.h b/src/lib/shuffler.h index b0a416b80..2b37b70a1 100644 --- a/src/lib/shuffler.h +++ b/src/lib/shuffler.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Carl Hetherington + Copyright (C) 2018-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,14 +18,18 @@ */ + #include "types.h" #include "content_video.h" #include + struct shuffler_test5; + class Piece; + class Shuffler { public: diff --git a/src/lib/text_decoder.cc b/src/lib/text_decoder.cc index 099e3ee74..0a7bdf95d 100644 --- a/src/lib/text_decoder.cc +++ b/src/lib/text_decoder.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2017 Carl Hetherington + Copyright (C) 2013-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "text_decoder.h" #include "text_content.h" #include "util.h" @@ -27,6 +28,7 @@ #include #include + using std::list; using std::cout; using std::string; @@ -34,9 +36,10 @@ using std::min; using std::max; using std::shared_ptr; using boost::optional; -using boost::function; +using std::function; using namespace dcpomatic; + TextDecoder::TextDecoder ( Decoder* parent, shared_ptr c, @@ -49,6 +52,7 @@ TextDecoder::TextDecoder ( } + /** Called by subclasses when an image subtitle is starting. * @param from From time of the subtitle. * @param image Subtitle image. @@ -63,6 +67,7 @@ TextDecoder::emit_bitmap_start (ContentTime from, shared_ptr image, dcpom _position = from; } + void TextDecoder::emit_plain_start (ContentTime from, list s) { @@ -97,6 +102,7 @@ TextDecoder::emit_plain_start (ContentTime from, list s) _position = from; } + void TextDecoder::emit_plain_start (ContentTime from, sub::Subtitle const & subtitle) { @@ -250,12 +256,14 @@ TextDecoder::emit_plain_start (ContentTime from, sub::Subtitle const & subtitle) emit_plain_start (from, out); } + void TextDecoder::emit_stop (ContentTime to) { Stop (to); } + void TextDecoder::emit_plain (ContentTimePeriod period, list s) { @@ -263,6 +271,7 @@ TextDecoder::emit_plain (ContentTimePeriod period, list s) emit_stop (period.to); } + void TextDecoder::emit_plain (ContentTimePeriod period, sub::Subtitle const & s) { @@ -270,6 +279,7 @@ TextDecoder::emit_plain (ContentTimePeriod period, sub::Subtitle const & s) emit_stop (period.to); } + /* @param rect Area expressed as a fraction of the video frame that this subtitle * is for (e.g. a width of 0.5 means the width of the subtitle is half the width * of the video frame) @@ -281,6 +291,7 @@ TextDecoder::emit_bitmap (ContentTimePeriod period, shared_ptr image, dcp emit_stop (period.to); } + void TextDecoder::seek () { diff --git a/src/lib/text_decoder.h b/src/lib/text_decoder.h index 3fb27b653..6e96b6b91 100644 --- a/src/lib/text_decoder.h +++ b/src/lib/text_decoder.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2018 Carl Hetherington + Copyright (C) 2013-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,9 +18,11 @@ */ + #ifndef DCPOMATIC_CAPTION_DECODER_H #define DCPOMATIC_CAPTION_DECODER_H + #include "decoder.h" #include "rect.h" #include "types.h" @@ -29,12 +31,14 @@ #include #include + namespace sub { class Subtitle; } class Image; + class TextDecoder : public DecoderPart { public: @@ -71,4 +75,5 @@ private: boost::optional _position; }; + #endif diff --git a/src/lib/text_ring_buffers.cc b/src/lib/text_ring_buffers.cc index ba727cc41..e2be7bf41 100644 --- a/src/lib/text_ring_buffers.cc +++ b/src/lib/text_ring_buffers.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Carl Hetherington + Copyright (C) 2018-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,12 +18,15 @@ */ + #include "text_ring_buffers.h" + using std::pair; using boost::optional; using namespace dcpomatic; + void TextRingBuffers::put (PlayerText text, DCPTextTrack track, DCPTimePeriod period) { @@ -31,19 +34,21 @@ TextRingBuffers::put (PlayerText text, DCPTextTrack track, DCPTimePeriod period) _data.push_back (Data(text, track, period)); } + optional TextRingBuffers::get () { boost::mutex::scoped_lock lm (_mutex); - if (_data.empty ()) { - return optional(); + if (_data.empty()) { + return {}; } - Data r = _data.front (); - _data.pop_front (); + auto r = _data.front(); + _data.pop_front(); return r; } + void TextRingBuffers::clear () { diff --git a/src/lib/text_ring_buffers.h b/src/lib/text_ring_buffers.h index 7d685d824..2014dacc5 100644 --- a/src/lib/text_ring_buffers.h +++ b/src/lib/text_ring_buffers.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Carl Hetherington + Copyright (C) 2018-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,14 +18,17 @@ */ + #ifndef DCPOMATIC_TEXT_RING_BUFFERS_H #define DCPOMATIC_TEXT_RING_BUFFERS_H -#include "player_text.h" + #include "dcp_text_track.h" +#include "player_text.h" #include #include + class TextRingBuffers { public: @@ -52,4 +55,5 @@ private: std::list _data; }; + #endif diff --git a/src/lib/uploader.cc b/src/lib/uploader.cc index 9618e5beb..c5448e469 100644 --- a/src/lib/uploader.cc +++ b/src/lib/uploader.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2015 Carl Hetherington + Copyright (C) 2015-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,15 +18,18 @@ */ + #include "uploader.h" #include "dcpomatic_assert.h" #include "compose.hpp" #include "i18n.h" + using std::string; using std::shared_ptr; -using boost::function; +using std::function; + Uploader::Uploader (function set_status, function set_progress) : _set_progress (set_progress) @@ -35,6 +38,7 @@ Uploader::Uploader (function set_status, function s _set_status (_("connecting")); } + boost::uintmax_t Uploader::count_file_sizes (boost::filesystem::path directory) const { @@ -42,40 +46,43 @@ Uploader::count_file_sizes (boost::filesystem::path directory) const boost::uintmax_t size = 0; - for (directory_iterator i = directory_iterator (directory); i != directory_iterator (); ++i) { - if (is_directory (i->path ())) { - size += count_file_sizes (i->path ()); + for (auto i: directory_iterator(directory)) { + if (is_directory (i.path())) { + size += count_file_sizes (i.path()); } else { - size += file_size (*i); + size += file_size (i); } } return size; } + void Uploader::upload (boost::filesystem::path directory) { boost::uintmax_t transferred = 0; - upload_directory (directory.parent_path (), directory, transferred, count_file_sizes (directory)); + upload_directory (directory.parent_path(), directory, transferred, count_file_sizes(directory)); } + void Uploader::upload_directory (boost::filesystem::path base, boost::filesystem::path directory, boost::uintmax_t& transferred, boost::uintmax_t total_size) { using namespace boost::filesystem; - create_directory (remove_prefix (base, directory)); - for (directory_iterator i = directory_iterator (directory); i != directory_iterator (); ++i) { - if (is_directory (i->path ())) { - upload_directory (base, i->path (), transferred, total_size); + create_directory (remove_prefix(base, directory)); + for (auto i: directory_iterator(directory)) { + if (is_directory(i.path())) { + upload_directory (base, i.path(), transferred, total_size); } else { - _set_status (String::compose (_("copying %1"), i->path().leaf ())); - upload_file (i->path (), remove_prefix (base, i->path ()), transferred, total_size); + _set_status (String::compose(_("copying %1"), i.path().leaf())); + upload_file (i.path(), remove_prefix (base, i.path()), transferred, total_size); } } } + boost::filesystem::path Uploader::remove_prefix (boost::filesystem::path prefix, boost::filesystem::path target) const { @@ -83,8 +90,8 @@ Uploader::remove_prefix (boost::filesystem::path prefix, boost::filesystem::path path result; - path::iterator i = target.begin (); - for (path::iterator j = prefix.begin (); j != prefix.end(); ++j) { + auto i = target.begin (); + for (auto j = prefix.begin (); j != prefix.end(); ++j) { DCPOMATIC_ASSERT (*i == *j); ++i; } diff --git a/src/lib/uploader.h b/src/lib/uploader.h index f57ed8c4f..a68be8dd0 100644 --- a/src/lib/uploader.h +++ b/src/lib/uploader.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2015 Carl Hetherington + Copyright (C) 2015-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,18 +18,21 @@ */ + #ifndef DCPOMATIC_UPLOADER_H #define DCPOMATIC_UPLOADER_H + #include -#include + class Job; + class Uploader { public: - Uploader (boost::function set_status, boost::function set_progress); + Uploader (std::function set_status, std::function set_progress); virtual ~Uploader () {} void upload (boost::filesystem::path directory); @@ -39,14 +42,14 @@ protected: virtual void create_directory (boost::filesystem::path directory) = 0; virtual void upload_file (boost::filesystem::path from, boost::filesystem::path to, boost::uintmax_t& transferred, boost::uintmax_t total_size) = 0; - boost::function _set_progress; + std::function _set_progress; private: void upload_directory (boost::filesystem::path base, boost::filesystem::path directory, boost::uintmax_t& transferred, boost::uintmax_t total_size); boost::uintmax_t count_file_sizes (boost::filesystem::path) const; boost::filesystem::path remove_prefix (boost::filesystem::path prefix, boost::filesystem::path target) const; - boost::function _set_status; + std::function _set_status; }; #endif diff --git a/src/lib/upmixer_b.cc b/src/lib/upmixer_b.cc index 317108f41..3b0c2d94f 100644 --- a/src/lib/upmixer_b.cc +++ b/src/lib/upmixer_b.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2015 Carl Hetherington + Copyright (C) 2015-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,17 +18,21 @@ */ + #include "upmixer_b.h" #include "audio_buffers.h" #include "audio_mapping.h" #include "i18n.h" + using std::string; +using std::make_shared; using std::min; using std::vector; using std::shared_ptr; + UpmixerB::UpmixerB (int sampling_rate) : _lfe (0.01, 150.0 / sampling_rate) , _delay (0.02 * sampling_rate) @@ -36,6 +40,7 @@ UpmixerB::UpmixerB (int sampling_rate) } + string UpmixerB::name () const { @@ -49,25 +54,28 @@ UpmixerB::id () const return N_("stereo-5.1-upmix-b"); } + int UpmixerB::out_channels () const { return 6; } + shared_ptr UpmixerB::clone (int sampling_rate) const { - return shared_ptr (new UpmixerB (sampling_rate)); + return make_shared(sampling_rate); } + shared_ptr UpmixerB::run (shared_ptr in, int channels) { - shared_ptr out (new AudioBuffers (channels, in->frames())); + auto out = make_shared(channels, in->frames()); /* L + R minus 6dB (in terms of amplitude) */ - shared_ptr in_LR = in->channel(0); + auto in_LR = in->channel(0); in_LR->accumulate_frames (in->channel(1).get(), in->frames(), 0, 0); in_LR->apply_gain (-6); @@ -94,7 +102,7 @@ UpmixerB::run (shared_ptr in, int channels) shared_ptr S; if (channels > 4) { /* Ls is L - R with some delay */ - shared_ptr sub (new AudioBuffers (1, in->frames())); + auto sub = make_shared(1, in->frames()); sub->copy_channel_from (in.get(), 0, 0); float* p = sub->data (0); float const * q = in->data (1); @@ -113,6 +121,7 @@ UpmixerB::run (shared_ptr in, int channels) return out; } + void UpmixerB::flush () { @@ -120,6 +129,7 @@ UpmixerB::flush () _delay.flush (); } + void UpmixerB::make_audio_mapping_default (AudioMapping& mapping) const { @@ -130,11 +140,12 @@ UpmixerB::make_audio_mapping_default (AudioMapping& mapping) const } } + vector UpmixerB::input_names () const { - vector n; - n.push_back (NamedChannel(_("Upmix L"), 0)); - n.push_back (NamedChannel(_("Upmix R"), 1)); - return n; + return { + NamedChannel(_("Upmix L"), 0), + NamedChannel(_("Upmix R"), 1) + }; } diff --git a/src/lib/upmixer_b.h b/src/lib/upmixer_b.h index c4c4fd1ac..fc30e2a28 100644 --- a/src/lib/upmixer_b.h +++ b/src/lib/upmixer_b.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2015 Carl Hetherington + Copyright (C) 2015-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,14 +18,17 @@ */ + /** @file src/lib/upmixer_b.h * @brief UpmixerB class. */ + #include "audio_processor.h" #include "audio_filter.h" #include "audio_delay.h" + class UpmixerB : public AudioProcessor { public: @@ -44,3 +47,4 @@ private: LowPassAudioFilter _lfe; AudioDelay _delay; }; + diff --git a/src/lib/util.cc b/src/lib/util.cc index 8a039764d..2b686da69 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -1040,7 +1040,7 @@ show_jobs_on_console (bool progress) /** XXX: could use mmap? */ void -copy_in_bits (boost::filesystem::path from, boost::filesystem::path to, boost::function progress) +copy_in_bits (boost::filesystem::path from, boost::filesystem::path to, std::function progress) { auto f = fopen_boost (from, "rb"); if (!f) { diff --git a/src/lib/util.h b/src/lib/util.h index a6b010e43..fa0d9fdf2 100644 --- a/src/lib/util.h +++ b/src/lib/util.h @@ -118,7 +118,7 @@ extern size_t utf8_strlen (std::string s); extern std::string day_of_week_to_string (boost::gregorian::greg_weekday d); extern void emit_subtitle_image (dcpomatic::ContentTimePeriod period, dcp::SubtitleImage sub, dcp::Size size, std::shared_ptr decoder); extern bool show_jobs_on_console (bool progress); -extern void copy_in_bits (boost::filesystem::path from, boost::filesystem::path to, boost::function); +extern void copy_in_bits (boost::filesystem::path from, boost::filesystem::path to, std::function); extern dcp::Size scale_for_display (dcp::Size s, dcp::Size display_container, dcp::Size film_container); extern dcp::DecryptedKDM decrypt_kdm_with_helpful_error (dcp::EncryptedKDM kdm); extern boost::filesystem::path default_font_file (); diff --git a/src/lib/writer.cc b/src/lib/writer.cc index b749968a7..bc299414b 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -546,7 +546,7 @@ Writer::calculate_digests () pool.create_thread (boost::bind (&boost::asio::io_service::run, &service)); } - boost::function set_progress; + std::function set_progress; if (job) { set_progress = boost::bind (&Writer::set_digest_progress, this, job.get(), _1); } else { @@ -948,7 +948,7 @@ Writer::set_digest_progress (Job* job, float progress) /** Calculate hashes for any referenced MXF assets which do not already have one */ void -Writer::calculate_referenced_digests (boost::function set_progress) +Writer::calculate_referenced_digests (std::function set_progress) try { for (auto const& i: _reel_assets) { diff --git a/src/lib/writer.h b/src/lib/writer.h index 0ff011fa1..1e25c3bdf 100644 --- a/src/lib/writer.h +++ b/src/lib/writer.h @@ -128,7 +128,7 @@ private: size_t video_reel (int frame) const; void set_digest_progress (Job* job, float progress); void write_cover_sheet (boost::filesystem::path output_dcp); - void calculate_referenced_digests (boost::function set_progress); + void calculate_referenced_digests (std::function set_progress); void write_hanging_text (ReelWriter& reel); void calculate_digests (); diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index 56c1db7b1..714bebc3d 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -18,10 +18,12 @@ */ + /** @file src/tools/dcpomatic.cc * @brief The main DCP-o-matic GUI. */ + #include "wx/standard_controls.h" #include "wx/film_viewer.h" #include "wx/film_editor.h" @@ -112,21 +114,22 @@ DCPOMATIC_ENABLE_WARNINGS #undef check #endif + using std::cout; -using std::wcout; +using std::dynamic_pointer_cast; +using std::exception; +using std::function; +using std::list; +using std::make_pair; +using std::make_shared; +using std::map; +using std::shared_ptr; using std::string; using std::vector; +using std::wcout; using std::wstring; using std::wstringstream; -using std::map; -using std::make_pair; -using std::list; -using std::exception; -using std::make_shared; -using std::shared_ptr; -using std::dynamic_pointer_cast; using boost::optional; -using boost::function; using boost::is_any_of; using boost::algorithm::find; #if BOOST_VERSION >= 106100 @@ -134,14 +137,15 @@ using namespace boost::placeholders; #endif using dcp::raw_convert; + class FilmChangedClosingDialog { public: explicit FilmChangedClosingDialog (string name) { _dialog = new wxMessageDialog ( - 0, - wxString::Format (_("Save changes to film \"%s\" before closing?"), std_to_wx (name).data()), + nullptr, + wxString::Format(_("Save changes to film \"%s\" before closing?"), std_to_wx (name).data()), /// TRANSLATORS: this is the heading for a dialog box, which tells the user that the current /// project (Film) has been changed since it was last saved. _("Film changed"), @@ -177,8 +181,8 @@ public: explicit FilmChangedDuplicatingDialog (string name) { _dialog = new wxMessageDialog ( - 0, - wxString::Format (_("Save changes to film \"%s\" before duplicating?"), std_to_wx (name).data()), + nullptr, + wxString::Format(_("Save changes to film \"%s\" before duplicating?"), std_to_wx (name).data()), /// TRANSLATORS: this is the heading for a dialog box, which tells the user that the current /// project (Film) has been changed since it was last saved. _("Film changed"), @@ -207,6 +211,7 @@ private: wxMessageDialog* _dialog; }; + #define ALWAYS 0x0 #define NEEDS_FILM 0x1 #define NOT_DURING_DCP_CREATION 0x2 @@ -217,6 +222,7 @@ private: #define NEEDS_CLIPBOARD 0x40 #define NEEDS_ENCRYPTION 0x80 + map menu_items; enum { @@ -261,28 +267,15 @@ enum { ID_forward_frame }; + class DOMFrame : public wxFrame { public: - explicit DOMFrame (wxString const & title) - : wxFrame (NULL, -1, title) - , _video_waveform_dialog (0) - , _system_information_dialog (0) - , _hints_dialog (0) - , _servers_list_dialog (0) - , _config_dialog (0) - , _kdm_dialog (0) - , _dkdm_dialog (0) - , _templates_dialog (0) - , _file_menu (0) - , _history_items (0) - , _history_position (0) - , _history_separator (0) - , _update_news_requested (false) - , _first_shown_called (false) + explicit DOMFrame (wxString const& title) + : wxFrame (nullptr, -1, title) { #if defined(DCPOMATIC_WINDOWS) - if (Config::instance()->win32_console ()) { + if (Config::instance()->win32_console()) { AllocConsole(); HANDLE handle_out = GetStdHandle(STD_OUTPUT_HANDLE); @@ -309,7 +302,7 @@ public: SetIcon (wxIcon (std_to_wx ("id"))); #endif - _config_changed_connection = Config::instance()->Changed.connect (boost::bind (&DOMFrame::config_changed, this, _1)); + _config_changed_connection = Config::instance()->Changed.connect(boost::bind(&DOMFrame::config_changed, this, _1)); config_changed (Config::OTHER); _analytics_message_connection = Analytics::instance()->Message.connect(boost::bind(&DOMFrame::analytics_message, this, _1, _2)); @@ -355,7 +348,7 @@ public: /* Use a panel as the only child of the Frame so that we avoid the dark-grey background on Windows. */ - wxPanel* overall_panel = new wxPanel (this, wxID_ANY); + auto overall_panel = new wxPanel (this, wxID_ANY); _film_viewer.reset (new FilmViewer (overall_panel)); _controls = new StandardControls (overall_panel, _film_viewer, true); @@ -486,7 +479,7 @@ public: _controls->set_film (_film); if (_video_waveform_dialog) { _video_waveform_dialog->Destroy (); - _video_waveform_dialog = 0; + _video_waveform_dialog = nullptr; } set_menu_sensitivity (); if (_film && _film->directory()) { @@ -788,8 +781,8 @@ private: } /* Remove any existing DCP if the user agrees */ - boost::filesystem::path const dcp_dir = _film->dir (_film->dcp_name(), false); - if (boost::filesystem::exists (dcp_dir)) { + auto const dcp_dir = _film->dir (_film->dcp_name(), false); + if (boost::filesystem::exists(dcp_dir)) { if (!confirm_dialog (this, wxString::Format (_("Do you want to overwrite the existing DCP %s?"), std_to_wx(dcp_dir.string()).data()))) { return; } @@ -832,7 +825,7 @@ private: if (_dkdm_dialog) { _dkdm_dialog->Destroy (); - _dkdm_dialog = 0; + _dkdm_dialog = nullptr; } _dkdm_dialog = new DKDMDialog (this, _film); @@ -967,7 +960,7 @@ private: if (kdm) { if (d->internal ()) { auto dkdms = Config::instance()->dkdms(); - dkdms->add (shared_ptr (new DKDM (kdm.get()))); + dkdms->add (make_shared(kdm.get())); Config::instance()->changed (); } else { auto path = d->directory() / (_film->dcp_name(false) + "_DKDM.xml"); @@ -1525,26 +1518,27 @@ private: FilmEditor* _film_editor; std::shared_ptr _film_viewer; StandardControls* _controls; - VideoWaveformDialog* _video_waveform_dialog; - SystemInformationDialog* _system_information_dialog; - HintsDialog* _hints_dialog; - ServersListDialog* _servers_list_dialog; - wxPreferencesEditor* _config_dialog; - KDMDialog* _kdm_dialog; - DKDMDialog* _dkdm_dialog; - TemplatesDialog* _templates_dialog; - wxMenu* _file_menu; + VideoWaveformDialog* _video_waveform_dialog = nullptr; + SystemInformationDialog* _system_information_dialog = nullptr; + HintsDialog* _hints_dialog = nullptr; + ServersListDialog* _servers_list_dialog = nullptr; + wxPreferencesEditor* _config_dialog = nullptr; + KDMDialog* _kdm_dialog = nullptr; + DKDMDialog* _dkdm_dialog = nullptr; + TemplatesDialog* _templates_dialog = nullptr; + wxMenu* _file_menu = nullptr; shared_ptr _film; - int _history_items; - int _history_position; - wxMenuItem* _history_separator; + int _history_items = 0; + int _history_position = 0; + wxMenuItem* _history_separator = nullptr; boost::signals2::scoped_connection _config_changed_connection; boost::signals2::scoped_connection _analytics_message_connection; - bool _update_news_requested; + bool _update_news_requested = false; shared_ptr _clipboard; - bool _first_shown_called; + bool _first_shown_called = false; }; + static const wxCmdLineEntryDesc command_line_description[] = { { wxCMD_LINE_SWITCH, "n", "new", "create new film", wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_OPTION, "c", "content", "add content file / directory", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, @@ -1555,6 +1549,7 @@ static const wxCmdLineEntryDesc command_line_description[] = { { wxCMD_LINE_NONE, "", "", "", wxCmdLineParamType (0), 0 } }; + /** @class App * @brief The magic App class for wxWidgets. */ @@ -1563,8 +1558,6 @@ class App : public wxApp public: App () : wxApp () - , _frame (0) - , _splash (0) { #ifdef DCPOMATIC_LINUX XInitThreads (); @@ -1641,23 +1634,23 @@ private: signal_manager = new wxSignalManager (this); Bind (wxEVT_IDLE, boost::bind (&App::idle, this, _1)); - if (!_film_to_load.empty() && boost::filesystem::is_directory (_film_to_load)) { + if (!_film_to_load.empty() && boost::filesystem::is_directory(_film_to_load)) { try { _frame->load_film (_film_to_load); } catch (exception& e) { - error_dialog (0, std_to_wx (String::compose (wx_to_std (_("Could not load film %1 (%2)")), _film_to_load)), std_to_wx(e.what())); + error_dialog (nullptr, std_to_wx(String::compose(wx_to_std(_("Could not load film %1 (%2)")), _film_to_load)), std_to_wx(e.what())); } } if (!_film_to_create.empty ()) { - _frame->new_film (_film_to_create, optional ()); - if (!_content_to_add.empty ()) { + _frame->new_film (_film_to_create, optional()); + if (!_content_to_add.empty()) { for (auto i: content_factory(_content_to_add)) { - _frame->film()->examine_and_add_content (i); + _frame->film()->examine_and_add_content(i); } } if (!_dcp_to_add.empty ()) { - _frame->film()->examine_and_add_content(shared_ptr(new DCPContent(_dcp_to_add))); + _frame->film()->examine_and_add_content(make_shared(_dcp_to_add)); } } @@ -1867,8 +1860,8 @@ private: } } - DOMFrame* _frame; - wxSplashScreen* _splash; + DOMFrame* _frame = nullptr; + wxSplashScreen* _splash = nullptr; shared_ptr _timer; string _film_to_load; string _film_to_create; @@ -1876,4 +1869,5 @@ private: string _dcp_to_add; }; + IMPLEMENT_APP (App) diff --git a/src/wx/config_dialog.cc b/src/wx/config_dialog.cc index 576e979e9..a81e8a65c 100644 --- a/src/wx/config_dialog.cc +++ b/src/wx/config_dialog.cc @@ -36,7 +36,7 @@ using std::make_shared; using boost::bind; using boost::optional; using std::shared_ptr; -using boost::function; +using std::function; #if BOOST_VERSION >= 106100 using namespace boost::placeholders; #endif diff --git a/src/wx/config_dialog.h b/src/wx/config_dialog.h index 818ab4def..dd0e92152 100644 --- a/src/wx/config_dialog.h +++ b/src/wx/config_dialog.h @@ -113,9 +113,9 @@ public: wxWindow* parent, wxString title, int border, - boost::function)> set, - boost::function (void)> get, - boost::function nag_alter + std::function)> set, + std::function (void)> get, + std::function nag_alter ); void add_button (wxWindow* button); @@ -144,9 +144,9 @@ private: wxStaticText* _private_key_bad; wxSizer* _sizer; wxBoxSizer* _button_sizer; - boost::function)> _set; - boost::function (void)> _get; - boost::function _nag_alter; + std::function)> _set; + std::function (void)> _get; + std::function _nag_alter; }; class KeysPage : public Page diff --git a/src/wx/content_widget.h b/src/wx/content_widget.h index 2a2bc9cf7..34755e4b5 100644 --- a/src/wx/content_widget.h +++ b/src/wx/content_widget.h @@ -30,7 +30,6 @@ #include #include #include -#include #include /** @class ContentWidget @@ -60,12 +59,12 @@ public: wxWindow* parent, T* wrapped, int property, - boost::function (Content*)> part, - boost::function model_getter, - boost::function model_setter, - boost::function view_changed, - boost::function view_to_model, - boost::function model_to_view + std::function (Content*)> part, + std::function model_getter, + std::function model_setter, + std::function view_changed, + std::function view_to_model, + std::function model_to_view ) : _wrapped (wrapped) , _sizer (0) @@ -217,12 +216,12 @@ private: wxButton* _button; List _content; int _property; - boost::function (Content *)> _part; - boost::function _model_getter; - boost::function _model_setter; - boost::function _view_changed; - boost::function _view_to_model; - boost::function _model_to_view; + std::function (Content *)> _part; + std::function _model_getter; + std::function _model_setter; + std::function _view_changed; + std::function _view_to_model; + std::function _model_to_view; std::list _connections; bool _ignore_model_changes; }; @@ -241,10 +240,10 @@ public: wxWindow* parent, wxSpinCtrl* wrapped, int property, - boost::function (Content *)> part, - boost::function getter, - boost::function setter, - boost::function view_changed = boost::function() + std::function (Content *)> part, + std::function getter, + std::function setter, + std::function view_changed = std::function() ) : ContentWidget ( parent, @@ -269,10 +268,10 @@ public: wxWindow* parent, wxSpinCtrlDouble* wrapped, int property, - boost::function (Content *)> part, - boost::function getter, - boost::function setter, - boost::function view_changed = boost::function() + std::function (Content *)> part, + std::function getter, + std::function setter, + std::function view_changed = std::function() ) : ContentWidget ( parent, @@ -297,12 +296,12 @@ public: wxWindow* parent, wxChoice* wrapped, int property, - boost::function (Content *)> part, - boost::function getter, - boost::function setter, - boost::function view_to_model, - boost::function model_to_view, - boost::function view_changed = boost::function() + std::function (Content *)> part, + std::function getter, + std::function setter, + std::function view_to_model, + std::function model_to_view, + std::function view_changed = std::function() ) : ContentWidget ( parent, diff --git a/src/wx/credentials_download_certificate_panel.cc b/src/wx/credentials_download_certificate_panel.cc index 9032b1f81..77c18e3c1 100644 --- a/src/wx/credentials_download_certificate_panel.cc +++ b/src/wx/credentials_download_certificate_panel.cc @@ -24,7 +24,7 @@ #include "wx_util.h" using std::string; -using boost::function; +using std::function; using boost::optional; CredentialsDownloadCertificatePanel::CredentialsDownloadCertificatePanel ( diff --git a/src/wx/credentials_download_certificate_panel.h b/src/wx/credentials_download_certificate_panel.h index 68472462a..b802768e9 100644 --- a/src/wx/credentials_download_certificate_panel.h +++ b/src/wx/credentials_download_certificate_panel.h @@ -22,7 +22,6 @@ #define CREDENTIALS_DOWNLOAD_CERTIFICATE_PANEL_H #include "download_certificate_panel.h" -#include class PasswordEntry; @@ -31,12 +30,12 @@ class CredentialsDownloadCertificatePanel : public DownloadCertificatePanel public: CredentialsDownloadCertificatePanel ( DownloadCertificateDialog* dialog, - boost::function ()> get_username, - boost::function set_username, - boost::function unset_username, - boost::function ()> get_password, - boost::function set_password, - boost::function unset_password + std::function ()> get_username, + std::function set_username, + std::function unset_username, + std::function ()> get_password, + std::function set_password, + std::function unset_password ); virtual bool ready_to_download () const; @@ -45,12 +44,12 @@ private: void username_changed (); void password_changed (); - boost::function (void)> _get_username; - boost::function _set_username; - boost::function _unset_username; - boost::function (void)> _get_password; - boost::function _set_password; - boost::function _unset_password; + std::function (void)> _get_username; + std::function _set_username; + std::function _unset_username; + std::function (void)> _get_password; + std::function _set_password; + std::function _unset_password; wxTextCtrl* _username; PasswordEntry* _password; diff --git a/src/wx/dkdm_output_panel.cc b/src/wx/dkdm_output_panel.cc index 964662f0e..cf6189efa 100644 --- a/src/wx/dkdm_output_panel.cc +++ b/src/wx/dkdm_output_panel.cc @@ -45,7 +45,7 @@ using std::list; using std::exception; using std::make_pair; using std::shared_ptr; -using boost::function; +using std::function; DKDMOutputPanel::DKDMOutputPanel (wxWindow* parent) diff --git a/src/wx/dkdm_output_panel.h b/src/wx/dkdm_output_panel.h index 57a941818..43e66a172 100644 --- a/src/wx/dkdm_output_panel.h +++ b/src/wx/dkdm_output_panel.h @@ -44,7 +44,7 @@ public: std::pair, int> make ( std::list kdms, std::string name, - boost::function confirm_overwrite + std::function confirm_overwrite ); private: diff --git a/src/wx/dolby_doremi_certificate_panel.cc b/src/wx/dolby_doremi_certificate_panel.cc index 68be51a07..817867cc1 100644 --- a/src/wx/dolby_doremi_certificate_panel.cc +++ b/src/wx/dolby_doremi_certificate_panel.cc @@ -23,19 +23,19 @@ #include "download_certificate_dialog.h" #include "wx_util.h" #include "lib/compose.hpp" -#include "lib/util.h" -#include "lib/signal_manager.h" #include "lib/internet.h" +#include "lib/signal_manager.h" +#include "lib/util.h" #include #include #include #include -using std::string; using std::cout; +using std::function; using std::list; -using boost::function; +using std::string; using boost::optional; #if BOOST_VERSION >= 106100 using namespace boost::placeholders; diff --git a/src/wx/download_certificate_panel.cc b/src/wx/download_certificate_panel.cc index b9680e298..c30b05008 100644 --- a/src/wx/download_certificate_panel.cc +++ b/src/wx/download_certificate_panel.cc @@ -19,19 +19,18 @@ */ -#include "wx_util.h" -#include "download_certificate_panel.h" #include "download_certificate_dialog.h" -#include "lib/signal_manager.h" +#include "download_certificate_panel.h" +#include "wx_util.h" #include "lib/compose.hpp" -#include +#include "lib/signal_manager.h" #include #include +#include #include using std::string; -using boost::function; using boost::optional; diff --git a/src/wx/editable_list.h b/src/wx/editable_list.h index f90d219f8..3f2ea0ca2 100644 --- a/src/wx/editable_list.h +++ b/src/wx/editable_list.h @@ -25,7 +25,6 @@ #include "dcpomatic_button.h" #include #include -#include #include class EditableListColumn @@ -60,9 +59,9 @@ public: EditableList ( wxWindow* parent, std::vector columns, - boost::function ()> get, - boost::function)> set, - boost::function column, + std::function ()> get, + std::function)> set, + std::function column, bool can_edit = true, bool title = true ) @@ -289,10 +288,10 @@ private: ev.Skip (); } - boost::function ()> _get; - boost::function )> _set; + std::function ()> _get; + std::function )> _set; std::vector _columns; - boost::function _column; + std::function _column; wxButton* _add; wxButton* _edit; diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc index 767676fff..d604f678d 100644 --- a/src/wx/film_editor.cc +++ b/src/wx/film_editor.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2016 Carl Hetherington + Copyright (C) 2012-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,10 +18,12 @@ */ + /** @file src/wx/film_editor.cc * @brief FilmEditor class. */ + #include "wx_util.h" #include "film_editor.h" #include "dcp_panel.h" @@ -34,6 +36,7 @@ #include #include + using std::cout; using std::string; using std::list; @@ -44,10 +47,11 @@ using boost::optional; using namespace boost::placeholders; #endif + FilmEditor::FilmEditor (wxWindow* parent, weak_ptr viewer) : wxPanel (parent) { - wxBoxSizer* s = new wxBoxSizer (wxVERTICAL); + auto s = new wxBoxSizer (wxVERTICAL); _main_notebook = new wxNotebook (this, wxID_ANY); s->Add (_main_notebook, 1); @@ -58,7 +62,7 @@ FilmEditor::FilmEditor (wxWindow* parent, weak_ptr viewer) _main_notebook->AddPage (_dcp_panel->panel (), _("DCP"), false); JobManager::instance()->ActiveJobsChanged.connect ( - bind (&FilmEditor::active_jobs_changed, this, _2) + bind(&FilmEditor::active_jobs_changed, this, _2) ); set_film (shared_ptr ()); @@ -92,6 +96,7 @@ FilmEditor::film_change (ChangeType type, Film::Property p) } } + void FilmEditor::film_content_change (ChangeType type, int property) { @@ -112,11 +117,12 @@ FilmEditor::film_content_change (ChangeType type, int property) _dcp_panel->film_content_changed (property); } + /** Sets the Film that we are editing */ void FilmEditor::set_film (shared_ptr film) { - set_general_sensitivity (film != 0); + set_general_sensitivity (film != nullptr); if (_film == film) { return; @@ -132,8 +138,8 @@ FilmEditor::set_film (shared_ptr film) return; } - _film->Change.connect (bind (&FilmEditor::film_change, this, _1, _2)); - _film->ContentChange.connect (bind (&FilmEditor::film_content_change, this, _1, _3)); + _film->Change.connect (bind(&FilmEditor::film_change, this, _1, _2)); + _film->ContentChange.connect (bind(&FilmEditor::film_content_change, this, _1, _3)); if (_film->directory()) { FileChanged (_film->directory().get()); @@ -142,10 +148,11 @@ FilmEditor::set_film (shared_ptr film) } if (!_film->content().empty()) { - _content_panel->set_selection (_film->content().front ()); + _content_panel->set_selection (_film->content().front()); } } + void FilmEditor::set_general_sensitivity (bool s) { @@ -153,6 +160,7 @@ FilmEditor::set_general_sensitivity (bool s) _dcp_panel->set_general_sensitivity (s); } + void FilmEditor::active_jobs_changed (optional j) { diff --git a/src/wx/film_editor.h b/src/wx/film_editor.h index a5232d2e5..6aff127d8 100644 --- a/src/wx/film_editor.h +++ b/src/wx/film_editor.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2015 Carl Hetherington + Copyright (C) 2012-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,10 +18,12 @@ */ + /** @file src/wx/film_editor.h * @brief FilmEditor class. */ + #include "lib/film.h" #include "lib/warnings.h" DCPOMATIC_DISABLE_WARNINGS @@ -29,12 +31,14 @@ DCPOMATIC_DISABLE_WARNINGS DCPOMATIC_ENABLE_WARNINGS #include + class wxNotebook; class Film; class ContentPanel; class DCPPanel; class FilmViewer; + /** @class FilmEditor * @brief A wx widget to edit a film's metadata, and perform various functions. */ diff --git a/src/wx/full_config_dialog.cc b/src/wx/full_config_dialog.cc index 155472a38..dd8da2760 100644 --- a/src/wx/full_config_dialog.cc +++ b/src/wx/full_config_dialog.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2019 Carl Hetherington + Copyright (C) 2012-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,62 +18,66 @@ */ + /** @file src/full_config_dialog.cc * @brief A dialogue to edit all DCP-o-matic configuration. */ -#include "full_config_dialog.h" -#include "wx_util.h" -#include "editable_list.h" -#include "filter_dialog.h" + +#include "check_box.h" +#include "config_dialog.h" +#include "config_move_dialog.h" +#include "dcpomatic_button.h" #include "dir_picker_ctrl.h" +#include "editable_list.h" +#include "email_dialog.h" #include "file_picker_ctrl.h" -#include "server_dialog.h" +#include "filter_dialog.h" +#include "full_config_dialog.h" #include "make_chain_dialog.h" -#include "email_dialog.h" -#include "name_format_editor.h" #include "nag_dialog.h" -#include "config_move_dialog.h" -#include "config_dialog.h" -#include "static_text.h" -#include "check_box.h" -#include "dcpomatic_button.h" +#include "name_format_editor.h" #include "password_entry.h" +#include "server_dialog.h" +#include "static_text.h" +#include "wx_util.h" #include "lib/config.h" -#include "lib/ratio.h" -#include "lib/filter.h" +#include "lib/cross.h" #include "lib/dcp_content_type.h" +#include "lib/exceptions.h" +#include "lib/filter.h" #include "lib/log.h" +#include "lib/ratio.h" #include "lib/util.h" -#include "lib/cross.h" -#include "lib/exceptions.h" -#include -#include #include -#include +#include +#include +#include #include #include -#include +#include #include #include #include -using std::vector; -using std::string; -using std::list; + using std::cout; -using std::pair; +using std::function; +using std::list; using std::make_pair; using std::map; -using boost::bind; +using std::pair; using std::shared_ptr; -using boost::function; +using std::string; +using std::vector; +using boost::bind; using boost::optional; #if BOOST_VERSION >= 106100 using namespace boost::placeholders; #endif using dcp::locale_convert; + class FullGeneralPage : public GeneralPage { public: @@ -84,7 +88,7 @@ public: private: void setup () { - wxGridBagSizer* table = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); + auto table = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); _panel->GetSizer()->Add (table, 1, wxALL | wxEXPAND, _border); int r = 0; @@ -124,8 +128,8 @@ private: add_update_controls (table, r); - _config_file->Bind (wxEVT_FILEPICKER_CHANGED, boost::bind (&FullGeneralPage::config_file_changed, this)); - _cinemas_file->Bind (wxEVT_FILEPICKER_CHANGED, boost::bind (&FullGeneralPage::cinemas_file_changed, this)); + _config_file->Bind (wxEVT_FILEPICKER_CHANGED, boost::bind(&FullGeneralPage::config_file_changed, this)); + _cinemas_file->Bind (wxEVT_FILEPICKER_CHANGED, boost::bind(&FullGeneralPage::cinemas_file_changed, this)); _master_encoding_threads->SetRange (1, 128); _master_encoding_threads->Bind (wxEVT_SPINCTRL, boost::bind (&FullGeneralPage::master_encoding_threads_changed, this)); @@ -141,7 +145,7 @@ private: void config_changed () { - Config* config = Config::instance (); + auto config = Config::instance (); checked_set (_master_encoding_threads, config->master_encoding_threads ()); checked_set (_server_encoding_threads, config->server_encoding_threads ()); @@ -157,8 +161,8 @@ private: void export_cinemas_file () { - wxFileDialog* d = new wxFileDialog ( - _panel, _("Select Cinemas File"), wxEmptyString, wxEmptyString, wxT ("XML files (*.xml)|*.xml"), + auto d = new wxFileDialog ( + _panel, _("Select Cinemas File"), wxEmptyString, wxEmptyString, wxT("XML files (*.xml)|*.xml"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); @@ -171,35 +175,35 @@ private: #ifdef DCPOMATIC_HAVE_EBUR128_PATCHED_FFMPEG void analyse_ebur128_changed () { - Config::instance()->set_analyse_ebur128 (_analyse_ebur128->GetValue ()); + Config::instance()->set_analyse_ebur128 (_analyse_ebur128->GetValue()); } #endif void automatic_audio_analysis_changed () { - Config::instance()->set_automatic_audio_analysis (_automatic_audio_analysis->GetValue ()); + Config::instance()->set_automatic_audio_analysis (_automatic_audio_analysis->GetValue()); } void master_encoding_threads_changed () { - Config::instance()->set_master_encoding_threads (_master_encoding_threads->GetValue ()); + Config::instance()->set_master_encoding_threads (_master_encoding_threads->GetValue()); } void server_encoding_threads_changed () { - Config::instance()->set_server_encoding_threads (_server_encoding_threads->GetValue ()); + Config::instance()->set_server_encoding_threads (_server_encoding_threads->GetValue()); } void config_file_changed () { - Config* config = Config::instance(); + auto config = Config::instance(); boost::filesystem::path new_file = wx_to_std(_config_file->GetPath()); if (new_file == config->config_file()) { return; } bool copy_and_link = true; if (boost::filesystem::exists(new_file)) { - ConfigMoveDialog* d = new ConfigMoveDialog (_panel, new_file); + auto d = new ConfigMoveDialog (_panel, new_file); if (d->ShowModal() == wxID_OK) { copy_and_link = false; } @@ -231,6 +235,7 @@ private: wxCheckBox* _automatic_audio_analysis; }; + class DefaultsPage : public Page { public: @@ -253,13 +258,13 @@ public: private: void setup () { - wxFlexGridSizer* table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); + auto table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); table->AddGrowableCol (1, 1); _panel->GetSizer()->Add (table, 1, wxALL | wxEXPAND, _border); { add_label_to_sizer (table, _panel, _("Default duration of still images"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL); - wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL); + auto s = new wxBoxSizer (wxHORIZONTAL); _still_length = new wxSpinCtrl (_panel); s->Add (_still_length); add_label_to_sizer (s, _panel, _("s"), false, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL); @@ -288,7 +293,7 @@ private: { add_label_to_sizer (table, _panel, _("Default JPEG2000 bandwidth"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL); - wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL); + auto s = new wxBoxSizer (wxHORIZONTAL); _j2k_bandwidth = new wxSpinCtrl (_panel); s->Add (_j2k_bandwidth); add_label_to_sizer (s, _panel, _("Mbit/s"), false, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL); @@ -297,7 +302,7 @@ private: { add_label_to_sizer (table, _panel, _("Default audio delay"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL); - wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL); + auto s = new wxBoxSizer (wxHORIZONTAL); _audio_delay = new wxSpinCtrl (_panel); s->Add (_audio_delay); add_label_to_sizer (s, _panel, _("ms"), false, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL); @@ -351,18 +356,18 @@ private: void config_changed () { - Config* config = Config::instance (); + auto config = Config::instance (); - vector containers = Ratio::containers (); + auto containers = Ratio::containers (); for (size_t i = 0; i < containers.size(); ++i) { - if (containers[i] == config->default_container ()) { + if (containers[i] == config->default_container()) { _container->SetSelection (i); } } - vector const ct = DCPContentType::all (); + auto const ct = DCPContentType::all (); for (size_t i = 0; i < ct.size(); ++i) { - if (ct[i] == config->default_dcp_content_type ()) { + if (ct[i] == config->default_dcp_content_type()) { _dcp_content_type->SetSelection (i); } } @@ -392,7 +397,7 @@ private: int const s = _dcp_audio_channels->GetSelection (); if (s != wxNOT_FOUND) { Config::instance()->set_default_dcp_audio_channels ( - locale_convert (string_client_data (_dcp_audio_channels->GetClientObject (s))) + locale_convert(string_client_data(_dcp_audio_channels->GetClientObject(s))) ); } } @@ -414,13 +419,13 @@ private: void container_changed () { - vector ratio = Ratio::containers (); + auto ratio = Ratio::containers (); Config::instance()->set_default_container (ratio[_container->GetSelection()]); } void dcp_content_type_changed () { - vector ct = DCPContentType::all (); + auto ct = DCPContentType::all (); Config::instance()->set_default_dcp_content_type (ct[_dcp_content_type->GetSelection()]); } @@ -445,6 +450,7 @@ private: wxChoice* _standard; }; + class EncodingServersPage : public Page { public: @@ -482,7 +488,7 @@ private: _panel->GetSizer()->Add (_servers_list, 1, wxEXPAND | wxALL, _border); - _use_any_servers->Bind (wxEVT_CHECKBOX, boost::bind (&EncodingServersPage::use_any_servers_changed, this)); + _use_any_servers->Bind (wxEVT_CHECKBOX, boost::bind(&EncodingServersPage::use_any_servers_changed, this)); } void config_changed () @@ -505,6 +511,7 @@ private: EditableList* _servers_list; }; + class TMSPage : public Page { public: @@ -567,7 +574,7 @@ private: void config_changed () { - Config* config = Config::instance (); + auto config = Config::instance (); checked_set (_upload, config->upload_after_make_dcp()); checked_set (_tms_protocol, static_cast(config->tms_protocol())); @@ -615,11 +622,6 @@ private: PasswordEntry* _tms_password; }; -static string -column (string s) -{ - return s; -} class EmailPage : public Page { @@ -643,7 +645,7 @@ public: private: void setup () { - wxFlexGridSizer* table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); + auto table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); table->AddGrowableCol (1, 1); _panel->GetSizer()->Add (table, 1, wxEXPAND | wxALL, _border); @@ -675,19 +677,19 @@ private: _password = new PasswordEntry (_panel); table->Add (_password->get_panel(), 1, wxEXPAND | wxALL); - _server->Bind (wxEVT_TEXT, boost::bind (&EmailPage::server_changed, this)); - _port->Bind (wxEVT_SPINCTRL, boost::bind (&EmailPage::port_changed, this)); - _protocol->Bind (wxEVT_CHOICE, boost::bind (&EmailPage::protocol_changed, this)); - _user->Bind (wxEVT_TEXT, boost::bind (&EmailPage::user_changed, this)); - _password->Changed.connect (boost::bind (&EmailPage::password_changed, this)); + _server->Bind (wxEVT_TEXT, boost::bind(&EmailPage::server_changed, this)); + _port->Bind (wxEVT_SPINCTRL, boost::bind(&EmailPage::port_changed, this)); + _protocol->Bind (wxEVT_CHOICE, boost::bind(&EmailPage::protocol_changed, this)); + _user->Bind (wxEVT_TEXT, boost::bind(&EmailPage::user_changed, this)); + _password->Changed.connect (boost::bind(&EmailPage::password_changed, this)); } void config_changed () { auto config = Config::instance (); - checked_set (_server, config->mail_server ()); - checked_set (_port, config->mail_port ()); + checked_set (_server, config->mail_server()); + checked_set (_port, config->mail_port()); switch (config->mail_protocol()) { case EmailProtocol::AUTO: checked_set (_protocol, 0); @@ -702,18 +704,18 @@ private: checked_set (_protocol, 3); break; } - checked_set (_user, config->mail_user ()); + checked_set (_user, config->mail_user()); checked_set (_password, config->mail_password()); } void server_changed () { - Config::instance()->set_mail_server (wx_to_std (_server->GetValue ())); + Config::instance()->set_mail_server(wx_to_std(_server->GetValue())); } void port_changed () { - Config::instance()->set_mail_port (_port->GetValue ()); + Config::instance()->set_mail_port(_port->GetValue()); } void protocol_changed () @@ -751,6 +753,7 @@ private: PasswordEntry* _password; }; + class KDMEmailPage : public Page { public: @@ -799,8 +802,9 @@ private: columns, bind (&Config::kdm_cc, Config::instance()), bind (&Config::set_kdm_cc, Config::instance(), _1), - bind (&column, _1) - ); + [] (string s, int) { + return s; + }); table->Add (_cc, 1, wxEXPAND | wxALL); add_label_to_sizer (table, _panel, _("BCC address"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL); @@ -872,6 +876,7 @@ private: wxButton* _reset_email; }; + class NotificationsPage : public Page { public: @@ -899,7 +904,7 @@ public: private: void setup () { - wxFlexGridSizer* table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); + auto table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); table->AddGrowableCol (1, 1); _panel->GetSizer()->Add (table, 1, wxEXPAND | wxALL, _border); @@ -931,8 +936,9 @@ private: columns, bind (&Config::notification_cc, Config::instance()), bind (&Config::set_notification_cc, Config::instance(), _1), - bind (&column, _1) - ); + [] (string s, int) { + return s; + }); table->Add (_cc, 1, wxEXPAND | wxALL); add_label_to_sizer (table, _panel, _("BCC address"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL); @@ -974,7 +980,7 @@ private: void config_changed () { - Config* config = Config::instance (); + auto config = Config::instance (); checked_set (_enable_message_box, config->notification(Config::MESSAGE_BOX)); checked_set (_enable_email, config->notification(Config::EMAIL)); @@ -989,39 +995,39 @@ private: void notification_subject_changed () { - Config::instance()->set_notification_subject (wx_to_std (_subject->GetValue ())); + Config::instance()->set_notification_subject(wx_to_std(_subject->GetValue())); } void notification_from_changed () { - Config::instance()->set_notification_from (wx_to_std (_from->GetValue ())); + Config::instance()->set_notification_from(wx_to_std(_from->GetValue())); } void notification_to_changed () { - Config::instance()->set_notification_to (wx_to_std (_to->GetValue ())); + Config::instance()->set_notification_to(wx_to_std(_to->GetValue())); } void notification_bcc_changed () { - Config::instance()->set_notification_bcc (wx_to_std (_bcc->GetValue ())); + Config::instance()->set_notification_bcc(wx_to_std(_bcc->GetValue())); } void notification_email_changed () { - if (_email->GetValue().IsEmpty ()) { + if (_email->GetValue().IsEmpty()) { /* Sometimes we get sent an erroneous notification that the email is empty; I don't know why. */ return; } - Config::instance()->set_notification_email (wx_to_std (_email->GetValue ())); + Config::instance()->set_notification_email(wx_to_std(_email->GetValue())); } void reset_email () { - Config::instance()->reset_notification_email (); - checked_set (_email, Config::instance()->notification_email ()); + Config::instance()->reset_notification_email(); + checked_set (_email, Config::instance()->notification_email()); } void type_changed (wxCheckBox* b, Config::Notification n) @@ -1042,6 +1048,7 @@ private: wxButton* _reset_email; }; + class CoverSheetPage : public Page { public: @@ -1082,7 +1089,7 @@ private: void config_changed () { - checked_set (_cover_sheet, Config::instance()->cover_sheet ()); + checked_set (_cover_sheet, Config::instance()->cover_sheet()); } void cover_sheet_changed () @@ -1093,13 +1100,13 @@ private: */ return; } - Config::instance()->set_cover_sheet (wx_to_std (_cover_sheet->GetValue ())); + Config::instance()->set_cover_sheet(wx_to_std(_cover_sheet->GetValue())); } void reset_cover_sheet () { - Config::instance()->reset_cover_sheet (); - checked_set (_cover_sheet, Config::instance()->cover_sheet ()); + Config::instance()->reset_cover_sheet(); + checked_set (_cover_sheet, Config::instance()->cover_sheet()); } wxTextCtrl* _cover_sheet; @@ -1129,7 +1136,7 @@ public: private: void setup () { - wxFlexGridSizer* table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); + auto table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); table->AddGrowableCol (1, 1); add_label_to_sizer (table, _panel, _("Issuer"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL); @@ -1174,7 +1181,7 @@ private: void config_changed () { - Config* config = Config::instance (); + auto config = Config::instance (); checked_set (_issuer, config->dcp_issuer ()); checked_set (_creator, config->dcp_creator ()); checked_set (_company_name, config->dcp_company_name ()); @@ -1185,27 +1192,27 @@ private: void issuer_changed () { - Config::instance()->set_dcp_issuer (wx_to_std (_issuer->GetValue ())); + Config::instance()->set_dcp_issuer(wx_to_std(_issuer->GetValue())); } void creator_changed () { - Config::instance()->set_dcp_creator (wx_to_std (_creator->GetValue ())); + Config::instance()->set_dcp_creator(wx_to_std(_creator->GetValue())); } void company_name_changed () { - Config::instance()->set_dcp_company_name (wx_to_std(_company_name->GetValue())); + Config::instance()->set_dcp_company_name(wx_to_std(_company_name->GetValue())); } void product_name_changed () { - Config::instance()->set_dcp_product_name (wx_to_std(_product_name->GetValue())); + Config::instance()->set_dcp_product_name(wx_to_std(_product_name->GetValue())); } void product_version_changed () { - Config::instance()->set_dcp_product_version (wx_to_std(_product_version->GetValue())); + Config::instance()->set_dcp_product_version(wx_to_std(_product_version->GetValue())); } void j2k_comment_changed () @@ -1230,21 +1237,6 @@ class AdvancedPage : public Page public: AdvancedPage (wxSize panel_size, int border) : Page (panel_size, border) - , _maximum_j2k_bandwidth (0) - , _allow_any_dcp_frame_rate (0) - , _allow_any_container (0) - , _show_experimental_audio_processors (0) - , _only_servers_encode (0) - , _log_general (0) - , _log_warning (0) - , _log_error (0) - , _log_timing (0) - , _log_debug_threed (0) - , _log_debug_encode (0) - , _log_debug_email (0) - , _log_debug_video_view (0) - , _log_debug_player (0) - , _log_debug_audio_analysis (0) {} wxString GetName () const @@ -1273,7 +1265,7 @@ private: void setup () { - wxFlexGridSizer* table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); + auto table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); table->AddGrowableCol (1, 1); _panel->GetSizer()->Add (table, 1, wxALL | wxEXPAND, _border); @@ -1290,8 +1282,8 @@ private: _video_display_mode = new wxChoice (_panel, wxID_ANY); table->Add (_video_display_mode); - wxStaticText* restart = add_label_to_sizer (table, _panel, _("(restart DCP-o-matic to change display mode)"), false); - wxFont font = restart->GetFont(); + auto restart = add_label_to_sizer (table, _panel, _("(restart DCP-o-matic to change display mode)"), false); + auto font = restart->GetFont(); font.SetStyle (wxFONTSTYLE_ITALIC); font.SetPointSize (font.GetPointSize() - 1); restart->SetFont (font); @@ -1319,7 +1311,7 @@ private: { add_label_to_sizer (table, _panel, _("Maximum number of frames to store per thread"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL); - wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL); + auto s = new wxBoxSizer (wxHORIZONTAL); _frames_in_memory_multiplier = new wxSpinCtrl (_panel); s->Add (_frames_in_memory_multiplier, 1); table->Add (s, 1); @@ -1357,7 +1349,7 @@ private: { add_top_aligned_label_to_sizer (table, _panel, _("Log")); - wxBoxSizer* t = new wxBoxSizer (wxVERTICAL); + auto t = new wxBoxSizer (wxVERTICAL); _log_general = new CheckBox (_panel, _("General")); t->Add (_log_general, 1, wxEXPAND | wxALL); _log_warning = new CheckBox (_panel, _("Warnings")); @@ -1417,7 +1409,7 @@ private: void config_changed () { - Config* config = Config::instance (); + auto config = Config::instance (); checked_set (_maximum_j2k_bandwidth, config->maximum_j2k_bandwidth() / 1000000); switch (config->video_view_type()) { @@ -1450,51 +1442,51 @@ private: void maximum_j2k_bandwidth_changed () { - Config::instance()->set_maximum_j2k_bandwidth (_maximum_j2k_bandwidth->GetValue() * 1000000); + Config::instance()->set_maximum_j2k_bandwidth(_maximum_j2k_bandwidth->GetValue() * 1000000); } void video_display_mode_changed () { if (_video_display_mode->GetSelection() == 0) { - Config::instance()->set_video_view_type (Config::VIDEO_VIEW_SIMPLE); + Config::instance()->set_video_view_type(Config::VIDEO_VIEW_SIMPLE); } else { - Config::instance()->set_video_view_type (Config::VIDEO_VIEW_OPENGL); + Config::instance()->set_video_view_type(Config::VIDEO_VIEW_OPENGL); } } void frames_in_memory_multiplier_changed () { - Config::instance()->set_frames_in_memory_multiplier (_frames_in_memory_multiplier->GetValue()); + Config::instance()->set_frames_in_memory_multiplier(_frames_in_memory_multiplier->GetValue()); } void allow_any_dcp_frame_rate_changed () { - Config::instance()->set_allow_any_dcp_frame_rate (_allow_any_dcp_frame_rate->GetValue ()); + Config::instance()->set_allow_any_dcp_frame_rate(_allow_any_dcp_frame_rate->GetValue()); } void allow_any_container_changed () { - Config::instance()->set_allow_any_container (_allow_any_container->GetValue ()); + Config::instance()->set_allow_any_container(_allow_any_container->GetValue()); } void show_experimental_audio_processors_changed () { - Config::instance()->set_show_experimental_audio_processors (_show_experimental_audio_processors->GetValue ()); + Config::instance()->set_show_experimental_audio_processors(_show_experimental_audio_processors->GetValue()); } void only_servers_encode_changed () { - Config::instance()->set_only_servers_encode (_only_servers_encode->GetValue ()); + Config::instance()->set_only_servers_encode (_only_servers_encode->GetValue()); } void dcp_metadata_filename_format_changed () { - Config::instance()->set_dcp_metadata_filename_format (_dcp_metadata_filename_format->get ()); + Config::instance()->set_dcp_metadata_filename_format(_dcp_metadata_filename_format->get()); } void dcp_asset_filename_format_changed () { - Config::instance()->set_dcp_asset_filename_format (_dcp_asset_filename_format->get ()); + Config::instance()->set_dcp_asset_filename_format(_dcp_asset_filename_format->get()); } void log_changed () @@ -1536,38 +1528,39 @@ private: #ifdef DCPOMATIC_WINDOWS void win32_console_changed () { - Config::instance()->set_win32_console (_win32_console->GetValue ()); + Config::instance()->set_win32_console(_win32_console->GetValue()); } #endif - wxSpinCtrl* _maximum_j2k_bandwidth; - wxChoice* _video_display_mode; - wxSpinCtrl* _frames_in_memory_multiplier; - wxCheckBox* _allow_any_dcp_frame_rate; - wxCheckBox* _allow_any_container; - wxCheckBox* _show_experimental_audio_processors; - wxCheckBox* _only_servers_encode; - NameFormatEditor* _dcp_metadata_filename_format; - NameFormatEditor* _dcp_asset_filename_format; - wxCheckBox* _log_general; - wxCheckBox* _log_warning; - wxCheckBox* _log_error; - wxCheckBox* _log_timing; - wxCheckBox* _log_debug_threed; - wxCheckBox* _log_debug_encode; - wxCheckBox* _log_debug_email; - wxCheckBox* _log_debug_video_view; - wxCheckBox* _log_debug_player; - wxCheckBox* _log_debug_audio_analysis; + wxSpinCtrl* _maximum_j2k_bandwidth = nullptr; + wxChoice* _video_display_mode = nullptr; + wxSpinCtrl* _frames_in_memory_multiplier = nullptr; + wxCheckBox* _allow_any_dcp_frame_rate = nullptr; + wxCheckBox* _allow_any_container = nullptr; + wxCheckBox* _show_experimental_audio_processors = nullptr; + wxCheckBox* _only_servers_encode = nullptr; + NameFormatEditor* _dcp_metadata_filename_format = nullptr; + NameFormatEditor* _dcp_asset_filename_format = nullptr; + wxCheckBox* _log_general = nullptr; + wxCheckBox* _log_warning = nullptr; + wxCheckBox* _log_error = nullptr; + wxCheckBox* _log_timing = nullptr; + wxCheckBox* _log_debug_threed = nullptr; + wxCheckBox* _log_debug_encode = nullptr; + wxCheckBox* _log_debug_email = nullptr; + wxCheckBox* _log_debug_video_view = nullptr; + wxCheckBox* _log_debug_player = nullptr; + wxCheckBox* _log_debug_audio_analysis = nullptr; #ifdef DCPOMATIC_WINDOWS - wxCheckBox* _win32_console; + wxCheckBox* _win32_console = nullptr; #endif }; + wxPreferencesEditor* create_full_config_dialog () { - wxPreferencesEditor* e = new wxPreferencesEditor (); + auto e = new wxPreferencesEditor (); #ifdef DCPOMATIC_OSX /* Width that we force some of the config panels to be on OSX so that @@ -1581,17 +1574,17 @@ create_full_config_dialog () int const border = 8; #endif - e->AddPage (new FullGeneralPage (ps, border)); - e->AddPage (new SoundPage (ps, border)); - e->AddPage (new DefaultsPage (ps, border)); - e->AddPage (new EncodingServersPage (ps, border)); - e->AddPage (new KeysPage (ps, border)); - e->AddPage (new TMSPage (ps, border)); - e->AddPage (new EmailPage (ps, border)); - e->AddPage (new KDMEmailPage (ps, border)); - e->AddPage (new NotificationsPage (ps, border)); - e->AddPage (new CoverSheetPage (ps, border)); - e->AddPage (new IdentifiersPage (ps, border)); - e->AddPage (new AdvancedPage (ps, border)); + e->AddPage (new FullGeneralPage (ps, border)); + e->AddPage (new SoundPage (ps, border)); + e->AddPage (new DefaultsPage (ps, border)); + e->AddPage (new EncodingServersPage(ps, border)); + e->AddPage (new KeysPage (ps, border)); + e->AddPage (new TMSPage (ps, border)); + e->AddPage (new EmailPage (ps, border)); + e->AddPage (new KDMEmailPage (ps, border)); + e->AddPage (new NotificationsPage (ps, border)); + e->AddPage (new CoverSheetPage (ps, border)); + e->AddPage (new IdentifiersPage (ps, border)); + e->AddPage (new AdvancedPage (ps, border)); return e; } diff --git a/src/wx/full_config_dialog.h b/src/wx/full_config_dialog.h index 5191b1456..ae275b188 100644 --- a/src/wx/full_config_dialog.h +++ b/src/wx/full_config_dialog.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2017 Carl Hetherington + Copyright (C) 2012-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,10 +18,14 @@ */ + /** @file src/full_config_dialog.h * @brief A dialogue to edit all DCP-o-matic configuration. */ + class wxPreferencesEditor; + wxPreferencesEditor* create_full_config_dialog (); + diff --git a/src/wx/job_view_dialog.cc b/src/wx/job_view_dialog.cc index 455998c5c..3d900e1d3 100644 --- a/src/wx/job_view_dialog.cc +++ b/src/wx/job_view_dialog.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2015 Carl Hetherington + Copyright (C) 2015-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,12 +18,15 @@ */ + #include "job_view_dialog.h" #include "normal_job_view.h" #include "lib/job.h" + using std::shared_ptr; + JobViewDialog::JobViewDialog (wxWindow* parent, wxString title, shared_ptr job) : TableDialog (parent, title, 4, 0, false) , _job (job) @@ -33,29 +36,31 @@ JobViewDialog::JobViewDialog (wxWindow* parent, wxString title, shared_ptr layout (); SetMinSize (wxSize (960, -1)); - Bind (wxEVT_TIMER, boost::bind (&JobViewDialog::periodic, this)); - _timer.reset (new wxTimer (this)); + Bind (wxEVT_TIMER, boost::bind(&JobViewDialog::periodic, this)); + _timer.reset (new wxTimer(this)); _timer->Start (1000); /* Start off with OK disabled and it will be enabled when the job is finished */ - wxButton* ok = dynamic_cast (FindWindowById (wxID_OK, this)); + auto ok = dynamic_cast(FindWindowById(wxID_OK, this)); if (ok) { ok->Enable (false); } } + JobViewDialog::~JobViewDialog () { delete _view; } + void JobViewDialog::periodic () { _view->maybe_pulse (); - shared_ptr job = _job.lock (); - wxButton* ok = dynamic_cast (FindWindowById (wxID_OK, this)); + auto job = _job.lock (); + auto ok = dynamic_cast(FindWindowById(wxID_OK, this)); if (job && ok) { ok->Enable (job->finished ()); } diff --git a/src/wx/job_view_dialog.h b/src/wx/job_view_dialog.h index b72ad298d..66a3ea6c6 100644 --- a/src/wx/job_view_dialog.h +++ b/src/wx/job_view_dialog.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2015 Carl Hetherington + Copyright (C) 2015-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -26,6 +26,7 @@ class JobView; class Job; + class JobViewDialog : public TableDialog { public: @@ -35,7 +36,7 @@ public: private: void periodic (); - JobView* _view; + JobView* _view = nullptr; std::weak_ptr _job; std::shared_ptr _timer; }; diff --git a/src/wx/kdm_output_panel.cc b/src/wx/kdm_output_panel.cc index 8c7f4007b..92aa86bf3 100644 --- a/src/wx/kdm_output_panel.cc +++ b/src/wx/kdm_output_panel.cc @@ -49,7 +49,7 @@ using std::list; using std::exception; using std::make_pair; using std::shared_ptr; -using boost::function; +using std::function; #if BOOST_VERSION >= 106100 using namespace boost::placeholders; #endif diff --git a/src/wx/kdm_output_panel.h b/src/wx/kdm_output_panel.h index cc4453d02..b01913354 100644 --- a/src/wx/kdm_output_panel.h +++ b/src/wx/kdm_output_panel.h @@ -54,7 +54,7 @@ public: std::pair, int> make ( std::list screen_kdms, std::string name, - boost::function confirm_overwrite + std::function confirm_overwrite ); private: diff --git a/src/wx/nag_dialog.cc b/src/wx/nag_dialog.cc index 1fb15f2d0..edaf8f83f 100644 --- a/src/wx/nag_dialog.cc +++ b/src/wx/nag_dialog.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2017-2018 Carl Hetherington + Copyright (C) 2017-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,11 +18,13 @@ */ + #include "nag_dialog.h" #include "wx_util.h" #include "static_text.h" #include "check_box.h" + using std::shared_ptr; #if BOOST_VERSION >= 106100 using namespace boost::placeholders; @@ -48,7 +50,7 @@ NagDialog::NagDialog (wxWindow* parent, Config::Nag nag, wxString message, bool if (can_cancel) { flags |= wxCANCEL; } - wxSizer* buttons = CreateSeparatedButtonSizer (flags); + auto buttons = CreateSeparatedButtonSizer (flags); if (buttons) { sizer->Add(buttons, wxSizerFlags().Expand().DoubleBorder()); } @@ -61,12 +63,14 @@ NagDialog::NagDialog (wxWindow* parent, Config::Nag nag, wxString message, bool sizer->SetSizeHints (this); } + void NagDialog::shut_up (wxCommandEvent& ev) { Config::instance()->set_nagged (_nag, ev.IsChecked()); } + /** @return true if the user clicked Cancel */ bool NagDialog::maybe_nag (wxWindow* parent, Config::Nag nag, wxString message, bool can_cancel) diff --git a/src/wx/nag_dialog.h b/src/wx/nag_dialog.h index bc5ae6962..11fb907f0 100644 --- a/src/wx/nag_dialog.h +++ b/src/wx/nag_dialog.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2017 Carl Hetherington + Copyright (C) 2017-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,12 +18,14 @@ */ + #include "lib/config.h" #include "lib/warnings.h" DCPOMATIC_DISABLE_WARNINGS #include DCPOMATIC_ENABLE_WARNINGS + class NagDialog : public wxDialog { public: diff --git a/src/wx/player_config_dialog.cc b/src/wx/player_config_dialog.cc index 557e6b8e7..802ab6b3b 100644 --- a/src/wx/player_config_dialog.cc +++ b/src/wx/player_config_dialog.cc @@ -63,7 +63,7 @@ using std::make_pair; using std::map; using boost::bind; using std::shared_ptr; -using boost::function; +using std::function; using boost::optional; #if BOOST_VERSION >= 106100 using namespace boost::placeholders; diff --git a/src/wx/suspender.cc b/src/wx/suspender.cc index 88128874c..7680c147b 100644 --- a/src/wx/suspender.cc +++ b/src/wx/suspender.cc @@ -22,9 +22,8 @@ #include "suspender.h" -Suspender::Suspender(boost::function handler) +Suspender::Suspender(std::function handler) : _handler (handler) - , _count (0) { } diff --git a/src/wx/suspender.h b/src/wx/suspender.h index 947d7a367..e01888823 100644 --- a/src/wx/suspender.h +++ b/src/wx/suspender.h @@ -19,14 +19,14 @@ */ -#include +#include #include class Suspender { public: - Suspender (boost::function handler); + Suspender (std::function handler); bool check (int property); @@ -47,7 +47,7 @@ private: void increment (); void decrement (); - boost::function _handler; - int _count; + std::function _handler; + int _count = 0; std::set _pending; }; diff --git a/src/wx/wx_util.h b/src/wx/wx_util.h index 97ddd5151..1c459595e 100644 --- a/src/wx/wx_util.h +++ b/src/wx/wx_util.h @@ -34,7 +34,6 @@ DCPOMATIC_DISABLE_WARNINGS #include DCPOMATIC_ENABLE_WARNINGS #include -#include #include #include diff --git a/test/audio_merger_test.cc b/test/audio_merger_test.cc index 4472f02c1..3a677bf82 100644 --- a/test/audio_merger_test.cc +++ b/test/audio_merger_test.cc @@ -33,7 +33,6 @@ #include #include #include -#include #include #include diff --git a/test/data b/test/data index 3596fb230..1ba6c3a1d 160000 --- a/test/data +++ b/test/data @@ -1 +1 @@ -Subproject commit 3596fb230c71b820ee5ced44d08d76a4ca3821d1 +Subproject commit 1ba6c3a1d4b3b507ef868aaacf9fa0383a7f22a9 diff --git a/test/ffmpeg_examiner_test.cc b/test/ffmpeg_examiner_test.cc index 9c3311719..73e73cbad 100644 --- a/test/ffmpeg_examiner_test.cc +++ b/test/ffmpeg_examiner_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2014 Carl Hetherington + Copyright (C) 2013-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,42 +18,48 @@ */ + /** @file test/ffmpeg_examiner_test.cc * @brief FFmpegExaminer tests * @ingroup selfcontained */ + #include #include "lib/ffmpeg_examiner.h" #include "lib/ffmpeg_content.h" #include "lib/ffmpeg_audio_stream.h" #include "test.h" + +using std::make_shared; using std::shared_ptr; using namespace dcpomatic; + /** Check that the FFmpegExaminer can extract the first video and audio time * correctly from data/count300bd24.m2ts. */ BOOST_AUTO_TEST_CASE (ffmpeg_examiner_test) { - shared_ptr film = new_test_film ("ffmpeg_examiner_test"); - shared_ptr content (new FFmpegContent ("test/data/count300bd24.m2ts")); - shared_ptr examiner (new FFmpegExaminer (content)); + auto film = new_test_film ("ffmpeg_examiner_test"); + auto content = make_shared("test/data/count300bd24.m2ts"); + auto examiner = make_shared(content); BOOST_CHECK_EQUAL (examiner->first_video().get().get(), ContentTime::from_seconds(600).get()); BOOST_CHECK_EQUAL (examiner->audio_streams().size(), 1U); BOOST_CHECK_EQUAL (examiner->audio_streams()[0]->first_audio.get().get(), ContentTime::from_seconds(600).get()); } + /** Check that audio sampling rate and channel counts are correctly picked up from * a problematic file. When we used to specify analyzeduration and probesize * this file's details were picked up incorrectly. */ BOOST_AUTO_TEST_CASE (ffmpeg_examiner_probesize_test) { - shared_ptr content (new FFmpegContent(TestPaths::private_data() / "RockyTop10 Playlist Flat.m4v")); - shared_ptr examiner (new FFmpegExaminer(content)); + auto content = make_shared(TestPaths::private_data() / "RockyTop10 Playlist Flat.m4v"); + auto examiner = make_shared(content); BOOST_CHECK_EQUAL (examiner->audio_streams().size(), 2U); BOOST_CHECK_EQUAL (examiner->audio_streams()[0]->frame_rate(), 48000); diff --git a/test/reels_test.cc b/test/reels_test.cc index a37e14067..5bb119f46 100644 --- a/test/reels_test.cc +++ b/test/reels_test.cc @@ -45,7 +45,7 @@ using std::vector; using std::string; using std::shared_ptr; using std::make_shared; -using boost::function; +using std::function; using namespace dcpomatic; diff --git a/test/required_disk_space_test.cc b/test/required_disk_space_test.cc index 5510864d9..cad2e2ee5 100644 --- a/test/required_disk_space_test.cc +++ b/test/required_disk_space_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Carl Hetherington + Copyright (C) 2016-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,20 +18,24 @@ */ + /** @file test/required_disk_space_test.cc * @brief Check Film::required_disk_space * @ingroup selfcontained */ + #include "lib/content_factory.h" #include "lib/dcp_content.h" #include "lib/film.h" #include "test.h" #include + +using std::dynamic_pointer_cast; using std::make_shared; using std::shared_ptr; -using std::dynamic_pointer_cast; + void check_within_n (int64_t a, int64_t b, int64_t n) { diff --git a/test/util_test.cc b/test/util_test.cc index a46337ab7..67c1a5265 100644 --- a/test/util_test.cc +++ b/test/util_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2019 Carl Hetherington + Copyright (C) 2012-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,11 +18,13 @@ */ + /** @file test/util_test.cc * @brief Test various utility methods. * @ingroup selfcontained */ + #include "lib/util.h" #include "lib/cross.h" #include "lib/exceptions.h" @@ -31,15 +33,17 @@ #include #include -using std::string; -using std::vector; + using std::list; using std::shared_ptr; +using std::string; +using std::vector; #if BOOST_VERSION >= 106100 using namespace boost::placeholders; #endif using namespace dcpomatic; + BOOST_AUTO_TEST_CASE (digest_head_tail_test) { vector p; @@ -61,27 +65,30 @@ BOOST_AUTO_TEST_CASE (digest_head_tail_test) BOOST_CHECK_THROW (digest_head_tail (p, 1024), OpenFileError); } + BOOST_AUTO_TEST_CASE (timecode_test) { - DCPTime t = DCPTime::from_seconds (2 * 60 * 60 + 4 * 60 + 31) + DCPTime::from_frames (19, 24); + auto t = DCPTime::from_seconds (2 * 60 * 60 + 4 * 60 + 31) + DCPTime::from_frames (19, 24); BOOST_CHECK_EQUAL (t.timecode (24), "02:04:31:19"); } + BOOST_AUTO_TEST_CASE (seconds_to_approximate_hms_test) { - BOOST_CHECK_EQUAL (seconds_to_approximate_hms (1), "1s"); - BOOST_CHECK_EQUAL (seconds_to_approximate_hms (2), "2s"); - BOOST_CHECK_EQUAL (seconds_to_approximate_hms (60), "1m"); - BOOST_CHECK_EQUAL (seconds_to_approximate_hms (1.5 * 60), "1m 30s"); - BOOST_CHECK_EQUAL (seconds_to_approximate_hms (2 * 60), "2m"); - BOOST_CHECK_EQUAL (seconds_to_approximate_hms (17 * 60 + 20), "17m"); - BOOST_CHECK_EQUAL (seconds_to_approximate_hms (1 * 3600), "1h"); - BOOST_CHECK_EQUAL (seconds_to_approximate_hms (3600 + 40 * 60), "1h 40m"); - BOOST_CHECK_EQUAL (seconds_to_approximate_hms (2 * 3600), "2h"); - BOOST_CHECK_EQUAL (seconds_to_approximate_hms (2 * 3600 - 1), "2h"); - BOOST_CHECK_EQUAL (seconds_to_approximate_hms (13 * 3600 + 40 * 60), "14h"); + BOOST_CHECK_EQUAL (seconds_to_approximate_hms(1), "1s"); + BOOST_CHECK_EQUAL (seconds_to_approximate_hms(2), "2s"); + BOOST_CHECK_EQUAL (seconds_to_approximate_hms(60), "1m"); + BOOST_CHECK_EQUAL (seconds_to_approximate_hms(1.5 * 60), "1m 30s"); + BOOST_CHECK_EQUAL (seconds_to_approximate_hms(2 * 60), "2m"); + BOOST_CHECK_EQUAL (seconds_to_approximate_hms(17 * 60 + 20), "17m"); + BOOST_CHECK_EQUAL (seconds_to_approximate_hms(1 * 3600), "1h"); + BOOST_CHECK_EQUAL (seconds_to_approximate_hms(3600 + 40 * 60), "1h 40m"); + BOOST_CHECK_EQUAL (seconds_to_approximate_hms(2 * 3600), "2h"); + BOOST_CHECK_EQUAL (seconds_to_approximate_hms(2 * 3600 - 1), "2h"); + BOOST_CHECK_EQUAL (seconds_to_approximate_hms(13 * 3600 + 40 * 60), "14h"); } + BOOST_AUTO_TEST_CASE (time_to_hmsf_test) { BOOST_CHECK_EQUAL (time_to_hmsf(DCPTime::from_frames(12, 24), 24), "0:00:00.12"); @@ -91,6 +98,7 @@ BOOST_AUTO_TEST_CASE (time_to_hmsf_test) BOOST_CHECK_EQUAL (time_to_hmsf(DCPTime::from_seconds(2 * 60 * 60 + 92), 24), "2:01:32.0"); } + BOOST_AUTO_TEST_CASE (tidy_for_filename_test) { BOOST_CHECK_EQUAL (tidy_for_filename ("fish\\chips"), "fish_chips"); @@ -99,6 +107,7 @@ BOOST_AUTO_TEST_CASE (tidy_for_filename_test) BOOST_CHECK_EQUAL (tidy_for_filename ("abcdefghï"), "abcdefghï"); } + BOOST_AUTO_TEST_CASE (utf8_strlen_test) { BOOST_CHECK_EQUAL (utf8_strlen("hello world"), 11U); @@ -106,6 +115,7 @@ BOOST_AUTO_TEST_CASE (utf8_strlen_test) BOOST_CHECK_EQUAL (utf8_strlen("hëłlo wørld"), 11U); } + BOOST_AUTO_TEST_CASE (careful_string_filter_test) { BOOST_CHECK_EQUAL ("hello_world", careful_string_filter("hello_world")); @@ -116,6 +126,7 @@ BOOST_AUTO_TEST_CASE (careful_string_filter_test) BOOST_CHECK_EQUAL ("hello_world_CcGgIOoSsUu", careful_string_filter("hello_world_ÇçĞğİÖöŞşÜü")); } + static list progress_values; static void @@ -124,6 +135,7 @@ progress (float p) progress_values.push_back (p); } + BOOST_AUTO_TEST_CASE (copy_in_bits_test) { for (int i = 0; i < 32; ++i) {