diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-01-07 23:22:48 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-01-07 23:23:08 +0100 |
| commit | 2ac6688e4e75ff26db9208e760966bd071dcc48f (patch) | |
| tree | b07e8890c13c23b7d3a05274965029697f4fc4dc | |
| parent | 89d4090c6b1bdf889c2302b92e1f4bf33cf7cf05 (diff) | |
C++11 tidying.
| -rw-r--r-- | src/lib/dcp_content.cc | 20 | ||||
| -rw-r--r-- | src/lib/decoder_factory.cc | 58 | ||||
| -rw-r--r-- | src/lib/ffmpeg_decoder.cc | 2 | ||||
| -rw-r--r-- | src/tools/dcpomatic.cc | 2 | ||||
| -rw-r--r-- | src/tools/dcpomatic_playlist.cc | 2 | ||||
| -rw-r--r-- | src/wx/job_view.cc | 13 | ||||
| -rw-r--r-- | src/wx/playlist_controls.cc | 48 |
7 files changed, 77 insertions, 68 deletions
diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc index de71c1257..d72c0c43d 100644 --- a/src/lib/dcp_content.cc +++ b/src/lib/dcp_content.cc @@ -20,19 +20,19 @@ #include "atmos_content.h" -#include "dcp_content.h" -#include "video_content.h" #include "audio_content.h" -#include "dcp_examiner.h" -#include "job.h" -#include "film.h" -#include "config.h" -#include "overlaps.h" #include "compose.hpp" +#include "config.h" +#include "dcp_content.h" #include "dcp_decoder.h" -#include "log.h" +#include "dcp_examiner.h" #include "dcpomatic_log.h" +#include "film.h" +#include "job.h" +#include "log.h" +#include "overlaps.h" #include "text_content.h" +#include "video_content.h" #include <dcp/dcp.h> #include <dcp/raw_convert.h> #include <dcp/exceptions.h> @@ -690,7 +690,7 @@ DCPContent::can_reference_audio (shared_ptr<const Film> film, string& why_not) c { shared_ptr<DCPDecoder> decoder; try { - decoder.reset (new DCPDecoder (film, shared_from_this(), false, film->tolerant(), shared_ptr<DCPDecoder>())); + decoder = make_shared<DCPDecoder>(film, shared_from_this(), false, film->tolerant(), shared_ptr<DCPDecoder>()); } catch (dcp::ReadError &) { /* We couldn't read the DCP, so it's probably missing */ return false; @@ -725,7 +725,7 @@ DCPContent::can_reference_text (shared_ptr<const Film> film, TextType type, stri { shared_ptr<DCPDecoder> decoder; try { - decoder.reset (new DCPDecoder (film, shared_from_this(), false, film->tolerant(), shared_ptr<DCPDecoder>())); + decoder = make_shared<DCPDecoder>(film, shared_from_this(), false, film->tolerant(), shared_ptr<DCPDecoder>()); } catch (dcp::ReadError &) { /* We couldn't read the DCP, so it's probably missing */ return false; diff --git a/src/lib/decoder_factory.cc b/src/lib/decoder_factory.cc index 1acef6f4f..cb17d27d1 100644 --- a/src/lib/decoder_factory.cc +++ b/src/lib/decoder_factory.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2016-2020 Carl Hetherington <cth@carlh.net> + Copyright (C) 2016-2022 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,82 +18,86 @@ */ + #include "atmos_mxf_content.h" #include "atmos_mxf_decoder.h" -#include "ffmpeg_content.h" -#include "ffmpeg_decoder.h" #include "dcp_content.h" #include "dcp_decoder.h" +#include "dcp_subtitle_content.h" +#include "dcp_subtitle_decoder.h" +#include "ffmpeg_content.h" +#include "ffmpeg_decoder.h" #include "image_content.h" #include "image_decoder.h" #include "string_text_file_content.h" #include "string_text_file_decoder.h" -#include "dcp_subtitle_content.h" -#include "dcp_subtitle_decoder.h" +#include "timer.h" #include "video_mxf_content.h" #include "video_mxf_decoder.h" -#include "timer.h" + +using std::dynamic_pointer_cast; using std::list; +using std::make_shared; using std::shared_ptr; -using std::dynamic_pointer_cast; + template <class T> shared_ptr<T> maybe_cast (shared_ptr<Decoder> d) { if (!d) { - return shared_ptr<T> (); + return {}; } return dynamic_pointer_cast<T> (d); } -/** - @param tolerant true to proceed in the face of `survivable' errors, otherwise false. - @param old_decoder A `used' decoder that has been previously made for this piece of content, or 0 + +/** @param tolerant true to proceed in the face of `survivable' errors, otherwise false. + * @param old_decoder A `used' decoder that has been previously made for this piece of content, or 0 */ shared_ptr<Decoder> decoder_factory (shared_ptr<const Film> film, shared_ptr<const Content> content, bool fast, bool tolerant, shared_ptr<Decoder> old_decoder) { - shared_ptr<const FFmpegContent> fc = dynamic_pointer_cast<const FFmpegContent> (content); + auto fc = dynamic_pointer_cast<const FFmpegContent>(content); if (fc) { - return shared_ptr<Decoder> (new FFmpegDecoder(film, fc, fast)); + return make_shared<FFmpegDecoder>(film, fc, fast); } - shared_ptr<const DCPContent> dc = dynamic_pointer_cast<const DCPContent> (content); + auto dc = dynamic_pointer_cast<const DCPContent>(content); if (dc) { try { - return shared_ptr<Decoder> (new DCPDecoder(film, dc, fast, tolerant, maybe_cast<DCPDecoder>(old_decoder))); + return make_shared<DCPDecoder>(film, dc, fast, tolerant, maybe_cast<DCPDecoder>(old_decoder)); } catch (KDMError& e) { /* This will be found and reported to the user when the content is examined */ - return shared_ptr<Decoder>(); + return {}; } } - shared_ptr<const ImageContent> ic = dynamic_pointer_cast<const ImageContent> (content); + auto ic = dynamic_pointer_cast<const ImageContent>(content); if (ic) { - return shared_ptr<Decoder> (new ImageDecoder(film, ic)); + return make_shared<ImageDecoder>(film, ic); } - shared_ptr<const StringTextFileContent> rc = dynamic_pointer_cast<const StringTextFileContent> (content); + auto rc = dynamic_pointer_cast<const StringTextFileContent>(content); if (rc) { - return shared_ptr<Decoder> (new StringTextFileDecoder(film, rc)); + return make_shared<StringTextFileDecoder>(film, rc); } - shared_ptr<const DCPSubtitleContent> dsc = dynamic_pointer_cast<const DCPSubtitleContent> (content); + auto dsc = dynamic_pointer_cast<const DCPSubtitleContent> (content); if (dsc) { - return shared_ptr<Decoder> (new DCPSubtitleDecoder(film, dsc)); + return make_shared<DCPSubtitleDecoder>(film, dsc); } - shared_ptr<const VideoMXFContent> vmc = dynamic_pointer_cast<const VideoMXFContent> (content); + auto vmc = dynamic_pointer_cast<const VideoMXFContent> (content); if (vmc) { - return shared_ptr<Decoder> (new VideoMXFDecoder(film, vmc)); + return make_shared<VideoMXFDecoder>(film, vmc); } - shared_ptr<const AtmosMXFContent> amc = dynamic_pointer_cast<const AtmosMXFContent> (content); + auto amc = dynamic_pointer_cast<const AtmosMXFContent> (content); if (amc) { - return shared_ptr<Decoder> (new AtmosMXFDecoder(film, amc)); + return make_shared<AtmosMXFDecoder>(film, amc); } - return shared_ptr<Decoder> (); + return {}; } diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index ea961a894..8e34de095 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -144,7 +144,7 @@ FFmpegDecoder::flush () auto const f = full_length.frames_round (vfr); auto v = video->position(film()).get_value_or(ContentTime()).frames_round(vfr) + 1; while (v < f) { - video->emit (film(), shared_ptr<const ImageProxy> (new RawImageProxy (_black_image)), v); + video->emit (film(), make_shared<const RawImageProxy>(_black_image), v); ++v; } } diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index 27df23ef0..459832963 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -615,7 +615,7 @@ private: int const r = d->ShowModal (); if (r == wxID_OK && d->check_path() && maybe_save_film<FilmChangedDuplicatingDialog>()) { - shared_ptr<Film> film (new Film (d->path())); + auto film = make_shared<Film>(d->path()); film->copy_from (_film); film->set_name (d->path().filename().generic_string()); film->write_metadata (); diff --git a/src/tools/dcpomatic_playlist.cc b/src/tools/dcpomatic_playlist.cc index 6f06c0624..d80d13903 100644 --- a/src/tools/dcpomatic_playlist.cc +++ b/src/tools/dcpomatic_playlist.cc @@ -206,7 +206,7 @@ private: void new_playlist () { - shared_ptr<SignalSPL> spl (new SignalSPL(wx_to_std(_("New Playlist")))); + auto spl = make_shared<SignalSPL>(wx_to_std(_("New Playlist"))); add_playlist_to_model (spl); add_playlist_to_view (spl); _list->SetItemState (_list->GetItemCount() - 1, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); diff --git a/src/wx/job_view.cc b/src/wx/job_view.cc index 06d10401f..a8db39751 100644 --- a/src/wx/job_view.cc +++ b/src/wx/job_view.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2019 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2022 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -25,20 +25,21 @@ #include "static_text.h" #include "check_box.h" #include "dcpomatic_button.h" -#include "lib/job.h" -#include "lib/job_manager.h" +#include "lib/analyse_audio_job.h" #include "lib/compose.hpp" #include "lib/config.h" +#include "lib/job.h" +#include "lib/job_manager.h" #include "lib/send_notification_email_job.h" #include "lib/transcode_job.h" -#include "lib/analyse_audio_job.h" #include <wx/wx.h> #include <boost/algorithm/string.hpp> -using std::string; +using std::make_shared; using std::min; using std::shared_ptr; +using std::string; using boost::bind; @@ -166,7 +167,7 @@ JobView::finished () string body = Config::instance()->notification_email(); boost::algorithm::replace_all (body, "$JOB_NAME", _job->name()); boost::algorithm::replace_all (body, "$JOB_STATUS", _job->status()); - JobManager::instance()->add_after (_job, shared_ptr<Job> (new SendNotificationEmailJob (body))); + JobManager::instance()->add_after(_job, make_shared<SendNotificationEmailJob>(body)); } } } diff --git a/src/wx/playlist_controls.cc b/src/wx/playlist_controls.cc index 3be47ad97..31bebdb06 100644 --- a/src/wx/playlist_controls.cc +++ b/src/wx/playlist_controls.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2018-2020 Carl Hetherington <cth@carlh.net> + Copyright (C) 2018-2022 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,33 +18,37 @@ */ -#include "playlist_controls.h" -#include "film_viewer.h" -#include "wx_util.h" + #include "content_view.h" #include "dcpomatic_button.h" +#include "film_viewer.h" +#include "playlist_controls.h" #include "static_text.h" -#include "lib/player_video.h" -#include "lib/dcp_content.h" +#include "wx_util.h" +#include "lib/compose.hpp" #include "lib/cross.h" -#include "lib/scoped_temporary.h" -#include "lib/internet.h" +#include "lib/dcp_content.h" #include "lib/ffmpeg_content.h" -#include "lib/compose.hpp" -#include <dcp/raw_convert.h> +#include "lib/internet.h" +#include "lib/player_video.h" +#include "lib/scoped_temporary.h" #include <dcp/exceptions.h> +#include <dcp/raw_convert.h> #include <wx/listctrl.h> #include <wx/progdlg.h> -using std::string; + using std::cout; +using std::dynamic_pointer_cast; using std::exception; -using std::sort; +using std::make_shared; using std::shared_ptr; -using std::dynamic_pointer_cast; +using std::sort; +using std::string; using boost::optional; using namespace dcpomatic; + PlaylistControls::PlaylistControls (wxWindow* parent, shared_ptr<FilmViewer> viewer) : Controls (parent, viewer, false) , _play_button (new Button(this, _("Play"))) @@ -62,13 +66,13 @@ PlaylistControls::PlaylistControls (wxWindow* parent, shared_ptr<FilmViewer> vie _spl_view = new wxListCtrl (this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_NO_HEADER); _spl_view->AppendColumn (wxT(""), wxLIST_FORMAT_LEFT, 740); - wxBoxSizer* left_sizer = new wxBoxSizer (wxVERTICAL); - wxBoxSizer* e_sizer = new wxBoxSizer (wxHORIZONTAL); + auto left_sizer = new wxBoxSizer (wxVERTICAL); + auto e_sizer = new wxBoxSizer (wxHORIZONTAL); wxFont subheading_font (*wxNORMAL_FONT); subheading_font.SetWeight (wxFONTWEIGHT_BOLD); - wxBoxSizer* spl_header = new wxBoxSizer (wxHORIZONTAL); + auto spl_header = new wxBoxSizer (wxHORIZONTAL); { wxStaticText* m = new StaticText (this, "Playlists"); m->SetFont (subheading_font); @@ -82,7 +86,7 @@ PlaylistControls::PlaylistControls (wxWindow* parent, shared_ptr<FilmViewer> vie _content_view = new ContentView (this); - wxBoxSizer* content_header = new wxBoxSizer (wxHORIZONTAL); + auto content_header = new wxBoxSizer (wxHORIZONTAL); { wxStaticText* m = new StaticText (this, "Content"); m->SetFont (subheading_font); @@ -142,7 +146,7 @@ PlaylistControls::deselect_playlist () _selected_playlist = boost::none; _spl_view->SetItemState (selected, 0, wxLIST_STATE_SELECTED); } - ResetFilm (shared_ptr<Film>(new Film(optional<boost::filesystem::path>()))); + ResetFilm (std::make_shared<Film>(optional<boost::filesystem::path>())); } void @@ -293,9 +297,9 @@ optional<dcp::EncryptedKDM> PlaylistControls::get_kdm_from_directory (shared_ptr<DCPContent> dcp) { using namespace boost::filesystem; - optional<path> kdm_dir = Config::instance()->player_kdm_directory(); + auto kdm_dir = Config::instance()->player_kdm_directory(); if (!kdm_dir) { - return optional<dcp::EncryptedKDM>(); + return {}; } for (directory_iterator i = directory_iterator(*kdm_dir); i != directory_iterator(); ++i) { try { @@ -343,7 +347,7 @@ PlaylistControls::select_playlist (int selected, int position) for (auto const& i: _playlists[selected].get()) { dialog.Pulse (); - shared_ptr<DCPContent> dcp = dynamic_pointer_cast<DCPContent> (i.content); + auto dcp = dynamic_pointer_cast<DCPContent> (i.content); if (dcp && dcp->needs_kdm()) { optional<dcp::EncryptedKDM> kdm; kdm = get_kdm_from_directory (dcp); @@ -388,7 +392,7 @@ void PlaylistControls::reset_film () { DCPOMATIC_ASSERT (_selected_playlist); - shared_ptr<Film> film (new Film(optional<boost::filesystem::path>())); + auto film = std::make_shared<Film>(optional<boost::filesystem::path>()); film->add_content (_playlists[*_selected_playlist].get()[_selected_playlist_position].content); ResetFilm (film); } |
