From 3a5bb966a85909418968f68473786cd9958e3b17 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Wed, 13 Feb 2019 14:52:07 +0200 Subject: [PATCH] Fixed: ffmpeg deocde getLength function was placeholder --HG-- branch : develop --- code/nel/src/sound/audio_decoder_ffmpeg.cpp | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/code/nel/src/sound/audio_decoder_ffmpeg.cpp b/code/nel/src/sound/audio_decoder_ffmpeg.cpp index dea8368d2..158c0ddc3 100644 --- a/code/nel/src/sound/audio_decoder_ffmpeg.cpp +++ b/code/nel/src/sound/audio_decoder_ffmpeg.cpp @@ -287,18 +287,7 @@ bool CAudioDecoderFfmpeg::getInfo(NLMISC::IStream *stream, std::string &artist, } } - if (ffmpeg._FormatContext->duration != AV_NOPTS_VALUE) - { - length = ffmpeg._FormatContext->duration * av_q2d(AV_TIME_BASE_Q); - } - else if (ffmpeg._FormatContext->streams[ffmpeg._AudioStreamIndex]->duration != AV_NOPTS_VALUE) - { - length = ffmpeg._FormatContext->streams[ffmpeg._AudioStreamIndex]->duration * av_q2d(ffmpeg._FormatContext->streams[ffmpeg._AudioStreamIndex]->time_base); - } - else - { - length = 0.f; - } + length = ffmpeg.getLength(); return true; } @@ -420,9 +409,16 @@ bool CAudioDecoderFfmpeg::isMusicEnded() float CAudioDecoderFfmpeg::getLength() { - printf(">> CAudioDecoderFfmpeg::getLength\n"); - // TODO: return (float)ov_time_total(&_OggVorbisFile, -1); - return 0.f; + float length = 0.f; + if (_FormatContext->duration != AV_NOPTS_VALUE) + { + length = _FormatContext->duration * av_q2d(AV_TIME_BASE_Q); + } + else if (_FormatContext->streams[_AudioStreamIndex]->duration != AV_NOPTS_VALUE) + { + length = _FormatContext->streams[_AudioStreamIndex]->duration * av_q2d(_FormatContext->streams[_AudioStreamIndex]->time_base); + } + return length; } void CAudioDecoderFfmpeg::setLooping(bool loop) -- 2.11.4.GIT