Cleanup: make things a little clearer.
[dcpomatic.git] / src / lib / audio_content.cc
index acd3b81b4295e817d54de91c9f3787b144b95886..bd857b313d418da8fcc674ee25f8abd3ed8f3221 100644 (file)
@@ -22,6 +22,7 @@
 #include "audio_content.h"
 #include "compose.hpp"
 #include "config.h"
+#include "constants.h"
 #include "exceptions.h"
 #include "film.h"
 #include "frame_rate_change.h"
@@ -312,7 +313,10 @@ AudioContent::add_properties (shared_ptr<const Film> film, list<UserProperty>& p
 
        if (stream) {
                p.push_back (UserProperty(UserProperty::AUDIO, _("Channels"), stream->channels()));
-               p.push_back (UserProperty(UserProperty::AUDIO, _("Content audio sample rate"), stream->frame_rate(), _("Hz")));
+               p.push_back (UserProperty(UserProperty::AUDIO, _("Content sample rate"), stream->frame_rate(), _("Hz")));
+               if (auto bits = stream->bit_depth()) {
+                       p.push_back(UserProperty(UserProperty::AUDIO, _("Content bit depth"), *bits, _("bits")));
+               }
        }
 
        FrameRateChange const frc (_parent->active_video_frame_rate(film), film->video_frame_rate());
@@ -401,13 +405,12 @@ AudioContent::take_settings_from (shared_ptr<const AudioContent> c)
        set_fade_in (c->fade_in());
        set_fade_out (c->fade_out());
 
-       size_t i = 0;
-       size_t j = 0;
+       auto const streams_to_take = std::min(_streams.size(), c->_streams.size());
 
-       while (i < _streams.size() && j < c->_streams.size()) {
-               _streams[i]->set_mapping (c->_streams[j]->mapping());
-               ++i;
-               ++j;
+       for (auto i = 0U; i < streams_to_take; ++i) {
+               auto mapping = _streams[i]->mapping();
+               mapping.take_from(c->_streams[i]->mapping());
+               _streams[i]->set_mapping(mapping);
        }
 }