Adjust subtitle position when referenced from top.
[dcpomatic.git] / src / lib / audio_content.cc
index e1f435f49b4d4e16934e4559dea6639e105b8b7f..fc295aa0185556092d769110b07bfedbe36c1e86 100644 (file)
 */
 
 #include "audio_content.h"
-#include "analyse_audio_job.h"
-#include "job_manager.h"
 #include "film.h"
 #include "exceptions.h"
 #include "config.h"
 #include "frame_rate_change.h"
 #include "raw_convert.h"
-#include "playlist.h"
+#include "compose.hpp"
 #include <libcxml/cxml.h>
+#include <libxml++/libxml++.h>
 #include <boost/foreach.hpp>
+#include <iostream>
 
 #include "i18n.h"
 
@@ -73,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");
 }
 
@@ -82,7 +82,7 @@ AudioContent::AudioContent (shared_ptr<const Film> film, vector<shared_ptr<Conte
 {
        shared_ptr<AudioContent> ref = dynamic_pointer_cast<AudioContent> (c[0]);
        DCPOMATIC_ASSERT (ref);
-       
+
        for (size_t i = 0; i < c.size(); ++i) {
                shared_ptr<AudioContent> ac = dynamic_pointer_cast<AudioContent> (c[i]);
 
@@ -115,7 +115,7 @@ AudioContent::set_audio_gain (double g)
                boost::mutex::scoped_lock lm (_mutex);
                _audio_gain = g;
        }
-       
+
        signal_changed (AudioContentProperty::AUDIO_GAIN);
 }
 
@@ -126,7 +126,7 @@ AudioContent::set_audio_delay (int d)
                boost::mutex::scoped_lock lm (_mutex);
                _audio_delay = d;
        }
-       
+
        signal_changed (AudioContentProperty::AUDIO_DELAY);
 }
 
@@ -155,7 +155,7 @@ AudioContent::set_audio_mapping (AudioMapping mapping)
                }
                i->set_mapping (stream_mapping);
        }
-               
+
        signal_changed (AudioContentProperty::AUDIO_STREAMS);
 }
 
@@ -166,9 +166,9 @@ AudioContent::audio_mapping () const
        BOOST_FOREACH (AudioStreamPtr i, audio_streams ()) {
                channels += i->channels ();
        }
-       
+
        AudioMapping merged (channels, MAX_DCP_AUDIO_CHANNELS);
-       
+
        int c = 0;
        int s = 0;
        BOOST_FOREACH (AudioStreamPtr i, audio_streams ()) {
@@ -191,13 +191,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
@@ -208,7 +205,7 @@ AudioContent::resampled_audio_frame_rate () const
                t /= frc.speed_up;
        }
 
-       return rint (t);
+       return lrint (t);
 }
 
 string