[theora-dev] Cortado gapless looping

Benjamin M. Schwartz bmschwar at fas.harvard.edu
Sat Feb 6 09:43:49 PST 2010


Gregor Richards wrote:
> I've been looking in to adding it myself, but I'm not used to Java
> enough to digest a project that complex. So I'm hoping that somebody
> with more indepth knowledge of Cortado could give me some tips on where
> I need to add it. I figure there are a few possible places ... there
> could be a class that abstracts an ogg file and presents it as a stream
> of the same ogg file over and over again, or at a higher level whatever
> is buffering the audio could understand how to reread any file type ...
> but I'm not sure where or how to implement either of these :)

The principal difficulty I see with looping is avoiding downloading the
file over and over again.

In Cortado, I believe that every "seek" event (e.g. restarting the stream)
causes all current buffers to be dropped.  This makes sense because
Cortado is designed to handle large files, and cannot touch the disk.
Cortado only buffers ahead of the current playback point, for streaming.
I imagine that you don't want users to be downloading your loop over and
over again; otherwise you could just stream it continuously from the server.

One relatively easy hack would be to forgo all the http streaming, and
instead ship the vorbis file inside the .jar.  This would simplify your
life considerably, but would force users to download the entire loop
before initiating playback.  It's also less reusable than one might like.

The ideal solution would involve augmenting the buffering logic to allow
caching of entire files, up to some size limit, so that one may loop back
to the beginning.  My best idea on how to accomplish this is to
(optionally) cache the file inside HTTPSrc.  Even after that, some
trickery would be needed for gapless playback.  OggDemux would probably
require a "loop" flag, which would cause it to seek to the beginning if it
receives an End Of Stream (EOS) message, instead of passing forward the EOS.

By the way, Cortado's internal design is very close to Gstreamer 0.10.
Reading the gstreamer docs may help to understand what's going on.

Feel free to keep asking questions here, of course.

--Ben



-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: OpenPGP digital signature
Url : http://lists.xiph.org/pipermail/theora-dev/attachments/20100206/3f6ffb07/attachment.pgp 


More information about the theora-dev mailing list