[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 ?
Andre Krause
post at andre-krause.net
Wed Apr 21 12:01:31 PDT 2004
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 ?
Current code looks like this:
/* Load an OGG stream from the given file pointer */
OGG_music *OGG_new(FILE *fp)
{
OGG_music *music;int xx;
music = (OGG_music *)malloc(sizeof *music);
if ( music ) {
/* Initialize the music structure */
memset(music, 0, (sizeof *music));
OGG_stop(music);
OGG_setvolume(music, MIX_MAX_VOLUME);
music->section = -1;
if ( ov_open(fp, &music->vf, NULL, 0) < 0 ) {
SDL_SetError("Not an Ogg Vorbis audio stream");
free(music);
return(NULL);
.....
<p>And playing the ogg:
/* Read some Ogg stream data and convert it for output */
static void OGG_getsome(OGG_music *music)
{
int section;
int len;
char data[4096];
SDL_AudioCVT *cvt;
len = ov_read(&music->vf, data, sizeof(data), 0, 2, 1, §ion);
if ( len <= 0 ) {
if ( len == 0 ) {
music->playing = 0;
}
return;
}
.....
<p><p>Any idea please ?
Thanks, andre
<p><p><p>_________________________________________
Andre Krause
Dipl. Inform.
Department of Biological Cybernetics
Faculty of Biology
University of Bielefeld
PO Box 10 01 31
33501 Bielefeld
Germany
Phone: +49-521-106-5519
Mobil: +49-177-7465055
Home : +49-521-3044776
Email: post at andre-krause.net
ICQ# : 68306404
More ways to contact me: http://wwp.icq.com/68306404
Homepage: http://www.andre-krause.net
http://www.andre-krause.de
_________________________________________
War isn't politics, my dear. It is indeed he only human activity that is
rottener than politics. RexStout
_________________________________________
--- >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