decoder/mpg123: use AtScopeExit() to call mpg123_delete() during scan
This commit is contained in:
parent
cfe34647e1
commit
cacc1ffdad
@ -287,20 +287,19 @@ mpd_mpg123_scan_file(Path path_fs, TagHandler &handler) noexcept
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AtScopeExit(handle) { mpg123_delete(handle); };
|
||||||
|
|
||||||
AudioFormat audio_format;
|
AudioFormat audio_format;
|
||||||
try {
|
try {
|
||||||
if (!mpd_mpg123_open(handle, path_fs.c_str(), audio_format)) {
|
if (!mpd_mpg123_open(handle, path_fs.c_str(), audio_format)) {
|
||||||
mpg123_delete(handle);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
mpg123_delete(handle);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const off_t num_samples = mpg123_length(handle);
|
const off_t num_samples = mpg123_length(handle);
|
||||||
if (num_samples <= 0) {
|
if (num_samples <= 0) {
|
||||||
mpg123_delete(handle);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,8 +307,6 @@ mpd_mpg123_scan_file(Path path_fs, TagHandler &handler) noexcept
|
|||||||
|
|
||||||
/* ID3 tag support not yet implemented */
|
/* ID3 tag support not yet implemented */
|
||||||
|
|
||||||
mpg123_delete(handle);
|
|
||||||
|
|
||||||
const auto duration =
|
const auto duration =
|
||||||
SongTime::FromScale<uint64_t>(num_samples,
|
SongTime::FromScale<uint64_t>(num_samples,
|
||||||
audio_format.sample_rate);
|
audio_format.sample_rate);
|
||||||
|
Loading…
Reference in New Issue
Block a user