OK, the xing/mp3 specific functions are:
AdvanceBufferToNextFrame() -- this function reads bytes from the input
buffer until the head of the input buffer points to a valid MP3 frame.
GetHeadInfo() -- this function gets the information about the bitstream
(sample rate, MPEG1/2, bitrate)
GetBitstreamStats() -- this function calls GetHeadInfo to get the crucial
info and it figures out the duration of the bitstream
ExtractI4(), GetXingHeader(), SeekPoint() -- these are Xing VBR TOC specific
functions
Generic functions are:
Prepare() -- this is a setup function where the input and output buffers get
setup
Clear() -- clear the output buffer
CanDecode() -- gets called to see if this LMC can decode this media. If the
decoder does not see a valid MP3 bitstream it returns an error.
GetExtensions() -- returns a list of file extensions that it can handle
ExtractMediaInfo -- this function gets called by the player to have the
decoder extract stream info using the GetBitstreamStats function.
CalculateSongLength() -- this function returns the length of the bitstream.
It does not use the input object to read the MP3 stream. There is too much
overhead involved with using the input objects, so normal file io is used.
This function then calls GetBitstreamStats() to do the work.
InitDecoder() -- this function initializes the decode library
DecodeWorkerThreadFunc() -- this function is the thread entry point for the
decoder
DecodeWork() -- this function is the workhorse of the decoder. I'll describe
this in more detail
BeginRead() -- this function encapsulates the buffering for streams. This
function will call the input BeginRead() function if its not a stream. If it
is a stream, it will call the BeginRead() function if enough data is
available. If not, it stops the play and buffers up the stream for a number
of seconds and then resumes the decode process.
BlockingBeginRead() -- this function blocks and loops to wait for new
data -- it does not return unless there is data or an error.
EndRead() -- is the completement to BeginRead()
ChangePosition() -- this function is called as a response to a seek. It is
given a frame number to seek to. This is too MP3 specific to make me happy.
Ignore the Equalizer stuff -- its not supported at the moment.
DecodeWork() details: The decode work function will initialize the decoder
and do a bunch of housekeeping to get the pipeline moving. Then it will ask
the output buffer if there is space for a decoded frame. If not, it sleeps
on a semaphore and loops. If there is enough space it will begin a write
operation on the output buffer and then it will ask the input buffer if
there is enough data for a whole frame. If not, it sleeps on a semaphore and
loops. If so, it will start a read operation on the input buffer. Then it
will call the decoder to decode one frame. After that it will finish the
read and write operations on the input and output buffers and start the
whole process over again until the process is aborted or the input buffer
signals EOF.
Interwoven in this is the event scheme for telling the PMO what's going on.
The eventbuffer is an output buffer that also supports passing events to the
PMO. The first event that the PMO needs to receive is an Init event to tell
it the sample rate and the size of the decoded frames and so on. Before the
decoder writes a frame to the buffer it will send the timestamp of the frame
to the event buffer via a timeinfo event. This gives the outputbuffer enough
information to know what frame it is playing at what time -- this
information is in turn passed to the player so the player can display the
current time. Finally the decoder will send a quit message which will cause
the PMO to finish playing all the samples and then disband the decode
pipeline.
There are many problems with this decode pipeline -- MP3 specifics have
cropped up in various places where the code should be generic, and the
stream buffering was added as an afterthought to support HTTP and RTP
streams. When we go to FreeAmp 3.0 we're planning on haveing a much more
flexible decode architecture that will allow us to have arbitrary data
sources, filters and data consumers. This is why I am hesitant to completely
documen the current structure -- it may not be well suited to adding other
decoders and it will go away in the next few months.
I hope this helps.
--ruaok Freezerburn! All else is only icing. -- Soul Coughing
Robert Kaye -- [EMAIL PROTECTED] http://moon.eorbit.net/~robert
_______________________________________________
[EMAIL PROTECTED]
http://www.freeamp.org/mailman/listinfo/freeamp-dev