From 12f11c97ae9e5b1b6367e4a5c49713fdd4984b89 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 10 Nov 2016 12:17:05 +0100 Subject: [PATCH] decoder/faad: use AtScopeExit() --- src/decoder/plugins/FaadDecoderPlugin.cxx | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/decoder/plugins/FaadDecoderPlugin.cxx b/src/decoder/plugins/FaadDecoderPlugin.cxx index ad1470fa6..79e3755c8 100644 --- a/src/decoder/plugins/FaadDecoderPlugin.cxx +++ b/src/decoder/plugins/FaadDecoderPlugin.cxx @@ -24,6 +24,7 @@ #include "input/InputStream.hxx" #include "CheckAudioFormat.hxx" #include "tag/TagHandler.hxx" +#include "util/ScopeExit.hxx" #include "util/ConstBuffer.hxx" #include "util/Error.hxx" #include "util/Domain.hxx" @@ -310,6 +311,7 @@ faad_get_file_time(InputStream &is) if (!recognized) { NeAACDecHandle decoder = faad_decoder_new(); + AtScopeExit(decoder) { NeAACDecClose(decoder); }; buffer.Fill(); @@ -317,8 +319,6 @@ faad_get_file_time(InputStream &is) if (faad_decoder_init(decoder, buffer, audio_format, IgnoreError())) recognized = true; - - NeAACDecClose(decoder); } return std::make_pair(recognized, duration); @@ -413,12 +413,9 @@ faad_stream_decode(Decoder &mpd_decoder, InputStream &is) /* create the libfaad decoder */ const NeAACDecHandle decoder = faad_decoder_new(); + AtScopeExit(decoder) { NeAACDecClose(decoder); }; faad_stream_decode(mpd_decoder, is, buffer, decoder); - - /* cleanup */ - - NeAACDecClose(decoder); } static bool