[Flac] Decoding a continues stream
GOO Creations
goocreations at gmail.com
Wed Jul 11 06:18:56 PDT 2012
Hi,
I've trying to decode a FLAC audio stream. I have a reader which sends
raw byte data to my FLAC wrapper class. Only once the decode function
below returns, the reader will send new data.
Hence I want to decode until the stream is empty, but I will add new
data to the stream once it is empty.
*void **MyFlacCoder::**decode(char *data, int bytes)
{
mBuffer = input;
mBufferBytes = bytes;
FLAC__stream_decoder_process_until_end_of_stream(mDecoder);
}
*
My read callback looks as follows:
*
FLAC__StreamDecoderReadStatus flacReadDecode(const FLAC__StreamDecoder
*decoder, FLAC__byte buffer[], size_t *bytes, void *client)
{
MyFlacCoder *coder = (MyFlacCoder*) client;
int size =min(*bytes, coder->mBufferBytes);
if(size <= 0)
{
*bytes = 0;
return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM;
}
memcpy(buffer, coder->mBuffer, size);
*bytes = size;
coder->mBuffer += size;
coder->mBufferBytes -= size;
return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
}*
As far as I understand*FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM*
notifies FLAC to stop decoding (no more data will come). However, in my
case I only want FLAC to "pause" and still keep the data that was not
processed yet, until new data is available and I call
*FLAC__stream_decoder_process_until_end_of_stream* again. So
*FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM* in my case actually
means that the current stream has no more data, but I will add new data
to the stream once it's empty. The problem is that frames might overlap.
Hence I can clear FLAC's buffer, because there might still be half a
frame in the buffer that couldn't be decoded yet.
Any suggestions on how I can do this?
Thank you
Christoph
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.xiph.org/pipermail/flac/attachments/20120711/6722d36d/attachment.htm
More information about the Flac
mailing list