[Scummvm-devel] Idea: IndexedMp3AudioStream

Michael Madsen michael at birdiesoft.dk
Thu Oct 7 14:38:32 CEST 2010



> -----Original Message-----
> From: yotam barnoy [mailto:yotambarnoy at gmail.com]
> Sent: Thursday, October 07, 2010 2:23 PM
> To: Johannes Schickel
> Cc: ScummVM devel
> Subject: Re: [Scummvm-devel] Idea: IndexedMp3AudioStream
> 
> >> 1. We immediately get the playback length of every AudioCD
> >> AudioStream, both in AudioCDManager and in makeLoopingAudioStream. In
> >> our mp3 files (which are usually VBR) we have to read all the way
> >> from the start of the file to the end of the file in order to get the
> >> playback length. CD rips can be in the order of tens of megabytes and
> >> mp3 files need to be read frame by frame, which on slow devices
> >> causes read times of 20 seconds or more.
> >>
> >
> > To be precise currently we always compute the length of the MP3 file
> > in the MP3Stream constructor. The "getLength()" call is a O(1)
> > operation later on (or rather should be for all SeekableAudioStream
> > implementations :-P). So I am unsure why you mention these code parts
> > here...
> 
> Yeah that's a lack of clarity as a result of re-editing my email. What I
> meant to say is that those are the places that retrieve the length, so if
> we deal with one the other will still have the issue.

I'm not really familiar with the sound system, so perhaps more than this is needed - but one option could be to take advantage of ID3 tags.

ID3v2 defines a TLEN field which is intended for the length of an MP3 file in milliseconds (as a string). It should be possible to make a tool which creates and fills in this field, and then MP3Stream can simply check if this field is present and only need to seek through the entire file if it's not.

We can also use the TXXX field for our own data, so if, for example, we need a frame count, we could place that there - or we could use ID3v2.4, which allows multiple values in the TLEN field, separated with a NULL character.

This *does* rely on the MP3 file not being edited after we tag it, but it might be an acceptable way of dealing with the getLength call.

Michael





More information about the Scummvm-devel mailing list