blob: 0b00ee2ee237f90a9d056e17e3cd92fc3a095b9f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
/*
Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
DCP-o-matic is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
DCP-o-matic is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file src/sound_processor.cc
* @brief CinemaSoundProcessor class.
*/
#include "cinema_sound_processor.h"
#include "dolby_cp750.h"
#include "dcpomatic_assert.h"
#include <iostream>
#include <cassert>
using namespace std;
vector<CinemaSoundProcessor const *> CinemaSoundProcessor::_cinema_sound_processors;
/** @param i Our id.
* @param n User-visible name.
*/
CinemaSoundProcessor::CinemaSoundProcessor (string i, string n)
: _id (i)
, _name (n)
{
}
/** @return All available sound processors */
vector<CinemaSoundProcessor const *>
CinemaSoundProcessor::all ()
{
return _cinema_sound_processors;
}
/** 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);
}
/** @param id One of our ids.
* @return Corresponding sound processor, or 0.
*/
CinemaSoundProcessor const *
CinemaSoundProcessor::from_id (string id)
{
vector<CinemaSoundProcessor const *>::iterator i = _cinema_sound_processors.begin ();
while (i != _cinema_sound_processors.end() && (*i)->id() != id) {
++i;
}
if (i == _cinema_sound_processors.end ()) {
return 0;
}
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<CinemaSoundProcessor*>::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.
*/
CinemaSoundProcessor const *
CinemaSoundProcessor::from_index (int i)
{
DCPOMATIC_ASSERT (i <= int(_cinema_sound_processors.size ()));
return _cinema_sound_processors[i];
}
|