BOOST_FOREACH (Buffer i, _buffers) {
if (i.period().to <= time) {
/* Completely within the pull period */
BOOST_FOREACH (Buffer i, _buffers) {
if (i.period().to <= time) {
/* Completely within the pull period */
out.push_back (make_pair (i.audio, i.time));
} else if (i.time < time) {
/* Overlaps the end of the pull period */
shared_ptr<AudioBuffers> audio (new AudioBuffers (i.audio->channels(), frames(DCPTime(time - i.time))));
audio->copy_from (i.audio.get(), audio->frames(), 0, 0);
out.push_back (make_pair (i.audio, i.time));
} else if (i.time < time) {
/* Overlaps the end of the pull period */
shared_ptr<AudioBuffers> audio (new AudioBuffers (i.audio->channels(), frames(DCPTime(time - i.time))));
audio->copy_from (i.audio.get(), audio->frames(), 0, 0);
out.push_back (make_pair (audio, i.time));
i.audio->trim_start (audio->frames ());
i.time += DCPTime::from_frames(audio->frames(), _frame_rate);
out.push_back (make_pair (audio, i.time));
i.audio->trim_start (audio->frames ());
i.time += DCPTime::from_frames(audio->frames(), _frame_rate);
AudioMerger::push (boost::shared_ptr<const AudioBuffers> audio, DCPTime time)
{
DCPOMATIC_ASSERT (time >= _last_pull);
AudioMerger::push (boost::shared_ptr<const AudioBuffers> audio, DCPTime time)
{
DCPOMATIC_ASSERT (time >= _last_pull);
_buffers.push_back (Buffer (part, time, _frame_rate));
} else if (before != _buffers.end() && after == _buffers.end()) {
/* We have an existing buffer before this one; append new data to it */
_buffers.push_back (Buffer (part, time, _frame_rate));
} else if (before != _buffers.end() && after == _buffers.end()) {
/* We have an existing buffer before this one; append new data to it */