diff options
author | Max Kellermann <max@duempel.org> | 2014-08-26 21:52:28 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-08-26 22:27:04 +0200 |
commit | 0c2d767f6fca030a8da3202c05b3eb80ba176ef1 (patch) | |
tree | 481acab9b4a1fadf8e208142bde510167b406d7e /src/decoder/plugins/FfmpegDecoderPlugin.cxx | |
parent | 02e697032f7f375e67acc349ada6d849edf51aa3 (diff) | |
download | mpd-0c2d767f6fca030a8da3202c05b3eb80ba176ef1.tar.gz mpd-0c2d767f6fca030a8da3202c05b3eb80ba176ef1.tar.xz mpd-0c2d767f6fca030a8da3202c05b3eb80ba176ef1.zip |
DecoderAPI: use std::chrono::duration for decoder_seek*()
For type safety and code readability.
Diffstat (limited to '')
-rw-r--r-- | src/decoder/plugins/FfmpegDecoderPlugin.cxx | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/decoder/plugins/FfmpegDecoderPlugin.cxx b/src/decoder/plugins/FfmpegDecoderPlugin.cxx index 2787d3705..e328da24b 100644 --- a/src/decoder/plugins/FfmpegDecoderPlugin.cxx +++ b/src/decoder/plugins/FfmpegDecoderPlugin.cxx @@ -210,11 +210,19 @@ time_from_ffmpeg(int64_t t, const AVRational time_base) / (double)1024; } +template<typename Ratio> +static constexpr AVRational +RatioToAVRational() +{ + return { Ratio::num, Ratio::den }; +} + gcc_const static int64_t -time_to_ffmpeg(double t_ms, const AVRational time_base) +time_to_ffmpeg(SongTime t, const AVRational time_base) { - return av_rescale_q(t_ms, (AVRational){1, 1000}, + return av_rescale_q(t.count(), + RatioToAVRational<SongTime::period>(), time_base); } @@ -547,7 +555,7 @@ ffmpeg_decode(Decoder &decoder, InputStream &input) if (cmd == DecoderCommand::SEEK) { int64_t where = - time_to_ffmpeg(decoder_seek_where_ms(decoder), + time_to_ffmpeg(decoder_seek_time(decoder), av_stream->time_base) + start_time_fallback(*av_stream); |