From: Josh Coalson Date: Wed, 3 Oct 2007 15:08:51 +0000 (+0000) Subject: fix bug: move flac decoder teardown into EncoderSession_destroy() X-Git-Tag: 1.3.0pre1~196 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=79e10b392198e5523445fa6752c507c8041292e8;p=platform%2Fupstream%2Fflac.git fix bug: move flac decoder teardown into EncoderSession_destroy() --- diff --git a/src/flac/encode.c b/src/flac/encode.c index 9c66326..4782594 100644 --- a/src/flac/encode.c +++ b/src/flac/encode.c @@ -1431,6 +1431,16 @@ FLAC__bool EncoderSession_construct(EncoderSession *e, encode_options_t options, void EncoderSession_destroy(EncoderSession *e) { + if(e->format == FORMAT_FLAC || e->format == FORMAT_OGGFLAC) { + size_t i; + if(e->fmt.flac.decoder) + FLAC__stream_decoder_delete(e->fmt.flac.decoder); + e->fmt.flac.decoder = 0; + for(i = 0; i < e->fmt.flac.client_data.num_metadata_blocks; i++) + FLAC__metadata_object_delete(e->fmt.flac.client_data.metadata_blocks[i]); + e->fmt.flac.client_data.num_metadata_blocks = 0; + } + if(e->fin != stdin) fclose(e->fin); @@ -1451,17 +1461,6 @@ int EncoderSession_finish_ok(EncoderSession *e, int info_align_carry, int info_a int ret = 0; FLAC__bool verify_error = false; - /*@@@ can this go in EncoderSession_destroy()? it's duplicated in EncoderSession_finish_error() */ - if(e->format == FORMAT_FLAC || e->format == FORMAT_OGGFLAC) { - size_t i; - for(i = 0; i < e->fmt.flac.client_data.num_metadata_blocks; i++) - FLAC__metadata_object_delete(e->fmt.flac.client_data.metadata_blocks[i]); - e->fmt.flac.client_data.num_metadata_blocks = 0; - if(e->fmt.flac.decoder) - FLAC__stream_decoder_delete(e->fmt.flac.decoder); - e->fmt.flac.decoder = 0; - } - if(e->encoder) { fse_state = FLAC__stream_encoder_get_state(e->encoder); ret = FLAC__stream_encoder_finish(e->encoder)? 0 : 1; @@ -1509,17 +1508,6 @@ int EncoderSession_finish_error(EncoderSession *e) { FLAC__ASSERT(e->encoder); - /*@@@ can this go in EncoderSession_destroy()? it's duplicated in EncoderSession_finish_ok() */ - if(e->format == FORMAT_FLAC || e->format == FORMAT_OGGFLAC) { - size_t i; - for(i = 0; i < e->fmt.flac.client_data.num_metadata_blocks; i++) - FLAC__metadata_object_delete(e->fmt.flac.client_data.metadata_blocks[i]); - e->fmt.flac.client_data.num_metadata_blocks = 0; - if(e->fmt.flac.decoder) - FLAC__stream_decoder_delete(e->fmt.flac.decoder); - e->fmt.flac.decoder = 0; - } - if(e->total_samples_to_encode > 0) flac__utils_printf(stderr, 2, "\n");