Commit 0be5fbdc authored by Max Kellermann's avatar Max Kellermann

decoder/wavpack: use AtScopeExit()

parent ae7e25ea
...@@ -279,6 +279,10 @@ wavpack_scan_file(Path path_fs, ...@@ -279,6 +279,10 @@ wavpack_scan_file(Path path_fs,
return false; return false;
} }
AtScopeExit(wpc) {
WavpackCloseFile(wpc);
};
const auto duration = const auto duration =
SongTime::FromScale<uint64_t>(WavpackGetNumSamples(wpc), SongTime::FromScale<uint64_t>(WavpackGetNumSamples(wpc),
WavpackGetSampleRate(wpc)); WavpackGetSampleRate(wpc));
...@@ -312,8 +316,6 @@ wavpack_scan_file(Path path_fs, ...@@ -312,8 +316,6 @@ wavpack_scan_file(Path path_fs,
} }
} }
WavpackCloseFile(wpc);
return true; return true;
} }
...@@ -561,13 +563,15 @@ wavpack_filedecode(DecoderClient &client, Path path_fs) ...@@ -561,13 +563,15 @@ wavpack_filedecode(DecoderClient &client, Path path_fs)
return; return;
} }
AtScopeExit(wpc) {
WavpackCloseFile(wpc);
};
ReplayGainInfo rgi; ReplayGainInfo rgi;
if (wavpack_replaygain(rgi, wpc)) if (wavpack_replaygain(rgi, wpc))
client.SubmitReplayGain(&rgi); client.SubmitReplayGain(&rgi);
wavpack_decode(client, wpc, true); wavpack_decode(client, wpc, true);
WavpackCloseFile(wpc);
} }
static char const *const wavpack_suffixes[] = { static char const *const wavpack_suffixes[] = {
......
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