Fix nonfunctional send-problem-report.
[dcpomatic.git] / src / lib / audio_content.cc
index 4d821ad6008e0b36f78fde9655e63642fb7e15e8..6d9c85ca20201c2719931216b114428163abb9ad 100644 (file)
@@ -25,7 +25,9 @@
 #include "raw_convert.h"
 #include "compose.hpp"
 #include <libcxml/cxml.h>
+#include <libxml++/libxml++.h>
 #include <boost/foreach.hpp>
+#include <iostream>
 
 #include "i18n.h"
 
@@ -71,7 +73,7 @@ AudioContent::AudioContent (shared_ptr<const Film> film, boost::filesystem::path
 AudioContent::AudioContent (shared_ptr<const Film> film, cxml::ConstNodePtr node)
        : Content (film, node)
 {
-       _audio_gain = node->number_child<float> ("AudioGain");
+       _audio_gain = node->number_child<double> ("AudioGain");
        _audio_delay = node->number_child<int> ("AudioDelay");
 }
 
@@ -166,6 +168,7 @@ AudioContent::audio_mapping () const
        }
 
        AudioMapping merged (channels, MAX_DCP_AUDIO_CHANNELS);
+       merged.make_zero ();
 
        int c = 0;
        int s = 0;
@@ -173,7 +176,9 @@ AudioContent::audio_mapping () const
                AudioMapping mapping = i->mapping ();
                for (int j = 0; j < mapping.input_channels(); ++j) {
                        for (int k = 0; k < MAX_DCP_AUDIO_CHANNELS; ++k) {
-                               merged.set (c, k, mapping.get (j, k));
+                               if (k < mapping.output_channels()) {
+                                       merged.set (c, k, mapping.get (j, k));
+                               }
                        }
                        ++c;
                }
@@ -189,13 +194,10 @@ AudioContent::audio_mapping () const
 int
 AudioContent::resampled_audio_frame_rate () const
 {
-       shared_ptr<const Film> film = _film.lock ();
-       DCPOMATIC_ASSERT (film);
-
        /* Resample to a DCI-approved sample rate */
        double t = has_rate_above_48k() ? 96000 : 48000;
 
-       FrameRateChange frc = film->active_frame_rate_change (position ());
+       FrameRateChange frc = film()->active_frame_rate_change (position ());
 
        /* Compensate if the DCP is being run at a different frame rate
           to the source; that is, if the video is run such that it will
@@ -206,7 +208,7 @@ AudioContent::resampled_audio_frame_rate () const
                t /= frc.speed_up;
        }
 
-       return rint (t);
+       return lrint (t);
 }
 
 string