Commit 89b1e27d authored by Max Kellermann's avatar Max Kellermann

decoder/audiofile: merge duplicate code into CheckAudioFormat(AFfilehandle)

parent 1dcaf8f7
...@@ -180,6 +180,14 @@ audiofile_setup_sample_format(AFfilehandle af_fp) ...@@ -180,6 +180,14 @@ audiofile_setup_sample_format(AFfilehandle af_fp)
return audiofile_bits_to_sample_format(bits); return audiofile_bits_to_sample_format(bits);
} }
static AudioFormat
CheckAudioFormat(AFfilehandle fh)
{
return CheckAudioFormat(afGetRate(fh, AF_DEFAULT_TRACK),
audiofile_setup_sample_format(fh),
afGetVirtualChannels(fh, AF_DEFAULT_TRACK));
}
static void static void
audiofile_stream_decode(DecoderClient &client, InputStream &is) audiofile_stream_decode(DecoderClient &client, InputStream &is)
{ {
...@@ -197,11 +205,7 @@ audiofile_stream_decode(DecoderClient &client, InputStream &is) ...@@ -197,11 +205,7 @@ audiofile_stream_decode(DecoderClient &client, InputStream &is)
AtScopeExit(fh) { afCloseFile(fh); }; AtScopeExit(fh) { afCloseFile(fh); };
const auto audio_format = const auto audio_format = CheckAudioFormat(fh);
CheckAudioFormat(afGetRate(fh, AF_DEFAULT_TRACK),
audiofile_setup_sample_format(fh),
afGetVirtualChannels(fh, AF_DEFAULT_TRACK));
const auto total_time = audiofile_get_duration(fh); const auto total_time = audiofile_get_duration(fh);
const uint16_t kbit_rate = (uint16_t) const uint16_t kbit_rate = (uint16_t)
...@@ -254,9 +258,7 @@ audiofile_scan_stream(InputStream &is, TagHandler &handler) noexcept ...@@ -254,9 +258,7 @@ audiofile_scan_stream(InputStream &is, TagHandler &handler) noexcept
handler.OnDuration(audiofile_get_duration(fh)); handler.OnDuration(audiofile_get_duration(fh));
try { try {
handler.OnAudioFormat(CheckAudioFormat(afGetRate(fh, AF_DEFAULT_TRACK), handler.OnAudioFormat(CheckAudioFormat(fh));
audiofile_setup_sample_format(fh),
afGetVirtualChannels(fh, AF_DEFAULT_TRACK)));
} catch (...) { } catch (...) {
} }
......
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