From b28cd725d82fbe0259695c508715c27d7aaacb40 Mon Sep 17 00:00:00 2001 From: k-m_schindler Date: Sun, 23 Nov 2014 00:02:56 +0000 Subject: Fix timeline for songs with no start_time master. Thanks to rudi_s. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@3107 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/media/UAudioDecoder_FFmpeg.pas | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/media/UAudioDecoder_FFmpeg.pas b/src/media/UAudioDecoder_FFmpeg.pas index 34b8d244..6761d541 100644 --- a/src/media/UAudioDecoder_FFmpeg.pas +++ b/src/media/UAudioDecoder_FFmpeg.pas @@ -64,6 +64,7 @@ uses avformat, avutil, avio, + ctypes, rational, UMusic, UIni, @@ -493,11 +494,17 @@ begin end; function TFFmpegDecodeStream.GetLength(): real; +var + start_time: cint64; begin - // do not forget to consider the start_time value here + start_time := fFormatCtx^.start_time; + // AV_NOPTS_VALUE is returned if no explicit start_time is available. + if start_time = AV_NOPTS_VALUE then + start_time := 0; + // there is a type size mismatch warnign because start_time and duration are cint64. // So, in principle there could be an overflow when doing the sum. - Result := (fFormatCtx^.start_time + fFormatCtx^.duration) / AV_TIME_BASE; + Result := (start_time + fFormatCtx^.duration) / AV_TIME_BASE; end; function TFFmpegDecodeStream.GetAudioFormatInfo(): TAudioFormatInfo; -- cgit v1.2.3