const core::video_format_desc format_desc_;\r
std::vector<int16_t> current_chunk_; \r
size_t frame_number_;\r
- bool restarting_;\r
+ bool wait_for_eof_;\r
public:\r
explicit implementation(input& input, const core::video_format_desc& format_desc) \r
: input_(input)\r
, codec_context_(*input_.get_audio_codec_context())\r
, format_desc_(format_desc) \r
, frame_number_(0)\r
- , restarting_(false)\r
+ , wait_for_eof_(false)\r
{\r
if(codec_context_.sample_rate != static_cast<int>(format_desc_.audio_sample_rate) || \r
codec_context_.channels != static_cast<int>(format_desc_.audio_channels))\r
{ \r
std::deque<std::pair<int, std::vector<int16_t>>> result;\r
\r
- if(!audio_packet)\r
+ if(!audio_packet) // eof\r
{ \r
avcodec_flush_buffers(&codec_context_);\r
current_chunk_.clear();\r
frame_number_ = 0;\r
- restarting_ = false;\r
+ wait_for_eof_ = false;\r
return result;\r
}\r
\r
- if(restarting_)\r
+ if(wait_for_eof_)\r
return result;\r
\r
auto s = current_chunk_.size();\r
\r
void restart()\r
{\r
- restarting_ = true;\r
+ wait_for_eof_ = true;\r
}\r
};\r
\r
}\r
);\r
\r
+ // If video is on first frame, sync with audio\r
if(audio_decoder_ && video_decoder_ && !video_frames_.empty() && !audio_chunks_.empty() &&\r
video_frames_.front().first == 0 && audio_chunks_.front().first != 0)\r
{\r
- audio_decoder_->restart();\r
+ audio_decoder_->restart(); // Notify decoder to wait for eof which was sent with video eof.\r
audio_chunks_ = audio_decoder_->receive(); \r
}\r
\r