/*
- Copyright (C) 2013-2016 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2018 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
}
}
+AudioContent::AudioContent (Content* parent, vector<shared_ptr<Content> > c)
+ : ContentPart (parent)
+{
+ shared_ptr<AudioContent> ref = c[0]->audio;
+ DCPOMATIC_ASSERT (ref);
+
+ for (size_t i = 1; i < c.size(); ++i) {
+ if (c[i]->audio->gain() != ref->gain()) {
+ throw JoinError (_("Content to be joined must have the same audio gain."));
+ }
+
+ if (c[i]->audio->delay() != ref->delay()) {
+ throw JoinError (_("Content to be joined must have the same audio delay."));
+ }
+ }
+
+ _gain = ref->gain ();
+ _delay = ref->delay ();
+ _streams = ref->streams ();
+}
+
void
AudioContent::as_xml (xmlpp::Node* node) const
{
void
AudioContent::set_mapping (AudioMapping mapping)
{
+ ChangeSignaller<Content> cc (_parent, AudioContentProperty::STREAMS);
+
int c = 0;
BOOST_FOREACH (AudioStreamPtr i, streams ()) {
AudioMapping stream_mapping (i->channels (), MAX_DCP_AUDIO_CHANNELS);
}
i->set_mapping (stream_mapping);
}
-
- _parent->signal_changed (AudioContentProperty::STREAMS);
}
AudioMapping
void
AudioContent::set_streams (vector<AudioStreamPtr> streams)
{
+ ChangeSignaller<Content> cc (_parent, AudioContentProperty::STREAMS);
+
{
boost::mutex::scoped_lock lm (_mutex);
_streams = streams;
}
-
- _parent->signal_changed (AudioContentProperty::STREAMS);
}
AudioStreamPtr
void
AudioContent::add_stream (AudioStreamPtr stream)
{
+ ChangeSignaller<Content> cc (_parent, AudioContentProperty::STREAMS);
+
{
boost::mutex::scoped_lock lm (_mutex);
_streams.push_back (stream);
}
-
- _parent->signal_changed (AudioContentProperty::STREAMS);
}
void
AudioContent::set_stream (AudioStreamPtr stream)
{
+ ChangeSignaller<Content> cc (_parent, AudioContentProperty::STREAMS);
+
{
boost::mutex::scoped_lock lm (_mutex);
_streams.clear ();
_streams.push_back (stream);
}
-
- _parent->signal_changed (AudioContentProperty::STREAMS);
}
void
++j;
}
}
+
+void
+AudioContent::modify_position (DCPTime& pos) const
+{
+ pos = pos.round (_parent->film()->audio_frame_rate());
+}
+
+void
+AudioContent::modify_trim_start (ContentTime& trim) const
+{
+ DCPOMATIC_ASSERT (!_streams.empty());
+ /* XXX: we're in trouble if streams have different rates */
+ trim = trim.round (_streams.front()->frame_rate());
+}