X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fcinema_sound_processor.cc;h=434fdd1cf6628ae92d79c95cb663c63c5a5390a0;hb=7f6cc5c6e151c32fce94181689cf740a011feafb;hp=1a3ba5a0f0af61fcd9b9d412a4b6111e4ffc82ca;hpb=e6c828cbd577239e7c8e4c532161084a33843a0f;p=dcpomatic.git diff --git a/src/lib/cinema_sound_processor.cc b/src/lib/cinema_sound_processor.cc index 1a3ba5a0f..434fdd1cf 100644 --- a/src/lib/cinema_sound_processor.cc +++ b/src/lib/cinema_sound_processor.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2014 Carl Hetherington + Copyright (C) 2012-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,10 +18,12 @@ */ + /** @file src/sound_processor.cc * @brief CinemaSoundProcessor class. */ + #include "cinema_sound_processor.h" #include "dolby_cp750.h" #include "usl.h" @@ -30,9 +32,12 @@ #include #include + using namespace std; -vector CinemaSoundProcessor::_cinema_sound_processors; + +vector> CinemaSoundProcessor::_cinema_sound_processors; + /** @param i Our id. * @param n User-visible name. @@ -47,59 +52,49 @@ CinemaSoundProcessor::CinemaSoundProcessor (string i, string n, float knee, floa } + /** @return All available sound processors */ vector CinemaSoundProcessor::all () { - return _cinema_sound_processors; + vector raw; + for (auto& processor: _cinema_sound_processors) { + raw.push_back (processor.get()); + } + return raw; } + /** Set up the static _sound_processors vector; must be called before from_* * methods are used. */ void CinemaSoundProcessor::setup_cinema_sound_processors () { - _cinema_sound_processors.push_back (new DolbyCP750); - _cinema_sound_processors.push_back (new USL); - _cinema_sound_processors.push_back (new DatasatAP2x); + _cinema_sound_processors.push_back (unique_ptr(new DolbyCP750)); + _cinema_sound_processors.push_back (unique_ptr(new USL)); + _cinema_sound_processors.push_back (unique_ptr(new DatasatAP2x)); } + /** @param id One of our ids. * @return Corresponding sound processor, or 0. */ CinemaSoundProcessor const * CinemaSoundProcessor::from_id (string id) { - vector::iterator i = _cinema_sound_processors.begin (); + auto i = _cinema_sound_processors.begin (); while (i != _cinema_sound_processors.end() && (*i)->id() != id) { ++i; } if (i == _cinema_sound_processors.end ()) { - return 0; + return nullptr; } - return *i; + return i->get(); } -/** @param s A sound processor from our static list. - * @return Index of the sound processor with the list, or -1. - */ -int -CinemaSoundProcessor::as_index (CinemaSoundProcessor const * s) -{ - vector::size_type i = 0; - while (i < _cinema_sound_processors.size() && _cinema_sound_processors[i] != s) { - ++i; - } - - if (i == _cinema_sound_processors.size ()) { - return -1; - } - - return i; -} /** @param i An index returned from as_index(). * @return Corresponding sound processor. @@ -107,10 +102,11 @@ CinemaSoundProcessor::as_index (CinemaSoundProcessor const * s) CinemaSoundProcessor const * CinemaSoundProcessor::from_index (int i) { - DCPOMATIC_ASSERT (i <= int(_cinema_sound_processors.size ())); - return _cinema_sound_processors[i]; + DCPOMATIC_ASSERT (i >= 0 && i < int(_cinema_sound_processors.size())); + return _cinema_sound_processors[i].get(); } + float CinemaSoundProcessor::db_for_fader_change (float from, float to) const {