Hi guys, I'm working doing the Java->JNI->OggVorbis thing. As a test to get me going, I've just written a quick routine that dumps info about the file test.ogg in the current directory. The problem arises when I call ov_clear. I get a segfault everytime. Note that I am *not* doing any decoding (ov_read) at all, just ov_comment and ov_info. Should I only call ov_clear if I have called ov_read? If I comment out the ov_clear, everything works fine. This is good, as it means I'm on the right track and I at least *partially* know what I'm doing. :) Here's the code [try and ignore all the Java required stuff]: #include <jni.h> #include "com_vorbis_ogg_HelloWorld.h" #include <stdio.h> #include <stdlib.h> #include <math.h> #include "vorbis/codec.h" #include "vorbis/vorbisfile.h" #ifdef _WIN32 #include <io.h> #include <fcntl.h> #endif JNIEXPORT void JNICALL Java_com_vorbis_ogg_HelloWorld_displayHelloWorld (JNIEnv *env, jobject obj) { OggVorbis_File vf; FILE *fp; char **ptr; vorbis_info *vi; fp = fopen("test.ogg", "r"); if (!fp) { fprintf(stderr, "File not found.\n"); return; } if( ov_open(fp, &vf, NULL, 0) < 0 ) { fprintf(stderr,"File does not appear to be an Ogg bitstream.\n"); return; } ptr = ov_comment(&vf, -1)->user_comments; while(*ptr){ fprintf(stderr, "%s\n", *ptr); ++ptr; } vi = ov_info(&vf, -1); fprintf( stderr, "\nBitstream is %d channel, %ldHz\n", vi->channels, vi->rate ); fprintf(stderr, "Encoded by: %s\n\n", ov_comment(&vf, -1)->vendor); ov_clear(&vf); // HERE'S THE PROBLEM CHILD RIGHT NOW fclose(fp); return; } -- Greg Holt --- >8 ---- List archives: http://www.xiph.org/archives/ Ogg project homepage: http://www.xiph.org/ogg/ To unsubscribe from this list, send a message to 'vorbis-dev-request@xiph.org' containing only the word 'unsubscribe' in the body. No subject is needed. Unsubscribe messages sent to the list will be ignored/filtered.
At 04:42 PM 12/13/00 -0600, you wrote:>Hi guys, > >I'm working doing the Java->JNI->OggVorbis thing. As a test to get me >going, I've just written a quick routine that dumps info about the file >test.ogg in the current directory. > >The problem arises when I call ov_clear. I get a segfault everytime. Note >that I am *not* doing any decoding (ov_read) at all, just ov_comment and >ov_info. Should I only call ov_clear if I have called ov_read? >That should work correctly. For a test (to see where the problem might be) what happens if you comment out the java stuff, and just rename that function to main? Ahh.. I see you're doing some stuff for win32 - if that's your actual dev platform, then I can see one potential problem. You MUST do fopen(..., "rb") - the binary tells it to open the file in binary mode. Windows does really weird things if you don't, in unpredictable ways. The other thing to check for (again assuming you're doing this under windows) is that you're using the 'right' version of the C runtime. You should usually use the multithreaded DLL unless there's a good reason to do otherwise. This can make things behave strangely too if libraries/applications are linked against different C runtimes. If I'm completely on the wrong track here, or these don't help anyway, could you try and find out exactly where it's crashing (i.e. line number)? Michael --- >8 ---- List archives: http://www.xiph.org/archives/ Ogg project homepage: http://www.xiph.org/ogg/ To unsubscribe from this list, send a message to 'vorbis-dev-request@xiph.org' containing only the word 'unsubscribe' in the body. No subject is needed. Unsubscribe messages sent to the list will be ignored/filtered.
> #include "com_vorbis_ogg_HelloWorld.h"Shouldn't this be com_ogg_vorbis...?> ov_clear(&vf); // HERE'S THE PROBLEM CHILD RIGHT NOW > > fclose(fp);I think ov_clear() does the fclose() already. That would explain it ;-) Dagdag, Segher --- >8 ---- List archives: http://www.xiph.org/archives/ Ogg project homepage: http://www.xiph.org/ogg/ To unsubscribe from this list, send a message to 'vorbis-dev-request@xiph.org' containing only the word 'unsubscribe' in the body. No subject is needed. Unsubscribe messages sent to the list will be ignored/filtered.