|
Hi
Function tuos_player.inputpositionTime I was getting random errors, i think due to no value being set when isAssigned=false
If I set initial value tmp:float=0.0; solved the problem, whether a better appraoch would be to set more values ie
Original Code:
function Tuos_Player.InputPositionTime(InputIndex: cint32): TTime;
var
tmp: float;
h, m, s, ms: word;
begin
Result := sysutils.EncodeTime(0, 0, 0, 0);
if (isAssigned = True) then tmp := InputPositionSeconds(InputIndex);
{$IF DEFINED(debug)}
WriteLn('InputPositionTime(): InputPositionSeconds: '+ floattostr(tmp));
{$endif}
ms := trunc(frac(tmp) * 1000);
h := trunc(tmp / 3600);
m := trunc(tmp / 60 - h * 60);
s := trunc(tmp - (h * 3600 + m * 60));
Result := sysutils.EncodeTime(h, m, s, ms);
{$IF DEFINED(debug)}
WriteLn('EncodeTime(): '+ timetostr(Result));
{$endif}
end;
Suggested Change
function Tuos_Player.InputPositionTime(InputIndex: cint32): TTime;
var
tmp: float=0.0; //set def value
h:word=0; //set def value
m:word=0; //set def value
s:word=0; //set def value
ms:word=0; //set def value
begin
if (isAssigned = True) then
begin
tmp := InputPositionSeconds(InputIndex);
{$IF DEFINED(debug)}
WriteLn('InputPositionTime(): InputPositionSeconds: '+ floattostr(tmp));
{$endif}
ms := trunc(frac(tmp) * 1000);
h := trunc(tmp / 3600);
m := trunc(tmp / 60 - h * 60);
s := trunc(tmp - (h * 3600 + m * 60));
end;
Result := sysutils.EncodeTime(h, m, s, ms);
{$IF DEFINED(debug)}
WriteLn('EncodeTime(): '+ timetostr(Result));
{$endif}
end;
|