Re: Starting/stopping decoding of same stream
Rob Leslie <[email protected]>
| Newsgroups | gmane.comp.audio.mad.devel |
|---|---|
| Message-ID | <[email protected]> |
On Mar 26, 2004, at 4:54 AM, Erik Jälevik wrote:
> I need to stop and start decoding the same stream at regular intervals
> depending on the PCM buffer size. So at stage 3 above, I call
> mad_decoder_run on the properly initialised decoder, and in the output
> callback, I return MAD_FLOW_STOP when I've been given enough frames to
> fill the buffer.
>
> Up until now everything's fine. But, it seems that the next time the
> buffer gets empty and I restart by calling mad_decoder_run again on
> the same decoder, the decoder doesn't remember the input last given to
> it by the input callback. So the first thing it does is call the input
> callback for more input. The mad_stream->next_frame passed into the
> input callback is always 0 after a restart.
>
> This causes problems because the input callback has no way of knowing
> how far into the previous chunk MAD has decoded. Is there any way to
> find this out from the decoder itself?
Only if you record the position yourself, perhaps in the filter
callback. But you will encounter a more serious problem, which is that
all the other decoder state (synthesis filterbank, Layer III overlap,
etc.) is destroyed when mad_decoder_run() returns.
> I haven't looked at the low-level API yet, will I maybe need to use
> that to achieve what I want?
I think you will indeed. It's not terribly difficult; for some
guidance, have a look at Bertrand Petit's madlld:
http://www.bsd-dk.dk/%7Eelrond/audio/madlld/
Cheers,
--
Rob Leslie
[email protected]