From 48b768db44cb9e00adfead71b973074685cec417 Mon Sep 17 00:00:00 2001 From: deva Date: Tue, 20 Sep 2005 19:39:49 +0000 Subject: *** empty log message *** --- src/liblame_wrapper.cc | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src/liblame_wrapper.cc') diff --git a/src/liblame_wrapper.cc b/src/liblame_wrapper.cc index c72c2dc..b29acf9 100644 --- a/src/liblame_wrapper.cc +++ b/src/liblame_wrapper.cc @@ -94,22 +94,27 @@ LibLAMEWrapper::~LibLAMEWrapper() Frame *LibLAMEWrapper::close(Frame *oldframe) { - Frame *frame = new Frame(NULL, oldframe->size + 7200); - frame->number = oldframe->number; + Frame *frame; + unsigned int offset = 0; - memcpy(frame->data, oldframe->data, oldframe->size); + frame = new Frame(NULL, (int)(1.25 * SAMPLES + 7200) * 2); // Big enough to hold two frames + + if(oldframe) { + offset = oldframe->size; + frame->number = oldframe->number; + memcpy(frame->data, oldframe->data, oldframe->size); + delete oldframe; + } int flush; - flush = lame_encode_finish(gfp, frame->data + oldframe->size, 7200); + flush = lame_encode_finish(gfp, frame->data + offset, 7200); - frame->size = oldframe->size + flush; + frame->size = offset + flush; calc_bitrate += flush; frame->bitrate = (unsigned int)((double)calc_bitrate / (double)(frame_number)) * 25; - delete oldframe; - return frame; } -- cgit v1.2.3