X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fffmpeg_decoder.cc;h=a51b521d0fe22918010a6976c5ae754dd9d8e051;hb=7e690d21278df14b113f3602cbbd43f6214fd614;hp=04dd7fd2d27fb141c1f4e17f5df9bbc54a10f829;hpb=b832098c526f8cdd616c0474f7538575463e0f6d;p=dcpomatic.git diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 04dd7fd2d..a51b521d0 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -422,15 +422,18 @@ FFmpegDecoder::decode_audio_packet () if (pts > 0) { /* Emit some silence */ - shared_ptr 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 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; + } } }