+ for (auto i: ffmpeg_content()->ffmpeg_audio_streams()) {
+ auto context = _codec_context[i->index(_format_context)];
+ int r = avcodec_send_packet (context, nullptr);
+ if (r < 0 && r != AVERROR_EOF) {
+ /* EOF can happen if we've already sent a flush packet */
+ throw DecodeError (N_("avcodec_send_packet"), N_("FFmpegDecoder::flush"), r);
+ }
+ r = avcodec_receive_frame (context, audio_frame(i));
+ if (r >= 0) {
+ process_audio_frame (i);
+ did_something = true;
+ }
+ }
+
+ if (did_something) {
+ /* We want to be called again */
+ return false;
+ }
+
+ /* Make sure all streams are the same length and round up to the next video frame */
+
+ auto const frc = film()->active_frame_rate_change(_ffmpeg_content->position());
+ ContentTime full_length (_ffmpeg_content->full_length(film()), frc);
+ full_length = full_length.ceil (frc.source);
+ if (video) {
+ double const vfr = _ffmpeg_content->video_frame_rate().get();
+ auto const f = full_length.frames_round (vfr);
+ auto v = video->position(film()).get_value_or(ContentTime()).frames_round(vfr) + 1;
+ while (v < f) {
+ video->emit (film(), make_shared<const RawImageProxy>(_black_image), v);
+ ++v;
+ }
+ }