Commit 1245b4a4 authored by Max Kellermann's avatar Max Kellermann

decoder/wavpack: merge duplicate code into Scan()

parent d4ce6049
......@@ -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;
}
......
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