+ buf = hb_fifo_see( track2->fifo );
+ if( !buf )
+ {
+ // XXX the libmkv muxer will produce unplayable files if the
+ // audio & video are far out of sync. To keep them in sync we require
+ // that *all* fifos have a buffer then we take the oldest.
+ // Unfortunately this means we can hang in a deadlock with the
+ // reader process filling the fifos.
+ if ( job->mux == HB_MUX_MKV )
+ {
+ return NULL;
+ }
+
+ // To make sure we don't camp on one fifo & prevent the others
+ // from making progress we take the earliest data of all the
+ // data that's currently available but we don't care if some
+ // fifos don't have data.
+ continue;
+ }
+ if ( buf->size <= 0 )
+ {
+ // EOF - mark this track as done
+ buf = hb_fifo_get( track2->fifo );
+ hb_buffer_close( &buf );
+ track2->eof = 1;
+ continue;
+ }
+ if( !track || buf->start < pts )
+ {
+ track = track2;
+ pts = buf->start;
+ }