X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=libhb%2Fmuxcommon.c;h=b6b5a2a579145bbd4cd525e12a34a32c46795b4c;hb=4f0019f03c2e85e8634150ff0c9a31bee6d35ce5;hp=a5ee9b0ba7db77c7d753eb2cdbe443a6d84c9c43;hpb=0935ceb66f3c5f59c9ee07d390dd03f9b6f5cdec;p=handbrake-jp%2Fhandbrake-jp-git.git diff --git a/libhb/muxcommon.c b/libhb/muxcommon.c index a5ee9b0b..b6b5a2a5 100644 --- a/libhb/muxcommon.c +++ b/libhb/muxcommon.c @@ -185,9 +185,10 @@ static void OutputTrackChunk( hb_mux_t *mux, hb_track_t *track, hb_mux_object_t while ( ( buf = mf_peek( track ) ) != NULL && buf->start < mux->pts ) { - m->mux( m, track->mux_data, mf_pull( track ) ); + buf = mf_pull( track ); track->frames += 1; track->bytes += buf->size; + m->mux( m, track->mux_data, buf ); } } @@ -288,6 +289,19 @@ void muxClose( hb_work_object_t * w ) hb_lock( mux->mutex ); if ( --mux->ref == 0 ) { + // 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 + // happening. + if( job->pass == 0 || job->pass == 2 ) + { + /* Update the UI */ + hb_state_t state; + state.state = HB_STATE_MUXING; + state.param.muxing.progress = 0; + hb_set_state( job->h, &state ); + } + if( mux->m ) { mux->m->end( mux->m ); @@ -300,12 +314,6 @@ void muxClose( hb_work_object_t * w ) struct stat sb; uint64_t bytes_total, frames_total; - /* Update the UI */ - hb_state_t state; - state.state = HB_STATE_MUXING; - state.param.muxing.progress = 0; - hb_set_state( job->h, &state ); - if( !stat( job->file, &sb ) ) { hb_deep_log( 2, "mux: file size, %"PRId64" bytes", (uint64_t) sb.st_size ); @@ -384,6 +392,10 @@ static void mux_loop( void * _w ) } w->status = w->work( w, &buf_in, NULL ); + if( buf_in ) + { + hb_buffer_close( &buf_in ); + } } } @@ -444,8 +456,7 @@ hb_work_object_t * hb_muxer_init( hb_job_t * job ) muxer->private_data->track = mux->ntracks; muxer->fifo_in = job->fifo_mpeg4; add_mux_track( mux, job->mux_data, 1 ); - muxer->done = &job->done; - muxer->thread = hb_thread_init( muxer->name, mux_loop, muxer, HB_NORMAL_PRIORITY ); + muxer->done = &muxer->private_data->mux->done; for( i = 0; i < hb_list_count( title->list_audio ); i++ ) {