decoder/audiofile: use AtScopeExit()

This commit is contained in:
Max Kellermann 2016-11-10 12:01:15 +01:00
parent 07a51957ee
commit 256ee7a8c7

View File

@ -23,6 +23,7 @@
#include "input/InputStream.hxx" #include "input/InputStream.hxx"
#include "CheckAudioFormat.hxx" #include "CheckAudioFormat.hxx"
#include "tag/TagHandler.hxx" #include "tag/TagHandler.hxx"
#include "util/ScopeExit.hxx"
#include "util/Error.hxx" #include "util/Error.hxx"
#include "util/Domain.hxx" #include "util/Domain.hxx"
#include "Log.hxx" #include "Log.hxx"
@ -195,6 +196,8 @@ audiofile_stream_decode(Decoder &decoder, InputStream &is)
if (fh == AF_NULL_FILEHANDLE) if (fh == AF_NULL_FILEHANDLE)
return; return;
AtScopeExit(fh) { afCloseFile(fh); };
Error error; Error error;
AudioFormat audio_format; AudioFormat audio_format;
if (!audio_format_init_checked(audio_format, if (!audio_format_init_checked(audio_format,
@ -203,7 +206,6 @@ audiofile_stream_decode(Decoder &decoder, InputStream &is)
afGetVirtualChannels(fh, AF_DEFAULT_TRACK), afGetVirtualChannels(fh, AF_DEFAULT_TRACK),
error)) { error)) {
LogError(error); LogError(error);
afCloseFile(fh);
return; return;
} }
@ -240,8 +242,6 @@ audiofile_stream_decode(Decoder &decoder, InputStream &is)
cmd = DecoderCommand::NONE; cmd = DecoderCommand::NONE;
} }
} while (cmd == DecoderCommand::NONE); } while (cmd == DecoderCommand::NONE);
afCloseFile(fh);
} }
gcc_pure gcc_pure