

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
3 messages in net.java.dev.jna.usersRe: [jna-users] fseek in windows cras...| From | Sent On | Attachments |
|---|---|---|
| Luigi Bitonti | Sep 4, 2008 7:42 am | |
| Timothy Wall | Sep 4, 2008 9:30 am | |
| Luigi Bitonti | Sep 11, 2008 6:55 am |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | Re: [jna-users] fseek in windows crashes JVM | Actions... |
|---|---|---|
| From: | Luigi Bitonti (ukna...@yahoo.com) | |
| Date: | Sep 11, 2008 6:55:37 am | |
| List: | net.java.dev.jna.users | |
Timothy,
Thanks a lot. The answer is: "no, the equivalent native code doesn't work on
windows". I was just asking the wrong question and getting to the wrong
conclusions...
Anyway, I have created mappings for the blade_enc API (and made a new release)
and now everything seems to work properly also on windows.
Thanks again Luigi
--- On Thu, 9/4/08, Timothy Wall <twal...@dev.java.net> wrote: From: Timothy Wall <twal...@dev.java.net> Subject: Re: [jna-users] fseek in windows crashes JVM To: use...@jna.dev.java.net Date: Thursday, September 4, 2008, 5:30 PM
Does the equivalent native code work on windows? You should be able to write a small wrapper to test it.
On Sep 4, 2008, at 10:43 AM, Luigi Bitonti wrote:
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







