X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Flib%2Fplayer.cc;h=b81eb4d807ae4c94422e3a4e41ea7243223b86a2;hb=0a93237cb5e4642d3b698ff9b7d0cfae5401478c;hp=be00aebc7d7657449a88cf94666693c439a5d3f9;hpb=608c146eb09fac2a8fc60e1a72591f6bb8364e1f;p=dcpomatic.git diff --git a/src/lib/player.cc b/src/lib/player.cc index be00aebc7..b81eb4d80 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -414,13 +414,6 @@ Player::get_audio (DCPTime time, DCPTime length, bool accurate) shared_ptr decoder = dynamic_pointer_cast ((*i)->decoder); DCPOMATIC_ASSERT (decoder); - if (content->audio_frame_rate() == 0) { - /* This AudioContent has no audio (e.g. if it is an FFmpegContent with no - * audio stream). - */ - continue; - } - /* The time that we should request from the content */ DCPTime request = time - DCPTime::from_seconds (content->audio_delay() / 1000.0); Frame request_frames = length_frames; @@ -439,41 +432,44 @@ Player::get_audio (DCPTime time, DCPTime length, bool accurate) Frame const content_frame = dcp_to_content_audio (*i, request); - /* Audio from this piece's decoder (which might be more or less than what we asked for) */ - shared_ptr all = decoder->get_audio (content_frame, request_frames, accurate); - - /* Gain */ - if (content->audio_gain() != 0) { - shared_ptr gain (new AudioBuffers (all->audio)); - gain->apply_gain (content->audio_gain ()); - all->audio = gain; - } + 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 gain (new AudioBuffers (all.audio)); + gain->apply_gain (content->audio_gain ()); + all.audio = gain; + } - /* Remap channels */ - shared_ptr dcp_mapped (new AudioBuffers (_film->audio_channels(), all->audio->frames())); - dcp_mapped->make_silent (); - AudioMapping map = content->audio_mapping (); - for (int i = 0; i < map.content_channels(); ++i) { - for (int j = 0; j < _film->audio_channels(); ++j) { - if (map.get (i, static_cast (j)) > 0) { - dcp_mapped->accumulate_channel ( - all->audio.get(), - i, - j, - map.get (i, static_cast (j)) - ); + /* Remap channels */ + shared_ptr dcp_mapped (new AudioBuffers (_film->audio_channels(), all.audio->frames())); + dcp_mapped->make_silent (); + AudioMapping map = j->mapping (); + for (int i = 0; i < map.content_channels(); ++i) { + for (int j = 0; j < _film->audio_channels(); ++j) { + if (map.get (i, static_cast (j)) > 0) { + dcp_mapped->accumulate_channel ( + all.audio.get(), + i, + j, + map.get (i, static_cast (j)) + ); + } } } - } - all->audio = 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) - ); + audio->accumulate_frames ( + all.audio.get(), + content_frame - all.frame, + offset.frames (_film->audio_frame_rate()), + min (Frame (all.audio->frames()), request_frames) + ); + } } return audio;