return;
}
- while (1) {
+ while (true) {
int r = av_read_frame (_format_context, &_packet);
if (r < 0) {
return;
av_free_packet (&_packet);
}
+
+ /* _video_position should be the next thing to be emitted, which will the one after the thing
+ we just saw.
+ */
+ _video_position++;
}
void
if (pts > 0) {
/* Emit some silence */
- shared_ptr<AudioBuffers> silence (
- new AudioBuffers (
- _ffmpeg_content->audio_channels(),
- pts * _ffmpeg_content->content_audio_frame_rate()
- )
- );
+ int64_t frames = pts * _ffmpeg_content->content_audio_frame_rate ();
+ while (frames > 0) {
+ int64_t const this_time = min (frames, (int64_t) _ffmpeg_content->content_audio_frame_rate() / 2);
+
+ shared_ptr<AudioBuffers> silence (
+ new AudioBuffers (_ffmpeg_content->audio_channels(), this_time)
+ );
- silence->make_silent ();
- audio (silence, _audio_position);
+ silence->make_silent ();
+ audio (silence, _audio_position);
+ frames -= this_time;
+ }
}
}