timeradd(&av_diff,&frame_period,&av_diff);// plus duration of the last video frame
// m_len.tv_sec -= audio_last.tv_sec;
to_finish_us=time_to_us(&av_diff);
// m_len.tv_usec -= audio_last.tv_usec;
// time_normalize(&m_len);
// long to_finish_us = time_to_us(&m_len);
av_diff=time_sub(&m_len,&audio->ctx_a.time_last);
frame_period=us_to_time(audio->frame_period);
av_diff=time_add(&av_diff,&frame_period);// plus duration of the last video frame
longto_finish_us=time_to_us(&av_diff);
floatperiod_us=(1.0/audio->audio_rate)*1000000;
// D6(fprintf(debug_file, "... and now we need to save audio for this time: %ld:%06ld - i.e. %06ld usecs\n", m_len.tv_sec, m_len.tv_usec, to_finish_us));
D6(fprintf(debug_file,"... and now we need to save audio for this time: %ld:%06ld - i.e. %06ld usecs\n",av_diff.tv_sec,av_diff.tv_usec,to_finish_us));
D6(fprintf(debug_file,"... and now we need to save audio for this time: %ld:%06ld - i.e. %06ld usecs\n",av_diff.tv_sec,av_diff.tv_usec,to_finish_us));
}else{
// audio is ahead of video, we do not need to save any additional audio frames