Change end() to only do one thing, and copy the required stuff into pause()
[dcpomatic.git] / src / lib / audio_mapping.cc
index 74b33aa358c5e79ae8cbfc4ebef53def0abd9ca5..6e8c4e30d3641f04cfa96c3961155d4f7168da2f 100644 (file)
@@ -24,6 +24,7 @@
 #include "constants.h"
 #include "dcpomatic_assert.h"
 #include "digester.h"
+#include "util.h"
 #include <dcp/raw_convert.h>
 #include <dcp/warnings.h>
 #include <libcxml/cxml.h>
@@ -169,8 +170,8 @@ AudioMapping::AudioMapping (cxml::ConstNodePtr node, int state_version)
                                        );
                        } else {
                                set (
-                                       i->number_attribute<int>("Input"),
-                                       i->number_attribute<int>("Output"),
+                                       number_attribute<int>(i, "Input", "input"),
+                                       number_attribute<int>(i, "Output", "output"),
                                        raw_convert<float>(i->content())
                                        );
                        }
@@ -230,8 +231,8 @@ AudioMapping::as_xml (xmlpp::Node* node) const
        for (int c = 0; c < input; ++c) {
                for (int d = 0; d < output; ++d) {
                        auto t = node->add_child ("Gain");
-                       t->set_attribute ("Input", raw_convert<string> (c));
-                       t->set_attribute ("Output", raw_convert<string> (d));
+                       t->set_attribute("input", raw_convert<string>(c));
+                       t->set_attribute("output", raw_convert<string>(d));
                        t->add_child_text (raw_convert<string> (get (c, d)));
                }
        }
@@ -288,3 +289,18 @@ AudioMapping::unmap_all ()
                }
        }
 }
+
+
+void
+AudioMapping::take_from(AudioMapping const& other)
+{
+       auto input = std::min(input_channels(), other.input_channels());
+       auto output = std::min(output_channels(), other.output_channels());
+
+       for (auto i = 0; i < input; ++i) {
+               for (auto o = 0; o < output; ++o) {
+                       set(i, o, other.get(i, o));
+               }
+       }
+}
+