0
0

Hhi,
As I don’t see the same sample in package,
I try to translate stream file C sample on delphi.
I see some strange thing in function declaration of TFSoundSeekCallback
which is declared as a procedure (in help and C sample, it is a function)
and Pos is defined as a cardinal (unsigned int) (signed int in C).
I see that sometimes fmod needs to seek negative.

As my translation does not work, I modify TFSoundSeekCallback to bethe same as C declaration but doesn’t work better.

Callback functions seems to be correctly called but when I trace on an mp3 file , program always ended after that :

-M- 11:33:00,711 Seek :0-2-0
-M- 11:33:00,711 Tell :75650
-M- 11:33:00,711 Seek :0-0-0
-M- 11:33:00,711 Seek :0-0-0
-M- 11:33:00,711 Seek :-128-2-0
-M- 11:33:00,711 Read :3
-M- 11:33:00,711 Seek :-10-2-0
-M- 11:33:00,711 Read :3
-M- 11:33:00,711 Seek :0-0-0
-M- 11:33:00,711 Read :16
-M- 11:33:00,711 Seek :0-0-0
-M- 11:33:00,711 Tell :0
-M- 11:33:00,711 Seek :0-0-0
-M- 11:33:00,711 Seek :0-0-0
-M- 11:33:00,711 Read :24

// Here are callback functions :

Function FmodOpen(Name: PChar): Cardinal; stdcall;
Begin
Result:=FileOpen(Name,fmOpenRead);
End;

Procedure FmodClose(Handle: Cardinal); stdcall;
Begin
FileClose(Handle);
End;

// Function FModSeek(Handle: Cardinal; Pos: Integer; Mode: Byte): Cardinal; stdcall;
Procedure FModSeek(Handle: Cardinal; Pos: Integer; Mode: Byte); stdcall;
Var R:Integer;
Begin
R:=FileSeek(Handle,Pos,Mode);
If R>-1 Then R:=0
Else R:=1;
Writeln(‘Seek :’,Pos,’-‘,Mode,’-‘,R);
// Result:=R;
End;

function FModTell(Handle: Cardinal): Cardinal; stdcall;
Var R:Integer;
Begin
R:=FileSeek(Handle,0,1);
Writeln(‘Tell :’,R);
Result:=R;
End;

//=====================================
// here is open part :

if not FSOUND_Init(44100, 16, 0) then
begin
WriteLn(‘Error! Initializing’);
WriteLn(FMOD_ErrorString(FSOUND_GetError));
FSOUND_Close;
Exit;
end;

// ==========================================================================================
// OPEN STREAM
// ==========================================================================================
stream := FSOUND_Stream_Open(PChar(ParamStr(1)), FSOUND_NORMAL or FSOUND_MPEGACCURATE, 0, 0);
if Stream = nil then
begin
WriteLn(‘Error! Opening stream’);
WriteLn(FMOD_ErrorString(FSOUND_GetError));
FSOUND_Close;
Exit;
end;

Can you tell mee what was wrong ?
Best regards
JCL

  • You must to post comments
0
0

But I don’t know why seek callback procedure is different from C to delphi ?

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.