X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=libhb%2Fenclame.c;h=027aa3add0645a82f98a7e2622f1a30a08181465;hb=033e32de9c380f54c7d1362a3979da205ebc3a29;hp=6b31a11d107e07d530a89b21aac6bc6414d9c5b6;hpb=bcd20ea430ced01a2c10605c8f6a77de9c6af410;p=handbrake-jp%2Fhandbrake-jp-git.git
diff --git a/libhb/enclame.c b/libhb/enclame.c
index 6b31a11d..027aa3ad 100644
--- a/libhb/enclame.c
+++ b/libhb/enclame.c
@@ -1,7 +1,7 @@
/* $Id: enclame.c,v 1.9 2005/03/05 14:27:05 titer Exp $
This file is part of the HandBrake source code.
- Homepage: .
+ Homepage: .
It may be used under the terms of the GNU General Public License. */
#include "hb.h"
@@ -28,6 +28,7 @@ struct hb_work_private_s
/* LAME handle */
lame_global_flags * lame;
+ int done;
unsigned long input_samples;
unsigned long output_bytes;
uint8_t * buf;
@@ -138,8 +139,35 @@ int enclameWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
hb_buffer_t ** buf_out )
{
hb_work_private_t * pv = w->private_data;
+ hb_buffer_t * in = *buf_in;
hb_buffer_t * buf;
+ if ( (*buf_in)->size <= 0 )
+ {
+ /* EOF on input - send it downstream & say we're done */
+ if ( pv->done )
+ {
+ *buf_out = *buf_in;
+ *buf_in = NULL;
+ return HB_WORK_DONE;
+ }
+ else
+ {
+ pv->done = 1;
+ hb_fifo_push( w->fifo_in, in);
+ *buf_in = NULL;
+
+ buf = hb_buffer_init( pv->output_bytes );
+ buf->size = lame_encode_flush( pv->lame, buf->data, LAME_MAXMP3BUFFER );
+ if( buf->size <= 0 )
+ {
+ hb_buffer_close( &buf );
+ }
+ *buf_out = buf;
+ return HB_WORK_OK;
+ }
+ }
+
hb_list_add( pv->list, *buf_in );
*buf_in = NULL;