[vorbis] Streaming ogg from filepointer pointing to archive of many oggs. Ogg stream does not stop after end of one ogg file - what to do ?

Michael Smith msmith at xiph.org
Wed Apr 21 18:25:21 PDT 2004



On Thursday 22 April 2004 05:01, Andre Krause wrote:
> Hello,
> I'm currently trying to implement streaming off ogg-files out of an archive
> file using SDL and SDL_mixer for playback. Therefore i create a FILE *
> filepointer, place it to the beginning of an ogg file inside the archive
> and hand over the filepointer to ov_open. ( command: ov_open(fp,
> &music->vf, NULL, 0) ). This works fine so far. The problem is: if i put
> many oggs together in one archive, the playback stops only after the last
> ogg file. Why is this a problem ? Suppose i want to play the ogg files in
> random order. The playback must end after the current ogg, so the user can
> select a random new ogg file, place the filepointer to it and play the ogg.
>
> So is there a method to determine when one ogg file ended and the other
> begins ?
>

There are two ways you can do this:

1) Check the 'section' variable after each call to ov_read(). If it has 
changed, then you've moved to a new ogg stream.

2) Use ov_open_callbacks() rather than ov_open(), and provide appropriate 
callbacks. The close callback can just do nothing (because you probably want 
to keep it open for playing some other file from the archive. The 
seek/tell/read callbacks should be simple wrappers, they just have to take 
into account the offset from the start of the archive that the individual 
file starts/ends. You'll want to return EOF appropriately from the read 
callback when you get to the end.

I'd recommend option 2.

Mike

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