Hi,
First of all, thanks very much to all the people that contributed to this great
project.
I
have written a Lame (mp3 encoding library) wrapper based on JNA, for
which I have made a first alpha relase. It is called Lamejb and can be
found at http://lamejb.sourceforge.net/
At
the moment I have one (known) bug on Windows and I would be grateful if
anyone of you could give me an idea of why this does not work as
expected.
I have the following mappings declared for the fopen and fclose C library
functions:
public interface FileUtil extends Library
{
FileUtil INSTANCE =
(FileUtil)Native.loadLibrary((Platform.isWindows() ? "msvcrt" : "c"),
FileUtil.class);
/**
*
<pre>FILE *fopen(const char *filename, const char *mode); </pre>
*/
Pointer fopen(String filename,String mode);
/**
* <pre>int fclose(FILE *stream);</pre>
*/
int fclose(Pointer stream);
}
These
are in turn used by another mapping to a native library call that takes
a file pointer as argument and writes some tags in a file (for variable
bit rates). This is the sequence of calls:
Pointer fp = FileUtil.INSTANCE.fopen( mp3File, "rb+" );
Lame.INSTANCE.lame_mp3_tags_fid( flags, fp );
FileUtil.INSTANCE.fclose( fp );
The second call (Lame.INSTANCE.lame_mp3_tags_fid( flags, fp )) crashes the VM on
Windows, but works on Linux.
I have found out that what
makes the VM crash in Windows is a call to the native function fseek,
specifically:
fseek(FILE *_File, long _Offset, int _Origin)
Does anyone have an idea of the reason why this happens?
Thanks in advance for your help.
Luigi