0
0

Hello

I’m just discover fmod and i’m trying to translate the stream example write in c++
When I execute, there is a memory access violation and I don’t understand why :(
Somebody can help me please ?

[code:3epdgv52]...
var
fic : file;

function myopen(name:PAnsiChar) : cardinal; stdcall;
begin
AssignFile(fic, name);
Reset(fic);
result := 1;
end;

procedure myclose(handle:cardinal); stdcall;
begin
closefile(fic);
end;

function myread(buffer:pointer; size:cardinal; handle:cardinal) : cardinal; stdcall;
var
count : integer;
begin
blockread(fic, buffer^, sizeof(buffer), count);
result := count;
end;

procedure myseek(handle:cardinal; pos:cardinal; mode:byte); stdcall;
begin
seek( fic, pos );
end;

function mytell(handle:cardinal) : cardinal; stdcall;
begin
result := filepos( fic );
end;
...

FSOUND_File_SetCallbacks(myopen, myclose, myread, myseek, mytell);
music := ‘c:\.....’;
stream := FSOUND_Stream_Open( PChar(music), FSOUND_NORMAL or FSOUND_MPEGACCURATE, 0, 6181149 ); //6181149 is the length of the used file
[/code:3epdgv52]

Thanks

  • You must to post comments
0
0

I’m not sure if it’s related to your problem, but under VB you [b:2r3oip6p]must[/b:2r3oip6p] call fsound_close before your application finishes or else you get a exception in the VB IDE. Even if an error elsewhere in the code which causes your application to end executing early – you still have to enter fsound_close into the immediate window before allowing execution to finish.

  • You must to post comments
0
0

I don’t give all my source code and I call fsound_close beforemy app finishes
I’ve put some log and myread, myseek and mytell are called many times before the error occurs…

  • You must to post comments
0
0

Donwload the PureBasic binding : i ve translated this example using win32 api, it would be easy to do the same thing with Delphi :)

  • You must to post comments
0
0

Where can I download your example ?

  • You must to post comments
0
0

In the [url=http://fmod.org/ifmoddownload.html:1xj2vt1f]download[/url:1xj2vt1f] section ๐Ÿ˜‰

  • You must to post comments
0
0

sorry,
i didn’t see it in download section … i’ll take timeto see source code after new year ๐Ÿ˜‰

thank you

  • You must to post comments
0
0

If you look at C declaration of seek callback (and help) you can see that
1) Pos is a signed integer not an unsigned one like cardinal : Fmod can seek negative
2) You need to test mode var in order to seek from end, current pos, or beginning of file
3) normally seek callback is a function and not a proc : must return 0 or > if error

BR
JCL

  • You must to post comments
Showing 7 results
Your Answer

Please first to submit.