+ pv->subtitle = hb_list_item( title->list_subtitle, 0 );
+
+ pv->video_sequence = 0;
+
+ return 0;
+}
+
+/***********************************************************************
+ * Close
+ ***********************************************************************
+ *
+ **********************************************************************/
+void syncClose( hb_work_object_t * w )
+{
+ hb_work_private_t * pv = w->private_data;
+ hb_job_t * job = pv->job;
+ hb_title_t * title = job->title;
+
+ int i;
+
+ if( pv->cur ) hb_buffer_close( &pv->cur );
+
+ for( i = 0; i < hb_list_count( title->list_audio ); i++ )
+ {
+ if( job->acodec & HB_ACODEC_AC3 ||
+ job->audio_mixdowns[i] == HB_AMIXDOWN_AC3 )
+ {
+ free( pv->sync_audio[i].ac3_buf );
+ }
+ else
+ {
+ src_delete( pv->sync_audio[i].state );
+ }
+ }
+
+ free( pv );
+ w->private_data = NULL;
+}
+
+/***********************************************************************
+ * Work
+ ***********************************************************************
+ * The root routine of this work abject
+ *
+ * The way this works is that we are syncing the audio to the PTS of
+ * the last video that we processed. That's why we skip the audio sync
+ * if we haven't got a valid PTS from the video yet.
+ *
+ **********************************************************************/
+int syncWork( hb_work_object_t * w, hb_buffer_t ** unused1,
+ hb_buffer_t ** unused2 )
+{
+ hb_work_private_t * pv = w->private_data;
+ int i;
+
+ /* If we ever got a video frame, handle audio now */
+ if( pv->pts_offset != INT64_MIN )
+ {
+ for( i = 0; i < hb_list_count( pv->job->title->list_audio ); i++ )
+ {
+ SyncAudio( w, i );
+ }
+ }