[vorbis] ov_open/ov_test weirdness

Thomas Fjellstrom tfjellstrom at telusplanet.net
Mon Dec 9 05:55:01 PST 2002



Hi,

I've been playing with a little player, and it seems I can't ov_open a file 
twice?

heres a snipit...

<p>#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <vorbis/vorbisfile.h>

OggVorbis_File vf;
FILE *f = NULL;

int main(int argc, char **argv)
{
        char *file = NULL;
        int err = 0;
        
        if(argc < 2) {
                fprintf(stderr, "usage: %s <file.ogg>\n", argv[0]);
                return -1;
        }

        file = argv[2];
        
        f = fopen(argv[1], "rb");
        if(!f) {
                fprintf(stderr, "fopen for '%s' failed: %s", file, strerror(errno));
                return -1;
        }

        err = ov_test(f, &vf, NULL, 0);
        if(err < 0) {
                char *tmp = "What?";
                switch(err) {
                        case OV_EREAD: tmp = "A read from media returned an error."; break;
                        case OV_ENOTVORBIS: tmp = "Bitstream is not Vorbis data."; break;
                        case OV_EVERSION: tmp = "Vorbis version mismatch."; break;
                        case OV_EBADHEADER: tmp = "Invalid Vorbis bitstream header."; break;
                        case OV_EFAULT: tmp = "Internal logic fault; indicates a bug or heap/stack 
corruption."; break;
                        default: tmp = "Unknown error"; break;
                }
                fprintf(stderr, "error: %s\n", tmp);
                return -1;
        }
        
        ov_clear(&vf);
        
        fclose(f);
        
        fprintf(stderr, "Ok1\n");
        
        f = fopen(argv[1], "rb");
        if(!f) {
                fprintf(stderr, "fopen for '%s' failed: %s", file, strerror(errno));
                return -1;
        }

        err = ov_open(f, &vf, NULL, 0);
        if(err < 0) {
                char *tmp = "What?";
                switch(err) {
                        case OV_EREAD: tmp = "A read from media returned an error."; break;
                        case OV_ENOTVORBIS: tmp = "Bitstream is not Vorbis data."; break;
                        case OV_EVERSION: tmp = "Vorbis version mismatch."; break;
                        case OV_EBADHEADER: tmp = "Invalid Vorbis bitstream header."; break;
                        case OV_EFAULT: tmp = "Internal logic fault; indicates a bug or heap/stack 
corruption."; break;
                        default: tmp = "Unknown error"; break;
                }
                fprintf(stderr, "error: %s\n", tmp);
                return -1;
        }
        
        ov_clear(&vf);
        
        fclose(f);
        
        fprintf(stderr, "Ok2\n");
        
        return 0;
        
}

it just doesn't work. Ok1 is printed. But I get OV_ENOTVORBIS the second time, 
everytime. Even if I use ov_test the first time.. Oh and ov_test acts the 
same as ov_open, I don't have to call ov_test_open (in fact ov_test_open 
fails...)

Also I've tried using 2 different OggVorbis_File structs for the two tries, 
but that doesn't help either.

ystem specs:
Debian Cid, Linux/AMD k7
libvorbisfile 1.0
libogg 1.0
libvorbis 1.0


-- 
Thomas Fjellstrom
tfjellstrom at telusplanet.net
http://strangesoft.net
--- >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-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 mailing list