On Monday, April 1, 2002, at 01:14 AM, Guenther Sohler wrote:
once again, I try to get help with my problem. I have written some mid level routines around mad to open, close, read and seek within mp3 somehow seek does not work. My goal is seeking to any sample position within the decoded stream And to be fast I just decode each frame header. The Problem is now, that something is wrong. I seek to a wrong position Can you please have a look into my code and saying what is wrong ?
Guenther,
I'm sorry I haven't responded to your question. I don't really understand what problem you are having, and your code is difficult to digest.
My first suggestion would be not to read the .seconds and .fraction fields directly from the mad_timer_t structure, but to use the API routines such as mad_timer_count() and mad_timer_compare() instead.
In general I think you have the right idea; by decoding only the frame headers you can advance through the stream knowing exactly how much playing time is represented by each frame. You correctly use mad_timer_add( ) to sum these times and maintain a timer with the current time position. I would suggest using mad_timer_compare() to compare the current time position with a desired time position.
I notice that you call mad_stream_buffer() before every call to mad_header_decode(); this is neither necessary nor recommended. You should only call mad_stream_buffer() after (re)loading your buffer with new data, for example in response to MAD_ERROR_BUFLEN. Perhaps this is a source of the problem you are having.
-- Rob Leslie rob@mars.org