diff options
author | John Stebbins <[email protected]> | 2015-10-16 16:10:22 -0700 |
---|---|---|
committer | John Stebbins <[email protected]> | 2015-10-16 16:10:22 -0700 |
commit | aaaf1a56e87cbbacddd77e7737d8bf01a1597b62 (patch) | |
tree | dac1367c769a54ed1ee9fed6399f9961218ed642 | |
parent | 6ae82c27e75f1eb4bd3c16c07e5b2a2cd120e82c (diff) | |
parent | ac3d924469174c0c197165e5f4131c4a853c7f18 (diff) |
Merge pull request #20 from jstebbins/mux-merge
mux: flush cached buffers when closing
-rw-r--r-- | libhb/muxcommon.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/libhb/muxcommon.c b/libhb/muxcommon.c index b2842acfa..990614540 100644 --- a/libhb/muxcommon.c +++ b/libhb/muxcommon.c @@ -457,7 +457,27 @@ static int muxWork( hb_work_object_t * w, hb_buffer_t ** buf_in, return HB_WORK_OK; } -void muxClose( hb_work_object_t * w ) +static void muxFlush(hb_mux_t * mux) +{ + int ii, done = 0; + + while (!done) + { + done = 1; + for (ii = 0; ii < mux->ntracks; ii++) + { + OutputTrackChunk(mux, ii, mux->m); + if (mux->track[ii]->mf.out != mux->track[ii]->mf.in) + { + // track buffer is not empty + done = 0; + } + } + mux->pts += mux->interleave; + } +} + +static void muxClose( hb_work_object_t * w ) { hb_work_private_t * pv = w->private_data; hb_mux_t * mux = pv->mux; @@ -468,6 +488,8 @@ void muxClose( hb_work_object_t * w ) hb_lock( mux->mutex ); if ( --mux->ref == 0 ) { + muxFlush(mux); + // Update state before closing muxer. Closing the muxer // may initiate optimization which can take a while and // we want the muxing state to be visible while this is |