13
0

Revert PinMapping Changes

This reverts
 * e48d97ed69
 * 98c906b733
 * 0cf73d459b

because the C++ API std::map:at can throw and exception
was not implemented (and also deemed excessive for the
case at hand). Also an explicit API for *p*plugin_pin
mapping is preferable and facilitates debugging.
This commit is contained in:
Robin Gareus 2024-09-03 13:20:48 +02:00
parent a9a5787399
commit e4d9344d2a
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
2 changed files with 24 additions and 10 deletions

View File

@ -333,10 +333,24 @@ private:
* which is known to be troublesome with Visual C++ :- * which is known to be troublesome with Visual C++ :-
* https://www.boost.org/doc/libs/1_65_0/libs/type_traits/doc/html/boost_typetraits/reference/aligned_storage.html * https://www.boost.org/doc/libs/1_65_0/libs/type_traits/doc/html/boost_typetraits/reference/aligned_storage.html
*/ */
typedef std::map <uint32_t, ARDOUR::ChanMapping> PinMappings; class PinMappings : public std::map <uint32_t, ARDOUR::ChanMapping>
#else #else
typedef std::map <uint32_t, ARDOUR::ChanMapping, std::less<uint32_t>, PBD::StackAllocator<std::pair<const uint32_t, ARDOUR::ChanMapping>, 4> > PinMappings; class PinMappings : public std::map <uint32_t, ARDOUR::ChanMapping, std::less<uint32_t>, PBD::StackAllocator<std::pair<const uint32_t, ARDOUR::ChanMapping>, 4> >
#endif #endif
{
public:
/* this emulates C++11's std::map::at()
* return mapping for given plugin instance */
inline ARDOUR::ChanMapping const& p (const uint32_t i) const {
#ifndef NDEBUG
const_iterator x = find (i);
assert (x != end ());
return x->second;
#else
return find(i)->second;
#endif
}
};
PinMappings _in_map; PinMappings _in_map;
PinMappings _out_map; PinMappings _out_map;

View File

@ -916,11 +916,11 @@ PluginInsert::connect_and_run (BufferSet& bufs, samplepos_t start, samplepos_t e
continue; continue;
} }
bool valid; bool valid;
uint32_t first_idx = in_map.at(0).get (*t, 0, &valid); uint32_t first_idx = in_map.p(0).get (*t, 0, &valid);
assert (valid && first_idx == 0); // check_inplace ensures this assert (valid && first_idx == 0); // check_inplace ensures this
/* copy the first stream's buffer contents to the others */ /* copy the first stream's buffer contents to the others */
for (uint32_t i = 1; i < natural_input_streams ().get (*t); ++i) { for (uint32_t i = 1; i < natural_input_streams ().get (*t); ++i) {
uint32_t idx = in_map.at(0).get (*t, i, &valid); uint32_t idx = in_map.p(0).get (*t, i, &valid);
if (valid) { if (valid) {
x_assert (idx, idx == 0); x_assert (idx, idx == 0);
bufs.get_available (*t, i).read_from (bufs.get_available (*t, first_idx), nframes, offset, offset); bufs.get_available (*t, i).read_from (bufs.get_available (*t, first_idx), nframes, offset, offset);
@ -1034,7 +1034,7 @@ PluginInsert::connect_and_run (BufferSet& bufs, samplepos_t start, samplepos_t e
for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) { for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
for (uint32_t out = 0; out < natural_output_streams().get (*t); ++out) { for (uint32_t out = 0; out < natural_output_streams().get (*t); ++out) {
bool valid; bool valid;
uint32_t out_idx = out_map.at(pc).get (*t, out, &valid); uint32_t out_idx = out_map.p(pc).get (*t, out, &valid);
if (valid) { if (valid) {
used_outputs.set (*t, out_idx, 1); // mark as used used_outputs.set (*t, out_idx, 1); // mark as used
} }
@ -1066,14 +1066,14 @@ PluginInsert::connect_and_run (BufferSet& bufs, samplepos_t start, samplepos_t e
for (Plugins::iterator i = _plugins.begin(); i != _plugins.end(); ++i, ++pc) { for (Plugins::iterator i = _plugins.begin(); i != _plugins.end(); ++i, ++pc) {
ARDOUR::ChanMapping i_in_map (natural_input_streams()); ARDOUR::ChanMapping i_in_map (natural_input_streams());
ARDOUR::ChanMapping i_out_map (out_map.at(pc)); ARDOUR::ChanMapping i_out_map (out_map.p(pc));
ARDOUR::ChanCount mapped; ARDOUR::ChanCount mapped;
/* map inputs sequentially */ /* map inputs sequentially */
for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) { for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
for (uint32_t in = 0; in < natural_input_streams().get (*t); ++in) { for (uint32_t in = 0; in < natural_input_streams().get (*t); ++in) {
bool valid; bool valid;
uint32_t in_idx = in_map.at(pc).get (*t, in, &valid); uint32_t in_idx = in_map.p(pc).get (*t, in, &valid);
uint32_t m = mapped.get (*t); uint32_t m = mapped.get (*t);
if (valid) { if (valid) {
inplace_bufs.get_available (*t, m).read_from (bufs.get_available (*t, in_idx), nframes, offset, offset); inplace_bufs.get_available (*t, m).read_from (bufs.get_available (*t, in_idx), nframes, offset, offset);
@ -1120,7 +1120,7 @@ PluginInsert::connect_and_run (BufferSet& bufs, samplepos_t start, samplepos_t e
/* in-place processing */ /* in-place processing */
uint32_t pc = 0; uint32_t pc = 0;
for (Plugins::iterator i = _plugins.begin(); i != _plugins.end(); ++i, ++pc) { for (Plugins::iterator i = _plugins.begin(); i != _plugins.end(); ++i, ++pc) {
if ((*i)->connect_and_run(bufs, start, end, speed, in_map.at(pc), out_map.at(pc), nframes, offset)) { if ((*i)->connect_and_run(bufs, start, end, speed, in_map.p(pc), out_map.p(pc), nframes, offset)) {
deactivate (); deactivate ();
} }
} }
@ -2608,9 +2608,9 @@ PluginInsert::state () const
for (uint32_t pc = 0; pc < get_count(); ++pc) { for (uint32_t pc = 0; pc < get_count(); ++pc) {
char tmp[128]; char tmp[128];
snprintf (tmp, sizeof(tmp), "InputMap-%d", pc); snprintf (tmp, sizeof(tmp), "InputMap-%d", pc);
node.add_child_nocopy (* _in_map.at (pc).state (tmp)); node.add_child_nocopy (* _in_map.p (pc).state (tmp));
snprintf (tmp, sizeof(tmp), "OutputMap-%d", pc); snprintf (tmp, sizeof(tmp), "OutputMap-%d", pc);
node.add_child_nocopy (* _out_map.at (pc).state (tmp)); node.add_child_nocopy (* _out_map.p (pc).state (tmp));
} }
node.add_child_nocopy (* _thru_map.state ("ThruMap")); node.add_child_nocopy (* _thru_map.state ("ThruMap"));