Commit 256ee7a8 authored by Max Kellermann's avatar Max Kellermann

decoder/audiofile: use AtScopeExit()

parent 07a51957
...@@ -23,6 +23,7 @@ ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment