[vorbis] Using vorbisfile with an in-memory file instead of FILE*

Olaf van der Spek Olaf at XCC.TMFWeb.NL
Thu Dec 28 06:47:13 PST 2000



----- Original Message -----
From: "Michael Smith" <msmith at labyrinth.net.au>
To: <vorbis at xiph.org>
Sent: Thursday, December 28, 2000 1:31 AM
Subject: Re: [vorbis] Using vorbisfile with an in-memory file instead of
FILE*

>
> >
> >extern int ov_open(FILE *f,OggVorbis_File *vf,char *initial,long ibytes);
> >
> >The third parameter, initial is not a const. Is this because of problems
> >with C or is initial being modified?
>
> Neither. initial could be const, but isn't. libvorbis doesn't make much
> (any?) use of the const keyword, though there are plenty of places it
would
> probably be good to use.

Is it planned to add const?
And maybe initial could be changed to const void*, so you don't need a cast
if you have for example an unsigned char*.

Also, I tried to use an in-memory file with the following code, but that
code hung in ov_open.
I didn't setup the callbacks yet, but I thought that wasn't necessary
because of the real (empty) file.
Of course I'm going to setup callbacks in the future.
When I use the fwrite, but not the rewind, it seems to work.
When I use both fwrite and rewind, but not initial and initial size, it
works also.
What did I do wrong?

 FILE* f = tmpfile();
 OggVorbis_File vf;
 if (!f)
  error = 1;
 /*
 else if (fwrite(get_data(), 1, get_size(), f) != get_size())
 {
  fclose(f);
  error = 1;
 }
 */
 else
 {
  // rewind(f);
  if (ov_open(f, &vf, const_cast<char*>(reinterpret_cast<const
char*>(get_data())), get_size()) < 0)

>
> 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-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.
>

--- >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