- shared_ptr<AudioContent> content = piece->content->audio;
- DCPOMATIC_ASSERT (content);
-
- /* Resample */
- if (stream->frame_rate() != content->resampled_frame_rate()) {
- shared_ptr<Resampler> r = resampler (content, stream, true);
- pair<shared_ptr<const AudioBuffers>, Frame> ro = r->run (content_audio.audio, content_audio.frame);
- if (ro.first->frames() == 0) {
- return;
- }
- content_audio.audio = ro.first;
- content_audio.frame = ro.second;
- }
-
- /* Compute time in the DCP */
- DCPTime time = resampled_audio_to_dcp (piece, content_audio.frame) + DCPTime::from_seconds (content->delay() / 1000.0);
- /* And the end of this block in the DCP */
- DCPTime end = time + DCPTime::from_frames(content_audio.audio->frames(), content->resampled_frame_rate());
-
- /* Remove anything that comes before the start or after the end of the content */
- if (time < piece->content->position()) {
- pair<shared_ptr<AudioBuffers>, DCPTime> cut = discard_audio (content_audio.audio, time, piece->content->position());
- if (!cut.first) {
- /* This audio is entirely discarded */
- return;
- }
- content_audio.audio = cut.first;
- time = cut.second;
- } else if (time > piece->content->end()) {
- /* Discard it all */
- return;
- } else if (end > piece->content->end()) {
- Frame const remaining_frames = DCPTime(piece->content->end() - time).frames_round(_film->audio_frame_rate());
- if (remaining_frames == 0) {
- return;
- }
- shared_ptr<AudioBuffers> cut (new AudioBuffers (content_audio.audio->channels(), remaining_frames));
- cut->copy_from (content_audio.audio.get(), remaining_frames, 0, 0);
- content_audio.audio = cut;
- }
-
- audio_transform (content, stream, content_audio, time);
-}
-
-void
-Player::image_subtitle_start (weak_ptr<Piece> wp, ContentImageSubtitle subtitle)
-{
- shared_ptr<Piece> piece = wp.lock ();
- if (!piece) {