From 78ca79cde19db630b1abfe8f00f49e87bb7e4068 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 20 Dec 2021 00:35:11 +0100 Subject: Fix a load of stuff that wasn't being freed on close. Nothing really that important, but it cleans up the valgrind leak check reports. --- src/lib/cinema_sound_processor.cc | 37 +++++++++++-------------------------- 1 file changed, 11 insertions(+), 26 deletions(-) (limited to 'src/lib/cinema_sound_processor.cc') diff --git a/src/lib/cinema_sound_processor.cc b/src/lib/cinema_sound_processor.cc index 1eaf8e1fc..434fdd1cf 100644 --- a/src/lib/cinema_sound_processor.cc +++ b/src/lib/cinema_sound_processor.cc @@ -36,7 +36,7 @@ using namespace std; -vector CinemaSoundProcessor::_cinema_sound_processors; +vector> CinemaSoundProcessor::_cinema_sound_processors; /** @param i Our id. @@ -57,7 +57,11 @@ CinemaSoundProcessor::CinemaSoundProcessor (string i, string n, float knee, floa vector CinemaSoundProcessor::all () { - return _cinema_sound_processors; + vector raw; + for (auto& processor: _cinema_sound_processors) { + raw.push_back (processor.get()); + } + return raw; } @@ -67,9 +71,9 @@ CinemaSoundProcessor::all () 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)); } @@ -88,26 +92,7 @@ CinemaSoundProcessor::from_id (string id) return nullptr; } - return *i; -} - - -/** @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; + return i->get(); } @@ -118,7 +103,7 @@ CinemaSoundProcessor const * CinemaSoundProcessor::from_index (int i) { DCPOMATIC_ASSERT (i >= 0 && i < int(_cinema_sound_processors.size())); - return _cinema_sound_processors[i]; + return _cinema_sound_processors[i].get(); } -- cgit v1.2.3