aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authork-m_schindler <k-m_schindler@b956fd51-792f-4845-bead-9b4dfca2ff2c>2014-11-23 00:02:56 +0000
committerk-m_schindler <k-m_schindler@b956fd51-792f-4845-bead-9b4dfca2ff2c>2014-11-23 00:02:56 +0000
commitb28cd725d82fbe0259695c508715c27d7aaacb40 (patch)
tree01631be8f25027f2a13a5d548fa8f8ceb1978969 /src
parent6f2e3e937bb4da26e1464d93073907529b727308 (diff)
downloadusdx-b28cd725d82fbe0259695c508715c27d7aaacb40.tar.gz
usdx-b28cd725d82fbe0259695c508715c27d7aaacb40.tar.xz
usdx-b28cd725d82fbe0259695c508715c27d7aaacb40.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/media/UAudioDecoder_FFmpeg.pas11
1 files 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;