[vorbis-dev] ov_clear segfaults?

Greg Holt greg at Brim.Net
Wed Dec 13 14:42:57 PST 2000



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 at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.




More information about the Vorbis-dev mailing list