Gad Hayisraeli gad@syete.co.il wrote:
i'm trying to get the best from madplay (0.2.12b), and my goal is to jump to certain milisecond in the song, when i get an interrupt (keyboard). i use mad_stream_skip within mad_header_dcode() to acheve this. while monitoring the latency between getting the interrupt and having the jump done, i noticed that both in assabet and intel PIII i acheve latency of between 2-50 miliseconds. by saying latency, i mean that while i wanted to jump to X position, i jumped de-facto to X+20ms, for example. can i make it better ? (i want to acheve <10ms or fixed latency up to 40ms) maybe my measure isnt right ? ( i take stream->current_frame time after the skip, when i get into mad_header_decode(), and the latency calculated by: latency=desired time-current time. maybe current time isnt calculated exctly ? mabe i need to use real-time linux kernel ?
Each Layer III frame holds about 26ms of audio data (at 44.1kHz) so you could see up to this much latency just to sync with the next frame.
If you are unlucky enough to jump past part of the bit reservoir holding bits for the next frame, the frame will not be able to be decoded and will be skipped, adding even more latency.
How do you calculate time from stream->current_frame?