+ 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 );
+ }
+
+ /*
+ * When we get here we've taken care of all the dups and gaps in the
+ * audio stream and are ready to inject the next input frame into
+ * the output stream.
+ */
+ *buf_out = OutputAudioFrame( w->audio, buf, sync );
+ return HB_WORK_OK;
+}
+
+hb_work_object_t hb_sync_audio =
+{
+ WORK_SYNC_AUDIO,
+ "AudioSynchronization",
+ syncAudioInit,
+ syncAudioWork,
+ syncAudioClose
+};
+
+static void InitAudio( hb_job_t * job, hb_sync_common_t * common, int i )
+{
+ hb_work_object_t * w;
+ hb_work_private_t * pv;
+ hb_title_t * title = job->title;
+ hb_sync_audio_t * sync;
+
+ pv = calloc( 1, sizeof( hb_work_private_t ) );
+ sync = &pv->type.audio;
+ sync->index = i;
+ pv->job = job;
+ pv->common = common;
+ pv->common->ref++;
+ pv->common->pts_count++;
+
+ w = hb_get_work( WORK_SYNC_AUDIO );
+ w->private_data = pv;
+ w->audio = hb_list_item( title->list_audio, i );
+ w->fifo_in = w->audio->priv.fifo_raw;
+
+ if( w->audio->config.out.codec == HB_ACODEC_AC3 ||
+ w->audio->config.out.codec == HB_ACODEC_DCA )
+ {
+ w->fifo_out = w->audio->priv.fifo_out;
+ }
+ else
+ {
+ w->fifo_out = w->audio->priv.fifo_sync;