decoder/wavpack: merge duplicate code into Scan()

This commit is contained in:
Max Kellermann 2018-07-07 13:54:02 +02:00
parent d4ce6049c9
commit 1245b4a49f

View File

@ -580,6 +580,19 @@ wavpack_filedecode(DecoderClient &client, Path path_fs)
wavpack_decode(client, wpc, true);
}
static void
Scan(WavpackContext *wpc,TagHandler &handler) noexcept
{
try {
handler.OnAudioFormat(CheckAudioFormat(wpc));
} catch (...) {
}
const auto duration = GetDuration(wpc);
if (!duration.IsNegative())
handler.OnDuration(SongTime(duration));
}
/*
* Reads metainfo from the specified file.
*/
@ -598,15 +611,7 @@ wavpack_scan_file(Path path_fs, TagHandler &handler) noexcept
WavpackCloseFile(wpc);
};
try {
handler.OnAudioFormat(CheckAudioFormat(wpc));
} catch (...) {
}
const auto duration = GetDuration(wpc);
if (!duration.IsNegative())
handler.OnDuration(SongTime(duration));
Scan(wpc, handler);
return true;
}
@ -627,15 +632,7 @@ wavpack_scan_stream(InputStream &is, TagHandler &handler) noexcept
WavpackCloseFile(wpc);
};
try {
handler.OnAudioFormat(CheckAudioFormat(wpc));
} catch (...) {
}
const auto duration = GetDuration(wpc);
if (!duration.IsNegative())
handler.OnDuration(SongTime(duration));
Scan(wpc, handler);
return true;
}