- frame_callback(frame->pts, video_timebase, timecode++,
- video_frame, 0, video_format,
- audio_frame, 0, audio_format);
+ if (audio_frame->len > 0) {
+ assert(audio_pts != -1);
+ }
+ if (!last_frame_was_connected) {
+ // We're recovering from an error (or really slow load, see above).
+ // Make sure to get the audio resampler reset. (This is a hack;
+ // ideally, the frame callback should just accept a way to signal
+ // audio discontinuity.)
+ timecode += MAX_FPS * 2 + 1;
+ }
+ frame_callback(frame->pts, video_timebase, audio_pts, audio_timebase, timecode++,
+ video_frame.get_and_release(), 0, video_format,
+ audio_frame.get_and_release(), 0, audio_format);
+ first_frame = false;
+ last_frame = steady_clock::now();
+ last_frame_was_connected = true;