diff options
author | Max Kellermann <max@duempel.org> | 2014-08-29 20:52:39 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-08-29 21:40:15 +0200 |
commit | d9d97bd17bf0d9469dcf00120d3d3fdab87299bc (patch) | |
tree | d7abd9d0cbc6e417aaf4427740bf47207f47d7fa /src/decoder/plugins/VorbisDecoderPlugin.cxx | |
parent | 94f6380d693b8bece655885d37495a3a73c78b62 (diff) | |
download | mpd-d9d97bd17bf0d9469dcf00120d3d3fdab87299bc.tar.gz mpd-d9d97bd17bf0d9469dcf00120d3d3fdab87299bc.tar.xz mpd-d9d97bd17bf0d9469dcf00120d3d3fdab87299bc.zip |
DecoderAPI: pass SignedSongTime to decoder_initialized()
Diffstat (limited to 'src/decoder/plugins/VorbisDecoderPlugin.cxx')
-rw-r--r-- | src/decoder/plugins/VorbisDecoderPlugin.cxx | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/decoder/plugins/VorbisDecoderPlugin.cxx b/src/decoder/plugins/VorbisDecoderPlugin.cxx index e740cede6..8348407d6 100644 --- a/src/decoder/plugins/VorbisDecoderPlugin.cxx +++ b/src/decoder/plugins/VorbisDecoderPlugin.cxx @@ -202,6 +202,16 @@ vorbis_init(gcc_unused const config_param ¶m) return true; } +gcc_pure +static SignedSongTime +vorbis_duration(OggVorbis_File &vf) +{ + auto total = ov_time_total(&vf, -1); + return total >= 0 + ? SignedSongTime::FromS(total) + : SignedSongTime::Negative(); +} + static void vorbis_stream_decode(Decoder &decoder, InputStream &input_stream) @@ -237,11 +247,8 @@ vorbis_stream_decode(Decoder &decoder, return; } - float total_time = ov_time_total(&vf, -1); - if (total_time < 0) - total_time = 0; - - decoder_initialized(decoder, audio_format, vis.seekable, total_time); + decoder_initialized(decoder, audio_format, vis.seekable, + vorbis_duration(vf)); #ifdef HAVE_TREMOR char buffer[4096]; |