- emit_audio (earliest_piece, da);
- earliest_piece->decoder->get ();
- }
- } else if (ds && _video) {
- _in_subtitle.piece = earliest_piece;
- _in_subtitle.subtitle = ds;
- update_subtitle ();
- earliest_piece->decoder->get ();
- }
-
- _just_did_inaccurate_seek = false;
-
- return false;
-}
-
-void
-Player::emit_video (weak_ptr<Piece> weak_piece, shared_ptr<DecodedVideo> video)
-{
- /* Keep a note of what came in so that we can repeat it if required */
- _last_incoming_video.weak_piece = weak_piece;
- _last_incoming_video.video = video;
-
- shared_ptr<Piece> piece = weak_piece.lock ();
- if (!piece) {
- return;
- }
-
- shared_ptr<VideoContent> content = dynamic_pointer_cast<VideoContent> (piece->content);
- assert (content);
-
- FrameRateChange frc (content->video_frame_rate(), _film->video_frame_rate());
-
- float const ratio = content->ratio() ? content->ratio()->ratio() : content->video_size_after_crop().ratio();
- libdcp::Size image_size = fit_ratio_within (ratio, _video_container_size);
- if (_approximate_size) {
- image_size.width &= ~3;
- image_size.height &= ~3;
- }
-
- shared_ptr<PlayerImage> pi (
- new PlayerImage (
- video->image,
- content->crop(),
- image_size,
- _video_container_size,
- _film->scaler()
- )
- );
-
- if (
- _film->with_subtitles () &&
- _out_subtitle.image &&
- video->dcp_time >= _out_subtitle.from && video->dcp_time <= _out_subtitle.to
- ) {
-
- Position<int> const container_offset (
- (_video_container_size.width - image_size.width) / 2,
- (_video_container_size.height - image_size.width) / 2
- );
-
- pi->set_subtitle (_out_subtitle.image, _out_subtitle.position + container_offset);
- }
-
-#ifdef DCPOMATIC_DEBUG
- _last_video = piece->content;
-#endif
-
- Video (pi, video->eyes, content->colour_conversion(), video->same, video->dcp_time);
-
- _last_emit_was_black = false;
-
- /* This is a bit of a hack; don't update _video_position if EYES_RIGHT is on its way */
- if (video->eyes != EYES_LEFT) {
- _video_position = rint (video->dcp_time + TIME_HZ / _film->video_frame_rate());
- }
-}
-
-void
-Player::emit_audio (weak_ptr<Piece> weak_piece, shared_ptr<DecodedAudio> audio)
-{
- shared_ptr<Piece> piece = weak_piece.lock ();
- if (!piece) {
- return;
- }
-
- shared_ptr<AudioContent> content = dynamic_pointer_cast<AudioContent> (piece->content);
- assert (content);
-
- /* Gain */
- if (content->audio_gain() != 0) {
- shared_ptr<AudioBuffers> gain (new AudioBuffers (audio->data));
- gain->apply_gain (content->audio_gain ());
- audio->data = gain;
- }
-
- if (content->trimmed (audio->dcp_time - content->position ())) {
- return;
- }
-
- /* Remap channels */
- shared_ptr<AudioBuffers> dcp_mapped (new AudioBuffers (_film->audio_channels(), audio->data->frames()));
- dcp_mapped->make_silent ();
- list<pair<int, libdcp::Channel> > map = content->audio_mapping().content_to_dcp ();
- for (list<pair<int, libdcp::Channel> >::iterator i = map.begin(); i != map.end(); ++i) {
- if (i->first < audio->data->channels() && i->second < dcp_mapped->channels()) {
- dcp_mapped->accumulate_channel (audio->data.get(), i->first, i->second);