aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder/plugins
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-08-30 00:53:14 +0200
committerMax Kellermann <max@duempel.org>2014-08-30 00:53:14 +0200
commitbc5b5afcbfdf0772c2cee78e09a37758b81db5da (patch)
treef774fadb7789c6fd7352232b1266d0932d5dca7a /src/decoder/plugins
parentb373c53ce4feedfc6a0c1750599ab723997a6744 (diff)
downloadmpd-bc5b5afcbfdf0772c2cee78e09a37758b81db5da.tar.gz
mpd-bc5b5afcbfdf0772c2cee78e09a37758b81db5da.tar.xz
mpd-bc5b5afcbfdf0772c2cee78e09a37758b81db5da.zip
decoder/sndfile: refactor frame_to_time()
Diffstat (limited to 'src/decoder/plugins')
-rw-r--r--src/decoder/plugins/SndfileDecoderPlugin.cxx14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/decoder/plugins/SndfileDecoderPlugin.cxx b/src/decoder/plugins/SndfileDecoderPlugin.cxx
index 558101089..6adba02cc 100644
--- a/src/decoder/plugins/SndfileDecoderPlugin.cxx
+++ b/src/decoder/plugins/SndfileDecoderPlugin.cxx
@@ -140,11 +140,10 @@ static SF_VIRTUAL_IO vio = {
/**
* Converts a frame number to a timestamp (in seconds).
*/
-static SongTime
-frame_to_time(sf_count_t frame, const AudioFormat *audio_format)
+static constexpr SongTime
+sndfile_duration(const SF_INFO &info)
{
- return SongTime::FromScale<uint64_t>(frame,
- audio_format->sample_rate);
+ return SongTime::FromScale<uint64_t>(info.frames, info.samplerate);
}
static void
@@ -174,7 +173,7 @@ sndfile_stream_decode(Decoder &decoder, InputStream &is)
}
decoder_initialized(decoder, audio_format, info.seekable,
- frame_to_time(info.frames, &audio_format));
+ sndfile_duration(info));
int buffer[4096];
@@ -246,9 +245,8 @@ sndfile_scan_stream(InputStream &is,
return false;
}
- const auto duration =
- SongTime::FromScale<uint64_t>(info.frames, info.samplerate);
- tag_handler_invoke_duration(handler, handler_ctx, duration);
+ tag_handler_invoke_duration(handler, handler_ctx,
+ sndfile_duration(info));
for (auto i : sndfile_tags)
sndfile_handle_tag(sf, i.str, i.tag, handler, handler_ctx);