Re-add missing audio mapping in butler for preview.
[dcpomatic.git] / src / lib / player.cc
index 95ff55bc5e26f7d3e8d7bf30945eadcb518a1d7f..2e47da5bfc9306c16077410be99dc7b5d00d7415 100644 (file)
@@ -718,24 +718,7 @@ Player::audio_transform (shared_ptr<AudioContent> content, AudioStreamPtr stream
 
        /* Remap */
 
-       shared_ptr<AudioBuffers> dcp_mapped (new AudioBuffers (_film->audio_channels(), content_audio.audio->frames()));
-       dcp_mapped->make_silent ();
-
-       AudioMapping map = stream->mapping ();
-       for (int i = 0; i < map.input_channels(); ++i) {
-               for (int j = 0; j < dcp_mapped->channels(); ++j) {
-                       if (map.get (i, static_cast<dcp::Channel> (j)) > 0) {
-                               dcp_mapped->accumulate_channel (
-                                       content_audio.audio.get(),
-                                       i,
-                                       static_cast<dcp::Channel> (j),
-                                       map.get (i, static_cast<dcp::Channel> (j))
-                                       );
-                       }
-               }
-       }
-
-       content_audio.audio = dcp_mapped;
+       content_audio.audio = remap (content_audio.audio, _film->audio_channels(), stream->mapping());
 
        /* Process */
 
@@ -743,12 +726,6 @@ Player::audio_transform (shared_ptr<AudioContent> content, AudioStreamPtr stream
                content_audio.audio = _audio_processor->run (content_audio.audio, _film->audio_channels ());
        }
 
-       /* Pad any gap which may be caused by audio delay */
-
-       if (_last_audio_time) {
-               fill_audio (DCPTimePeriod (*_last_audio_time, time));
-       }
-
        /* Push */
 
        _audio_merger.push (content_audio.audio, time);
@@ -950,6 +927,8 @@ Player::fill_audio (DCPTimePeriod period)
                return;
        }
 
+       DCPOMATIC_ASSERT (period.from < period.to);
+
        BOOST_FOREACH (DCPTimePeriod i, subtract(period, _no_audio)) {
                DCPTime t = i.from;
                while (t < i.to) {