+ sync->next_pts = start;
+ }
+ if ( sync->first_drop )
+ {
+ // we were dropping old data but input buf time is now current
+ hb_log( "sync: audio %d time went backwards %d ms, dropped %d frames "
+ "(next %"PRId64", current %"PRId64")", w->audio->id,
+ (int)( sync->next_pts - sync->first_drop ) / 90,
+ sync->drop_count, sync->first_drop, sync->next_pts );
+ sync->first_drop = 0;
+ sync->drop_count = 0;
+ sync->next_pts = start;
+ }
+ if ( start - sync->next_pts >= (90 * 70) )
+ {
+ if ( start - sync->next_pts > (90000LL * 60) )
+ {
+ // there's a gap of more than a minute between the last
+ // frame and this. assume we got a corrupted timestamp
+ // and just drop the next buf.
+ hb_log( "sync: %d minute time gap in audio %d - dropping buf"
+ " start %"PRId64", next %"PRId64,
+ (int)((start - sync->next_pts) / (90000*60)),
+ w->audio->id, start, sync->next_pts );
+ hb_buffer_close( &buf );
+ return HB_WORK_OK;
+ }
+ /*
+ * there's a gap of at least 70ms between the last
+ * frame we processed & the next. Fill it with silence.
+ * Or in the case of DCA, skip some frames from the
+ * other streams.
+ */
+ if( w->audio->config.out.codec == HB_ACODEC_DCA )
+ {
+ hb_log( "sync: audio gap %d ms. Skipping frames. Audio %d"
+ " start %"PRId64", next %"PRId64,
+ (int)((start - sync->next_pts) / 90),
+ w->audio->id, start, sync->next_pts );
+ hb_lock( pv->common->mutex );
+ pv->common->audio_passthru_slip += (start - sync->next_pts);
+ pv->common->video_pts_slip += (start - sync->next_pts);
+ hb_unlock( pv->common->mutex );
+ *buf_out = buf;
+ return HB_WORK_OK;
+ }
+ hb_log( "sync: adding %d ms of silence to audio %d"
+ " start %"PRId64", next %"PRId64,
+ (int)((start - sync->next_pts) / 90),
+ w->audio->id, start, sync->next_pts );
+ InsertSilence( w, start - sync->next_pts );