- offset = -request;
- request_frames += request.frames (_film->audio_frame_rate ());
- if (request_frames < 0) {
- request_frames = 0;
- }
- request = DCPTime ();
- }
-
- Frame const content_frame = dcp_to_content_audio (*i, request);
-
- BOOST_FOREACH (AudioStreamPtr j, content->audio_streams ()) {
-
- /* Audio from this piece's decoder stream (which might be more or less than what we asked for) */
- ContentAudio all = decoder->get_audio (j, content_frame, request_frames, accurate);
-
- /* Gain */
- if (content->audio_gain() != 0) {
- shared_ptr<AudioBuffers> gain (new AudioBuffers (all.audio));
- gain->apply_gain (content->audio_gain ());
- all.audio = gain;
- }
-
- /* Remap channels */
- shared_ptr<AudioBuffers> dcp_mapped (new AudioBuffers (_film->audio_channels(), all.audio->frames()));
- dcp_mapped->make_silent ();
- AudioMapping map = j->mapping ();
- for (int i = 0; i < map.input_channels(); ++i) {
- for (int j = 0; j < _film->audio_channels(); ++j) {
- if (map.get (i, j) > 0) {
- dcp_mapped->accumulate_channel (
- all.audio.get(),
- i,
- j,
- map.get (i, j)
- );
- }
- }
- }
-
- if (_audio_processor) {
- dcp_mapped = _audio_processor->run (dcp_mapped);
- }
-
- all.audio = dcp_mapped;
-
- audio->accumulate_frames (
- all.audio.get(),
- content_frame - all.frame,
- offset.frames (_film->audio_frame_rate()),
- min (Frame (all.audio->frames()), request_frames)
- );